Page 1 of 1
GAMS modeling of an conditional equation
Posted: Wed Mar 20, 2019 2:18 pm
by saghafiiii
Hi everyone.
I want to model the equation below in GAMS:
Code: Select all
equation1..
if( x(i) > x(j),
y(i) > y(j);
);
it means
if x(i) > x(j), then y(i) should be greater than y(j).
here y(i) is a variable and x(i) is a parameter.
I would be appreciated if someone can help how to model it in GAMS.
Re: GAMS modeling of an conditional equation
Posted: Thu Mar 21, 2019 8:15 pm
by dirkse
Hi,
You have two strict inequalities there: one comparing parameters, the other comparing variables. The parameters can be compared this way, but not the variables. So you could do something like:
Code: Select all
set i / blah /;
alias (i,j);
parameter a(i);
variables x(i);
equation f(i,j);
f(i,j)$[a(i) > a(j)] .. x(i) =g= x(j);
Mathematically, we don't do optimization over open sets (i.e. those defined with strict inequalities): how can you solve
max x
s.t. x < 3
And numerically, we do all this in finite-precision arithmetic so there is almost always some round-off error. Constraints are not satisfied exactly but to within some tolerance, so a strict vs. non-strict inequality is easily lost in the noise of round-off error.
-Steve
Re: GAMS modeling of an conditional equation
Posted: Wed Mar 27, 2019 11:26 am
by saghafiiii
Thanks a million.
dirkse wrote: ↑5 years ago
Hi,
You have two strict inequalities there: one comparing parameters, the other comparing variables. The parameters can be compared this way, but not the variables. So you could do something like:
Code: Select all
set i / blah /;
alias (i,j);
parameter a(i);
variables x(i);
equation f(i,j);
f(i,j)$[a(i) > a(j)] .. x(i) =g= x(j);
Mathematically, we don't do optimization over open sets (i.e. those defined with strict inequalities): how can you solve
max x
s.t. x < 3
And numerically, we do all this in finite-precision arithmetic so there is almost always some round-off error. Constraints are not satisfied exactly but to within some tolerance, so a strict vs. non-strict inequality is easily lost in the noise of round-off error.
-Steve