4
$\begingroup$

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$

$\endgroup$
6
$\begingroup$

$a \geq M_1x$

$a \leq M_2 - (M_2+eps)x$

$b = K_1 + (K_2-K_1)x$

  • $M_1 < 0$ bigM for the lower bound on $a$
  • $M_2 > 0$ bigM for the upper bound on $a$
  • $x$ binary variable equal to $1$ if $a < 0$, $0$ otherwise (i.e. $a \geq 0$)
  • $eps$ tolerance
$\endgroup$
4
$\begingroup$

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;

*/
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.