Originally posted by: pareto
Hello Alex,
I didnt understand why you have duplicated the decision variables, let me give you a more precise example with a similar model:
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 CPLEX search.
int values[1..10] = [5,2,2,5,2,2,5,5,2,6];
int values2[1..10] = [1,0,0,1,1,0,0,0,1,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] <= x[j];
}
main{
thisOplModel.generate();
var def = thisOplModel.modelDefinition;
// Default behaviour
writeln("Default Behaviour");
var cplex1 = new IloCplex();
var opl1 = new IloOplModel(def, cplex1);
opl1.generate();
cplex1.solve();
writeln(opl1.printSolution());
// Setting initial solution
writeln("Setting initial solution");
var cplex2 = new IloCplex();
var opl2 = new IloOplModel(def, cplex2);
opl2.generate();
var vectors = new IloOplCplexVectors();
// We attach the values (defined as data) as starting solution
// for the variables x.
vectors.attach(opl2.x,opl2.values);
vectors.attach(opl2.y,opl2.values2);
vectors.setVectors(cplex2);
cplex2.solve();
writeln(opl2.printSolution());
opl1.end();
cplex1.end();
opl2.end();
cplex2.end();
0;
}
if I write the code like this:
MIP start 'm1' defined initial solution with objective 36.0000. (which doesnt take values2(y) into account) . It is just objective value(x) when values are considered.
If I change the order in main and write:
vectors.attach(opl2.y,opl2.values2);
vectors.attach(opl2.x,opl2.values);
Then;
MIP start 'm1' defined initial solution with objective 14.0000. (now, it doesnt consider values(x warm-start variables), but y variables ). So, the warm-start is changed.
Normally, if I give warm-start for both x and y. I should get a MIP start of 40.000
Maybe I didnt get it completely, but I didnt understand it
Kind Regards
#DecisionOptimization#OPLusingCPLEXOptimizer