IloCplex::solve()
, and its command line does not require the user to indicate an optimizer.
#include <ilcplex/ilocplex.h> ILOSTLBEGIN static void usage (const char *progname); int main (int argc, char **argv) { IloEnv env; try { IloModel model(env); IloCplex cplex(env); if ( argc != 2 ) { usage (argv[0]); throw(-1); } IloObjective obj; IloNumVarArray var(env); IloRangeArray rng(env); cplex.importModel(model, argv[1], obj, var, rng); cplex.extract(model); cplex.solve(); env.out() << "Solution status = " << cplex.getStatus() << endl; env.out() << "Solution value = " << cplex.getObjValue() << endl; IloNumArray vals(env); cplex.getValues(vals, var); env.out() << "Values = " << vals << endl; } catch (IloException& e) { cerr << "Concert exception caught: " << e << endl; } catch (...) { cerr << "Unknown exception caught" << endl; } env.end(); return 0; } // END main static void usage (const char *progname) { cerr << "Usage: " << progname << " filename" << endl; cerr << " where filename is a file with extension " << endl; cerr << " MPS, SAV, or LP (lower case is allowed)" << endl; cerr << " Exiting..." << endl; } // END usage |