Integer relaxation
Presents a model that shows how to relax integer constraints then undo the relaxation.
OPL allows relaxation of integer constraints on decision
variables. With OPL, there is a simple way to relax all integer decision
variables at once and to convert a MIP problem to an LP problem: just
call the method IloOplModel.convertAllIntVars as
shown in the model below, convert_example.mod.
The inverse operation is also available. To undo integer
relaxation, call the method IloOplModel.unconvertAllIntVars.
Relaxing an integer constraint and undoing relaxation (convert_example.mod)
dvar int x in 0..10;
minimize x;
subject to {
ct :
x >= 1/2;
}
main {
var status = 0;
thisOplModel.generate();
if (cplex.solve()) {
writeln("Integer Model");
writeln("OBJECTIVE: ",cplex.getObjValue());
if (cplex.getObjValue() != 1) {
status = -1;
}
}
thisOplModel.convertAllIntVars();
if (cplex.solve()) {
writeln("Relaxed Model");
writeln("OBJECTIVE: ",cplex.getObjValue());
if (cplex.getObjValue() != 0.5) {
status = -1;
}
}
thisOplModel.unconvertAllIntVars();
if (cplex.solve()) {
writeln("Unrelaxed Model");
writeln("OBJECTIVE: ",cplex.getObjValue());
if (cplex.getObjValue() != 1) {
status = -1;
}
}
status;
}
Both methods are available for flow control scripting, and in the C++, Java™, and .NET Interfaces.
For more information
For details on scripting, see IBM ILOG Script for OPL.
For details on the API, see each Interfaces Reference Manual.
To learn more about what MIP relaxation is and how to use it, see the CPLEX® documentation or consult a textbook about linear-programming.