Now we can use solveFixed in scripting:
dvar int x in 0..10;
dvar float y in 0..10;
minimize x+y;
subject to {
ctx :
x >= 1/2;
cty:
y>=1/2;
}
main {
var status = 0;
thisOplModel.generate();
cplex.solve();
writeln("Solve");
writeln("x=",thisOplModel.x);
writeln("y=",thisOplModel.y);
writeln("OBJECTIVE: ",cplex.getObjValue());
writeln("SolveFixed");
if (cplex.solveFixed()) {
writeln("x=",thisOplModel.x);
writeln("y=",thisOplModel.y);
writeln("OBJECTIVE: ",cplex.getObjValue());
writeln("dual CTX:",thisOplModel.ctx.dual);
writeln("dual CTY:",thisOplModel.cty.dual);
}
}
which gives
Solve
x=1
y=0.5
OBJECTIVE: 1.5
SolveFixed
x=1
y=0.5
OBJECTIVE: 1.5
dual CTX:0
dual CTY:1
------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]
------------------------------
Original Message:
Sent: Wed August 24, 2022 05:21 AM
From: Archive User
Subject: Re: Solvefixed in OPL to get dual for MIP
Originally posted by: ouaigooo
Thanks Alex,
Is there a way to iterate all int vars of model (in order to fix them) ?
Something like for (var x in thisOplModel.getVariables()) if (x.isIntVar), ...
It would be cool if it could work without specifying explicitely the variable names and their dimensions
kr -- lucien
#DecisionOptimization