Hi
at https://www.ibm.com/developerworks/community/forums/html/topic?id=0289cdc7-a237-4442-91f3-9c8e2944a8a7&ps=25
we can see how to do incremental changes and solve again.
Sometimes you need to use part of the first solution in the second solve. And users seem to start with codes that look like
dvar int x[1..3] in 1..10;
subject to
{
ct:sum(i in 1..3) x[i]==10;
}
execute
{
writeln("x=",x);
}
main
{
thisOplModel.generate();
cplex.solve();
thisOplModel.postProcess();
// change a constraint
thisOplModel.ct.UB=11;
thisOplModel.ct.LB=11;
// freeze part of the decision variables
thisOplModel.x[1].UB=thisOplModel.x[1].solutionValue;
thisOplModel.x[1].LB=thisOplModel.x[1].solutionValue;
cplex.solve();
thisOplModel.postProcess();
}
but they get an error because the first model solution is not valid any more when you modify the model.
They get " Script execution failed with status -2. "
What they should rather write:
dvar int x[1..3] in 1..10;
subject to
{
ct:sum(i in 1..3) x[i]==10;
}
int copysolution[i in 1..3]=x[i];
execute
{
writeln("copysolution=",copysolution);
}
main
{
thisOplModel.generate();
cplex.solve();
thisOplModel.postProcess();
// change a constraint
thisOplModel.ct.UB=11;
thisOplModel.ct.LB=11;
// freeze part of the decision variables
thisOplModel.x[1].UB=thisOplModel.copysolution[1];
thisOplModel.x[1].LB=thisOplModel.copysolution[1];
cplex.solve();
thisOplModel.postProcess();
}
which gives
copysolution= [8 1 1]
copysolution= [8 2 1]
regards
#DecisionOptimization#OPLusingCPLEXOptimizer