Logical Syntax

Problems with syntax of GAMS
Post Reply
PauloRodriguez
User
User
Posts: 3
Joined: 1 week ago

Logical Syntax

Post by PauloRodriguez » 1 week ago

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: 129
Joined: 4 years ago
Location: Fairfax, VA

Re: Logical Syntax

Post by dirkse » 1 week 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

PauloRodriguez
User
User
Posts: 3
Joined: 1 week ago

Re: Logical Syntax

Post by PauloRodriguez » 1 week ago

dirkse wrote:
1 week 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