I am writing code in opl cplex. I want to add new constraints like the following constraint to the model in each iteration;
x[1][2]==1.
How can I change the main block or post-processing? THANKYOU
I am writing code in opl cplex. I want to add new constraints like the following constraint to the model in each iteration;
x[1][2]==1.
How can I change the main block or post-processing? THANKYOU
https://github.com/AlexFleischerParis/zooopl/blob/master/zooincremental.mod
int nbKids=300;
float costBus40=500;
float costBus30=400;
dvar int+ nbBus40;
dvar int+ nbBus30;
dvar int+ emptyVar;
minimize
costBus40*nbBus40 +nbBus30*costBus30;
subject to
{
ctKids:40*nbBus40+nbBus30*30>=nbKids;
ctEmpty:0<=0;
}
execute DISPLAY_After_SOLVE
{
writeln("The minimum cost is ",costBus40*nbBus40 +nbBus30*costBus30);
writeln("We will use ",nbBus40," 40 seats buses and ",nbBus30," 30 seats buses ");
writeln();
}
main
{
thisOplModel.generate();
writeln("Basic model");
cplex.solve();
thisOplModel.postProcess();
writeln("Let us add a row : saying that nbBus40 and nbBus30 should be equal");
thisOplModel.ctEmpty.setCoef(thisOplModel.nbBus40,1);
thisOplModel.ctEmpty.setCoef(thisOplModel.nbBus30,-1);
thisOplModel.ctEmpty.setBounds(0,0);
cplex.solve();
thisOplModel.postProcess();
writeln("Let us add a column : saying that nbBus50 could also be used and their cost is 700");
cplex.setObjCoef(thisOplModel.emptyVar,700);
thisOplModel.ctKids.setCoef(thisOplModel.emptyVar,50);
cplex.solve();
writeln("The minimum cost is ",
thisOplModel.costBus40*thisOplModel.nbBus40.solutionValue +thisOplModel.nbBus30.solutionValue*thisOplModel.costBus30
+700*thisOplModel.emptyVar.solutionValue);
writeln("We will use ",thisOplModel.nbBus40.solutionValue," 40 seats buses ",thisOplModel.nbBus30.solutionValue,
" 30 seats buses and "+thisOplModel.emptyVar.solutionValue," 50 seats buses");
}