Hi,
if you enjoyed the warmstart example let me start from there.
With CPO
using CP;
range r = 1..10;
dvar int+ x[r];
dvar int+ y[r];
// The following array of values (defined as data) will be used as
// a starting solution to warm-start the CP Optimizer search.
int values[i in r] = (i==5)? 10 : 0;
minimize sum( i in r ) x[i] + sum( j in r ) y[j];
subject to
{
ctSum: sum( i in r ) x[i] >= 10;
forall( j in r ) ctEqual: y[j] == j;
}
execute
{
writeln(x);
}
main
{
thisOplModel.generate();
var sol=new IloOplCPSolution();
for(var i=1;i<=10;i++) sol.setValue(thisOplModel.x[i],thisOplModel.values[i]);
cp.solve();
thisOplModel.postProcess();
cp.setStartingPoint(sol);
cp.solve();
thisOplModel.postProcess();
}
gives
[0 0 0 0 0 10 0 0 0 0]
[0 0 0 0 10 0 0 0 0 0]
and then if you move to scheduling
using CP;
range r = 1..10;
dvar interval x[r] size 1;
dvar interval y[r] size 1;
// The following array of values (defined as data) will be used as
// a starting solution to warm-start the CP Optimizer search.
int values[i in r] = (i==5)? 10 : 0;
minimize sum( i in r ) startOf(x[i]) + sum( j in r ) startOf(y[j]);
subject to
{
ctSum: sum( i in r ) startOf(x[i]) >= 10;
forall( j in r ) ctEqual: startOf(y[j]) == j;
}
execute
{
for(i in r) write(Opl.startOf(x[i])," ");
writeln();
}
main
{
thisOplModel.generate();
var sol=new IloOplCPSolution();
for(var i=1;i<=10;i++) sol.setStart(thisOplModel.x[i],thisOplModel.values[i]);
cp.solve();
thisOplModel.postProcess();
cp.setStartingPoint(sol);
cp.solve();
thisOplModel.postProcess();
}
gives
0 0 0 0 0 0 0 0 0 10
0 0 0 0 10 0 0 0 0 0
regards
#DecisionOptimization#OPLusingCPLEXOptimizer