$title Convexification of bilinear term binary times x (BILINEAR,SEQ=346)
$onText
The model demonstrates various formulations to represent bilinear
product terms of one continuous and one binary variable.
A set of 60 products i is produced on a set of machine with a given
total capacity. Some machine are special in the sense that if a
product is produced on one of them, cleaning treatment costs apply
caused by a set of cleaning treatment machines t.
A binary variable, delta(i), indicates that product i is produced on
one of the special machines. The model is simplified regarding the
machine-product relations.
Here we mimic a larger production problem, and just require that
E1.. sum(iE, delta(iE)) =e= 2;
E2.. sum(iO, delta(iO)) =e= 5;
which represents the fact that it cannot be avoided to use the special
machine and, thus, to have some cleaning treatment.
If product i is produced on a special machine, then the amount, y(i),
of the by-product is given by the recipe constraint y(i)=0.164*p(i),
where the non-negative variable p(i) is the amount produced on special
machines. For each product there is a specific yield of YS(i) $/ton.
The by-product is burnt and leads to an energy yield of YB(i) $/ton,
where YB(i) cplex.opt
mipEmphasis 3
$offEcho
if(%solvebigM1%, bigM1.optFile = 1; solve bigM1 max z using miqcp;);
* Alternative bigM forumulation
Positive Variable slack(i);
Equation bigM2_1, bigM2_2, bigM2_3 'bigM convexification of binary times bounded continuous';
bigM2_1(i).. p(i) =e= x(i) - slack(i);
bigM2_2(i).. p(i) =l= XUB(i)*delta(i); // this is not needed because of the sign of p in the objective
bigM2_3(i).. slack(i) =l= XUB(i)*(1 - delta(i));
Model bigM2 / coreConv, bigM2_1, bigM2_2, bigM2_3 /;
slack.up(i) = XUB(i);
if(%solvebigM2%, bigM2.optFile = 1; solve bigM2 max z using miqcp;);
* Cplex Indicator Formulation
Equation disj1, disj2 'indicator convexification of binary times bounded continuous';
disj1(i).. p(i) =e= x(i);
disj2(i).. p(i) =e= 0; // this is not needed because of the sign of p in the objective
Model indic / coreConv, disj1, disj2 /;
$onEcho > cplex.op2
indic disj1(i)$delta(i) 1
indic disj2(i)$delta(i) 0
cuts 3
$offEcho
if(%solveIndic%, indic.optFile = 2; solve indic max z using miqcp;);
* The EMP (Extended Math Programming) framework explores modeling
* extensions that result in non-traditional math programs (like
* disjunctions) and automate the reformulation into traditional math
* programs (like MIPs). The manually generated big-M and indicator
* formulations above are automatically produced by EMP from a model
* with disjunctions. Moreover, EMP provides a convex hull formulation
* (which is independent of a bigM) for disjunctions.
* EMP Formulations
File femp / "%emp.info%" /;
put femp;
$onEcho > jams.opt
SubSolver cplex
SubSolverOpt 1
$offEcho
* Convex Hull Convexification
putClose 'modeltype miqcp disjunction delta disj1 else disj2';
if(%solveEMPCH%, indic.optFile = 1; solve indic max z using emp;);
* Cplex Indicator Convexification
putClose 'modeltype miqcp disjunction indic delta disj1 else disj2';
if(%solveEMPI%, indic.optFile = 1; solve indic max z using emp;);
* Big-M Convexification type 1 (similar to bigM1 formulation)
put 'modeltype miqcp';
loop(i, put / 'disjunction bigM' XUB(i) delta(i) disj1(i) 'else' disj2(i));
putClose;
if(%solveEMPBM1%, indic.optFile = 1; solve indic max z using emp;);
* Big-M Convexification type 2 (similar to bigM2 forumlation)
put 'modeltype miqcp';
loop(i, put / 'disjunction bigM' XUB(i) 1e-4 1 delta(i) disj1(i) 'else' disj2(i));
putClose;
if(%solveEMPBM2%, indic.optFile = 1; solve indic max z using emp;);
* SOS1 Formulation
delta.prior(i) = inf; // relax binary requirement of delta
Set j 'binary choice' / 0, 1 /;
SOS1 Variable S1(i,j), S2(i,j);
Equation defS1_0, defS1_1, defS2_0, defS2_1 'selection constraints';
defS1_0(i).. S1(i,'0') =e= delta(i);
defS1_1(i).. S1(i,'1') =e= x(i) - p(i);
defS2_0(i).. S2(i,'0') =e= 1 - delta(i);
defS2_1(i).. S2(i,'1') =e= p(i);
Model sos1conv / coreConv, defS1_0, defS1_1, defS2_0, defS2_1 /;
if(%solveSOS1%, solve sos1conv max z using miqcp;);