GAMS modeling of an conditional equation Topic is solved

Problems with modeling
Post Reply
saghafiiii
User
User
Posts: 6
Joined: 3 months ago

GAMS modeling of an conditional equation

Post by saghafiiii » 3 months ago

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.

User avatar
dirkse
Moderator
Moderator
Posts: 56
Joined: 2 years ago
Location: Fairfax, VA

Re: GAMS modeling of an conditional equation

Post by dirkse » 3 months 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

saghafiiii
User
User
Posts: 6
Joined: 3 months ago

Re: GAMS modeling of an conditional equation

Post by saghafiiii » 2 months ago

Thanks a million.
dirkse wrote:
3 months 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

Post Reply