I have a strange problem in CPLEX C++: i have the following code:
IloEnv env;
IloModel model(env);
IloNumVar X(env, 0, IloInfinity, ILOFLOAT);
IloNumVar Y(env, 0, IloInfinity, ILOFLOAT);
model.add(X + Y <= 5);
model.add(IloMaximize(env, 2*X + Y));
IloCplex mycplex(env);
mycplex.extract(model);
IloBool feasible = mycplex.solve();
if(feasible == IloTrue){
cout << mycplex.getObjValue() << "\n"; //i get the obj value of 10
}
IloModel model1 = model.getClone(env);
model1.add(X <= 4);
IloCplex mycplex1(env);
mycplex1.extract(model1);
IloBool feasible1 = mycplex1.solve();
if(feasible1 == IloTrue){
cout << mycplex1.getObjValue() << "\n"; //again I get the obj value 10
}
My question is, why the second model also has the objective value of 10 although I've added the constraint that x <= 4. Then the objective value should be 9??
thank you in advance