Page 1 of 1

Logical Syntax

Posted: Thu Oct 15, 2020 6:22 am
by PauloRodriguez
Guys, how can i put a constraint with logical operator like:

const1.. (binaryvariable1= 1 and x(i)-y(i)<0) or (binaryvariable1=0 and x(i)-y(i)>)

I mean, i wish this constraint makes at least one of the conditions being satisfied.

Re: Logical Syntax

Posted: Thu Oct 15, 2020 3:33 pm
by dirkse
Paulo,

We don't use strict inequalities in optimization. Google strict inequality math programming for a wealth of reasons why, perspectives, examples, etc.

You could use a Big-M method: given a binary variable y, use

x-y <= M * y
y-x <= M * (1-y)

if M is large enough, the constraint x-y<=0 is on when y = 0 and off otherwise.
y-x <= 0 is off when y = 0 and on otherwise

Just make M as small as possible.

https://en.wikipedia.org/wiki/Big_M_method

There are other ways to do this also: indicator constraints, disjunctive programming. There is lots written about it in the GAMS docs.

-Steve

Re: Logical Syntax

Posted: Thu Oct 15, 2020 6:05 pm
by PauloRodriguez
dirkse wrote: 3 years ago Paulo,

We don't use strict inequalities in optimization. Google strict inequality math programming for a wealth of reasons why, perspectives, examples, etc.

You could use a Big-M method: given a binary variable y, use

x-y <= M * y
y-x <= M * (1-y)

if M is large enough, the constraint x-y<=0 is on when y = 0 and off otherwise.
y-x <= 0 is off when y = 0 and on otherwise

Just make M as small as possible.

https://en.wikipedia.org/wiki/Big_M_method

There are other ways to do this also: indicator constraints, disjunctive programming. There is lots written about it in the GAMS docs.

-Steve
Thank you so much, its the first time using GAMS and working with this type of programming. I am doing my academic work and was at dead end.