Originally posted by: EBKN_Eduardo_Aime
Thanks a lot Philippe.
I tried the following:
The model is syntactically correct.
Runs well the first solution, but in the second run indefinitely.
I'm not sure how to do the step: "fill solution".
/*********************************************
* OPL 12.5.1.0 Model
*********************************************/
using CP;
ranger = 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 search.
int RestartValues[iin 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;
}
main{
thisOplModel.generate();
var ThisModelDef = thisOplModel.modelDefinition;
/* Default behaviour */
writeln("Default Behaviour");
var cp1 = new IloCP();
var opl1 = new IloOplModel(ThisModelDef, cp1);
opl1.generate();
cp1.solve();
writeln(opl1.printSolution()); /* Solution OK */
/* Setting initial solution */
writeln("Setting Initial Solution ");
var cp2 = new IloCP();
var opl2 = new IloOplModel(ThisModelDef, cp2);
opl2.generate();
var RestartValues = thisOplModel.RestartValues ;
var x = thisOplModel.x;
var cpSolution = new IloOplCPSolution();
for(var i = 1; i=10; i++)
cpSolution.setValue(x[i], RestartValues[i]); /* Is this the right form to assign values ?? */
cp2.SetStartingPoint(cpSolution);
cp2.solve(); /* non-stop running !! */
writeln(opl2.printSolution());
opl1.end();
cp1.end();
opl2.end();
cp2.end();
}
//OUTPUT:
//Default Behaviour
//// solution with objective 65
//x = [0 0 0 10 0 0 0 0 0 0];
//y = [1 2 3 4 5 6 7 8 9 10];
//
//Setting Initial Solution
#CPOptimizer#DecisionOptimization