#include #include "ampl/ampl_c.h" int main() { // Create an AMPL instance AMPL* ampl; AMPL_CALL(AMPL_Create(&l)); /* // If the AMPL installation directory is not in the system search path: AMPL_ENVIRONMENT *env; AMPL_EnvironmentCreate(&env, "full path to the AMPL installation directory", ""); AMPL_CALL(AMPL_CreateWithEnv(&l, env)); */ // Get the value of the option presolve and print bool exists; bool presolve = false; AMPL_CALL(AMPL_GetBoolOption(ampl, "presolve", &exists, &presolve)); int s; #ifdef FMT_GCC_VERSION s = FMT_GCC_VERSION; #else s = -1; #endif printf("AMPL presolve is %s\n", presolve ? "true" : "false"); printf("FMT_GCC_VERSION = %d\n", s); // Set the value to false (maps to 0) AMPL_CALL(AMPL_SetBoolOption(ampl, "presolve", false)); // Get the value of the option presolve and print AMPL_CALL(AMPL_GetBoolOption(ampl, "presolve", &exists, &presolve)); printf("AMPL presolve is now %s\n", presolve ? "true" : "false"); // Check whether an option with a specified name // exists char *value; AMPL_CALL(AMPL_GetOption(ampl, "solver", &exists, &value)); if (exists) { printf("Option solver exists and has value: %s\n", value); } AMPL_StringFree(&value); // Check again, this time failing AMPL_CALL(AMPL_GetOption(ampl, "s_o_l_v_e_r", &exists, &value)); if (!exists) { printf("Option s_o_l_v_e_r does not exists!\n"); } AMPL_StringFree(&value); //AMPL_EnvironmentFree(&env); AMPL_Free(&l); return 0; }