Equation based on set number

Problems with syntax of GAMS
Post Reply
sinagilassi
User
User
Posts: 8
Joined: 6 years ago

Equation based on set number

Post by sinagilassi »

Hi,

I defined a set and a parameter as

Code: Select all

Sets i /1, 2/;   

Positive Variable X_V_ce(i);
 
one of the constraints is

Code: Select all


Z1(i).. X_V_ce(i) =e= X_V_ce(i+1) + ....

How it can be defined, i cannot be set i+1 !!

What can I do to add 1 or 2 to an element?

Regards
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Equation based on set number

Post by Renger »

Hi
This is not a problem for Gams. For i = 2, it writes the equation as
Z1(i).. X_V_ce("2") =e= 0;
If you want another formulation for this case, you could use the cardinality of set i (the number of elements):
Z1(i).. X_V_ce(i) =e= X_V_ce(i+1)$(ord(i) ne card(i) + (.....)$(ord(i) eq card(i);
Hope this answers your question
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
sinagilassi
User
User
Posts: 8
Joined: 6 years ago

Re: Equation based on set number

Post by sinagilassi »

Hi Renger,

Thank you for your help
Renger wrote: 6 years ago Hi
This is not a problem for Gams. For i = 2, it writes the equation as
Z1(i).. X_V_ce("2") =e= 0;
If you want another formulation for this case, you could use the cardinality of set i (the number of elements):
Z1(i).. X_V_ce(i) =e= X_V_ce(i+1)$(ord(i) ne card(i) + (.....)$(ord(i) eq card(i);
Hope this answers your question
Cheers
Renger
Post Reply