gams:formulate_logical_expressions_in_equations

GAMS does not reformulate logical expressions. You need to do this by hand. If you need help coming up with the right model you should try to read HP Williams Book on Modeling (http://www.amazon.com/Model-Building-Mathematical-Programming-4th/dp/0471997889). It explains how to use the `bigM`

method to linearize logical constraints.

For example, if you have a logical expression `i=1 ⇔ a > b`

then you can reformulate this as

`a <= b + bigM * i`

`a > b - bigM * (1-i)`

Try to evaluate: If `i=1`

then the first constraint will not be effective if `bigM`

is big enough while the second equation will read `a>b`

. If `i=0`

, the first constraint ensures `a<=b`

while the second will
never be active if `bigM`

is big enough. The second constraint has some issues since we can't have strict “greater than” constraints in a mathematical programs. So you either don't care what happens to i at
the point `a=b`

or you rewrite the constraint as `a > b + 1e-6 - bigM*(1-i)`

or some other small number. `bigM`

can be usually calculated from the data of the problem, don't make it just “big”, since the solvers won't
like this.

This way you can define two indicators

`i=1 ⇔ a>b`

`j=1 ⇔ c>d`

Now you can have a third indicator that has to be defined as

`k=1 ⇔ i=1 and j=1`

using similar constraints. You find these explicitly in the book.

gams/formulate_logical_expressions_in_equations.txt · Last modified: 2013/08/05 08:00 by support