I am relatively new to integer programming and (again) got stuck with the formulation of a constraint.
In my simplified model I have a (continous) variable with a lower bound LB below zero and an upper bound UB above zero. Now I want to assign the variable value to other variables depending on the value that the variable has taken.
The logic I want to express is the following:
LB > 0
UB > 0
-LB <= Variable1 <= UB
if Variable1 => 0:
Variable2 = Variable1
Variable3 = 0
else:
Variable2 = 0
Variable3 = abs(Variable1)
How can I describe this using linear (in)equalities?
I guess am a bit slow on the uptake..
Thanks in advance!
** Edit: For the modeling I am using Python, Pyomo and the newest Gurobi solver.
*** Edit: I have now formulated it the following way by the use of a binary variable. (I know it is quadratic but this can be linearized later):
LB > 0
UB > 0
-LB <= Variable1 <= UB
0 <= Variable2 <= UB
0 <= Variable3 <= LB
Variable4 = Variable2 * BinaryVariable - Variable3 * (1-BinaryVariable)
But now I still have to make sure that Variable3 is 0 if Variable2 is > 0 and vice versa.
Any ideas?