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.
Logical Syntax
Re: Logical Syntax
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
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
-
- User
- Posts: 4
- Joined: 3 years ago
Re: Logical Syntax
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.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