Given a if-else statement:
If a > 0 and b > 0:
c = 1
else:
c = 0
Where a and b are input variable with fix values.
For example, I have 20 samples and each sample has a and b values. Those 20 samples will be inputted to my model. The c will decide whether to execute the action in my objective function. The action is a equation in my objective function.
I was wondering can I write the equation from the above if-else statement into the following statement for linear programming to represent if-else statement?
Set c is a binary variable (0, 1), and the constraint equation will be:
a·b·(c-0.5) > 0
Observing from the above equation, if a > 0 and b > 0, the binary variable c will be 1 because satisfying the equation a·b·(c-0.5) > 0. Otherwise, if c = 0 under a > 0 and b > 0, the equation cannot be satisfied.
I was wondering am I correct? If I want to run Lingo software and other linear programming software... Thanks.