How to convert this if-then constraint to MIP constraint?
$\text{if } a \geq 0 \text{ then } b=K_1 \text{ else(a <0 ) } \ b =K_2$
Operations Research Stack Exchange is a question and answer site for operations research and analytics professionals, educators, and students. It only takes a minute to sign up.
Sign up to join this community$a \geq M_1x$
$a \leq M_2 - (M_2+eps)x$
$b = K_1 + (K_2-K_1)x$
I would like to remind that CPLEX can handle "if then" directly through logical constraints.
In OPL for example:
int nbKids=300;
float costBus40=500;
float costBus30=400;
dvar int+ nbBus40;
dvar int+ nbBus30;
minimize
costBus40*nbBus40 +nbBus30*costBus30;
subject to
{
40*nbBus40+nbBus30*30>=nbKids;
// with if nb buses 40 more than 3 then nb buses30 more than 7
(nbBus40>=3)=>(nbBus30>=7);
//(nbBus40>=3)<=(nbBus30>=7); //equivalent
}
/*
which gives
nbBus40 = 0;
nbBus30 = 10;
*/