Originally posted by: SystemAdmin
Hi Tobias,
I am ina very bad hurry before approachign a deadline so I made it very simple. Looks naive but might be worth testing:
I made a simple exampel as following:
#include <ilcplex/ilocplex.h>
ILOSTLBEGIN
int main(int argc, char **argv) {
IloEnv env;
try {
IloNumVarArray x(env, 10, 0,1, ILOINT);
IloModel model(env);
IloCplex cplex(env);
IloExpr exprObj(env);
exprObj = IloSum(x);
IloRangeArray rng1(env);
IloRangeArray rng2(env);
rng1.add(x[1]+x[2] + x[3] + x[4] <= 1);
IloObjective obj(env, IloMaximize(env));
obj.setExpr(exprObj);
model.add(rng1);
model.add(rng2);
cplex.extract(model);
cplex.solve();
cout<< cplex.getObjValue() << endl;
cplex.exportModel("before.lp");
rng2.add(x[5]+x[6] + x[7] + x[8] <= 1);
// optional cplex.extract(model);
cplex.solve();
cout<< cplex.getObjValue() << endl;
cplex.exportModel("after.lp");
}
catch(IloException& e) {
cerr << " ERROR: " << e << endl;
}
catch(...) {
cerr << " ERROR" << endl;
}
env.end();
return 0;
}
this is my output
// before.lp
\Problem name: IloCplex
Minimize
obj:
Subject To
id14: id1 + id2 + id3 + id4 <= 1
Bounds
0 <= id1 <= 1
0 <= id2 <= 1
0 <= id3 <= 1
0 <= id4 <= 1
Binaries
id1 id2 id3 id4
End
// after.lp
\Problem name: IloCplex
Minimize
obj:
Subject To
id14: id1 + id2 + id3 + id4 <= 1
Bounds
0 <= id1 <= 1
0 <= id2 <= 1
0 <= id3 <= 1
0 <= id4 <= 1
Binaries
id1 id2 id3 id4
End
I hope that helps.
#CPLEXOptimizers#DecisionOptimization