Logical Syntax

Problems with syntax of GAMS
Post Reply
PauloRodriguez
User
User
Posts: 4
Joined: 3 years ago

Logical Syntax

Post 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.
User avatar
dirkse
Moderator
Moderator
Posts: 214
Joined: 7 years ago
Location: Fairfax, VA

Re: Logical Syntax

Post 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
PauloRodriguez
User
User
Posts: 4
Joined: 3 years ago

Re: Logical Syntax

Post 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.
Post Reply