Description
Test =e= indicator constraints. Contributed by Steve Dirkse, November 2011
Small Model of Type : MIP
Category : GAMS Test library
Main file : indic02.gms
$title Test of =e= indicator constraints (INDIC02,SEQ=542)
$onText
Test =e= indicator constraints.
Contributed by Steve Dirkse, November 2011
$offText
binary variable b;
positive variables x, y;
variable z;
equations
obj
e0 'on if b=0'
e1 'on if b=1'
useB 'trivial equation to get b into the model'
;
obj.. z =e= x + y;
e0.. y =e= -1.5*x + 4.5;
e1.. y =e= -2 *x + 5;
useB.. b =L= 1;
model m / all /;
$onEcho > copt.o99
indic e0$b 0
indic e1$b 1
$offEcho
$onEcho > cplex.o99
indic e0$b 0
indic e1$b 1
$offEcho
$onEcho > gurobi.o99
indic e0$b 0
indic e1$b 1
$offEcho
$onEcho > xpress.o99
indic e0$b 0
indic e1$b 1
miprelstop 0
$offEcho
$echo gams/indicatorfile = "cplex.o99" > scip.o99
m.optfile = 99;
m.optcr = 1e-5;
x.up = 10;
* x=1, y=3 solves both e0 and e1
* if y.up < 3, e0 is favored, and b = 0 is optimal
* if y.up > 3, e1 is favored, and b = 1 is optimal
y.up = 2;
solve m using mip max z;
abort$[m.solvestat <> %solveStat.normalCompletion%] "wrong solver status";
abort$[m.modelstat <> %modelStat.optimal%] "wrong model status";
abort$[abs(b.l) > 1e-6] 'binary not zero', b.l;
abort$[abs(4.5 - y.l - 1.5*x.l) > 1e-6] 'e0 not satisfied', x.l, y.l;
y.up = 4;
solve m using mip max z;
abort$[m.solvestat <> %solveStat.normalCompletion%] "wrong solver status";
abort$[m.modelstat <> %modelStat.optimal%] "wrong model status";
abort$[abs(b.l-1) > 1e-6] 'binary not one', b.l;
abort$[abs(5 - y.l - 2*x.l) > 1e-6] 'e1 not satisfied', x.l, y.l;