Originally posted by: hugotorres
Hello,
I'm trying to replicate the idea present on the mulprod example by having a loop where the data is changed and the model is ran again. The problem is that It always finds an issue with the CPLEX basis, saying "warm start preparation failed: 1262". I tried to search if this value had any special meaning but with no sucess. I'll leave my code here and appreciate any help you can give :)
int p=...;
int m=...;
range pecas=1..p;
range machines=1..m;
int whours=...;
int processTimes[pecas][machines]=...;
int availableMachines[machines]=...;
dvar int+ x[pecas][machines];
dvar int+ y;
dexpr int Z = y;
maximize Z;
subject to
{
forall(i in machines)
sum(j in pecas) (processTimes[j][i]*x[j][i]) <= whours*60*availableMachines[i];
forall(j in pecas)
sum(i in machines) (x[j][i])-y >= 0;
}
main
{
var status = 0;
thisOplModel.generate();
var model = thisOplModel;
var woHours = model.whours;
var best;
var curr = Infinity;
var basis = new IloOplCplexBasis();
while(woHours != 0)
{
best = curr;
writeln("Solve with working hours = ",woHours);
if (cplex.solve()) {
curr = cplex.getObjValue();
writeln();
writeln("OBJECTIVE: ",curr);
}
else {
writeln("No solution!");
break;
}
if ( !basis.getBasis(cplex) ) {
writeln("warm start preparation failed: ",basis.status);
break;
}
// prepare next iteration
var def = produce.modelDefinition;
var data = produce.dataElements;
if ( produce!=thisOplModel ) {
produce.end();
}
produce = new IloOplModel(def,cplex);
woHours--;
data.whours = woHours;
produce.addDataSource(data);
produce.generate();
if ( !basis.setBasis(cplex) ) {
writeln("warm start ",basis.Nrows,"x",basis.Ncols," failed: ",basis.status);
break;
}
}
basis.end();
if (Math.abs(cplex.getObjValue() - 393.5)>=0.01) {
status = -1;
}
if (best != Infinity) {
writeln("plan = ",produce.Plan);
}
if ( model!=thisOplModel ) {
model.end();
}
status;
}
#DecisionOptimization#OPLusingCPLEXOptimizer