int main(int argc, char** argv) { IloEnv env; try { IloModel m(env); IloCplex cplex(env); IloObjective obj; IloNumVarArray vars(env); IloRangeArray rngs(env); const char* datadir = (argc >= 2) ? argv[1] : "../../../examples/data"; char *fname = new char[strlen(datadir) + 1 + strlen("noswot.mps") + 1]; sprintf(fname, "%s/noswot.mps", datadir); env.out() << "reading " << fname << endl; cplex.importModel(m, fname, obj, vars, rngs); delete[] fname; env.out() << "extracting model ..." << endl; cplex.extract(m); IloRangeArray cuts(env); makeCuts(cuts, vars); // Use addUserCuts when the added constraints strengthen the // formulation. Use addLazyConstraints when the added constraints // remove part of the feasible region. Use addCuts when you are // not certain. cplex.addUserCuts(cuts); cuts.endElements(); cuts.end(); cplex.setParam(IloCplex::Param::MIP::Interval, 1000); env.out() << "solving model ...\n"; cplex.solve(); env.out() << "solution status is " << cplex.getStatus() << endl; env.out() << "solution value is " << cplex.getObjValue() << endl; } catch (IloException& ex) { cerr << "Error: " << ex << endl; } env.end(); return 0; }
int main(int argc, char** argv) { IloEnv env; try { IloModel m(env); IloCplex cplex(env); IloObjective obj; IloNumVarArray var(env); IloRangeArray con(env); const char* datadir = (argc >= 2) ? argv[1] : "../../../examples/data"; char *fname = new char[strlen(datadir) + 1 + strlen("noswot.mps") + 1]; sprintf(fname, "%s/noswot.mps", datadir); env.out() << "reading " << fname << endl; cplex.importModel(m, fname, obj, var, con); delete[] fname; env.out() << "constructing cut callback ..." << endl; IloExprArray lhs(env); IloNumArray rhs(env); makeCuts(var, lhs, rhs); cplex.use(CtCallback(env, lhs, rhs, cplex.getParam( IloCplex::Param::Simplex::Tolerances::Feasibility))); env.out() << "extracting model ..." << endl; cplex.extract(m); cplex.setParam(IloCplex::Param::MIP::Interval, 1000); cplex.setParam(IloCplex::Param::MIP::Strategy::Search, IloCplex::Traditional); env.out() << "solving model ...\n"; cplex.solve(); env.out() << "solution status is " << cplex.getStatus() << endl; env.out() << "solution value is " << cplex.getObjValue() << endl; } catch (IloException& ex) { cerr << "Error: " << ex << endl; } env.end(); return 0; }