Originally posted by: SystemAdmin
In the warm star example, why if I make these modifications to the decisions variables the program don´t take the initial solution:
range r = 1..10;
dvar float+ x[r];
dvar float+ y[r];
// The following array of values (defined as data) will be used as
// a starting solution to warm-start the CPLEX search.
float values
i in r = (i==5)? 10.5 : 0;
minimize
sum( i in r ) x[i] + sum( j in r ) y[j];
subject to{
ctSum:
sum( i in r ) x[i] >= 10.5;
forall( j in r )
ctEqual:
y[j] == j;
}
main{
thisOplModel.generate();
var def = thisOplModel.modelDefinition;
// Default behaviour
writeln("Default Behaviour");
var opl1 = new IloOplModel(def, cplex);
opl1.generate();
cplex.solve();
writeln(opl1.printSolution());
// Setting initial solution
writeln("Setting initial solution");
var opl2 = new IloOplModel(def, cplex);
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.setVectors(cplex);
cplex.solve();
writeln(opl2.printSolution());
opl1.end();
opl2.end();
0;
}
You can see in the results that the program don´t take the initial solution:
Default Behaviour
// solution (optimal) with objective 65.5
// Quality There are no bound infeasibilities.
// There are no reduced-cost infeasibilities.
// Maximum Ax-b residual = 0
// Maximum c-B'pi residual = 0
// Maximum |x| = 10.5
// Maximum |slack| = 0
// Maximum |pi| = 1
// Maximum |red-cost| = 1
// Condition number of unscaled basis = 1.0e+000
//
x = [0
0 0 0 0 0 0 0 0 10.5];
y =
1 2 3 4 5 6 7 8 9 10;
Setting initial solution
// solution (optimal) with objective 65.5
// Quality There are no bound infeasibilities.
// There are no reduced-cost infeasibilities.
// Maximum Ax-b residual = 0
// Maximum c-B'pi residual = 0
// Maximum |x| = 10.5
// Maximum |slack| = 0
// Maximum |pi| = 1
// Maximum |red-cost| = 1
// Condition number of unscaled basis = 1.0e+000
//
x = [0
0 0 0 0 0 0 0 0 10.5];
y =
1 2 3 4 5 6 7 8 9 10;
#DecisionOptimization#OPLusingCPLEXOptimizer