I would really like to seek for your kind help regarding an if-then constraint. I found in the community a similar topic but my condition is a bit different from that, therefore I want to show my case and ask for your tips again.
Specifically, I have the following variables:
A: decision variable
And I want to achieve the following:
1)if A-B>=0, then Q=A-B
2)if A-B<0, then Q=0
I would like to ask if it is possible to consrtuct a linear formulation for this if-then logic to be realised.
Many thanks in advance!
Best answer by Marcel Hunting
L <= A-B <= U
Now introduce a new binary variable b.
Then you can use this MIP formulation:
Q >= A-B
Q <= A-B + (U-L) * b
Q >= 0
Q <= 0 + (U-L) * (1-b)
If A>B then b will be 0, and Q will be A-B. If A<B then b will be 1, and Q will be 0. If A=B then b can be 0 or 1, and Q will be 0.