Originally posted by: rebecca.fries
Hi Alex,
thank you for the tip, but my model is not working yet... it is not relaxing the binary constraint for values bte [0,1] I have read a few posts in this forum now about this issue. I have read sth about using IloConversion .. But I don't know how to use it..
Another issue I have is that I get this message in the script, so it doesnt show me the value Gam of my decision variable (that should be relaxed btw 0 and 1)
Sorry for bothering you, but I just recently started using OPL for my masterthesis. I am really grateful for your help!
This is my current script
main
{
thisOplModel.generate();
var mod = thisOplModel;
//Relaxation
writeln("==Relax all==");
for(var m=1;m<=mod.M;m++){
for(var k=1;k<=mod.K;k++){
for(var t=1;t<=mod.T;t++){
if(t>1){ // here the constraint needs to be relaxed btw 0 and 1 (0.1 etc)
/* IloConversion conversion = cplex.conversion(mod.Gam[m][k][t], IloNumVarType.Float);
cplex.add(conversion); */
mod.Gam[m][k][t].LB= 0;
mod.Gam[m][k][t].UB= 1;
writeln("machine ",m," of product ",k," in period ",t,": Gam ",mod.Gam[m][k][t]);
} // if(t>=2){
} // T
} // K
} // M
// Fix and Relax
var iteration =1;
while (iteration <= 6){
writeln("Iteration=",iteration);
for(var m=1;m<=mod.M;m++){
for(var k=1;k<=mod.K;k++){
for(var t=1;t<=mod.T;t++){
if(t>iteration && iteration==1){
mod.Gam[m][k][t].LB= 0; //should relax all values btw 0 and 1
mod.Gam[m][k][t].UB= 1;
}
if(t == iteration){
mod.Gam[m][k][t].LB= 0; //determine optimal value setup btw. 0 and 1
mod.Gam[m][k][t].UB= 1;
}
if(t==iteration-1){ // set to opt value
writeln("fixed periods are: ",t," Gam at machine ",m," of product ",k,mod.Gam[m][k][t]);
mod.Gam[m][k][t].LB = mod.Gam[m][k][t].UB = mod.Gam[m][k][t].solutionValue;
writeln("======")
}
}
}
}
if(cplex.solve()){
writeln("=== ",mod.printSolution());
writeln(mod.printRelaxation());
writeln(mod.printConflict())
mod.postProcess();
iteration++
}
else{
writeln("No solution in ",iteration);
break;
}
}
mod.postProcess();
}
Regards,
Rebecca
#DecisionOptimization#OPLusingCPLEXOptimizer