Especify a variable value

Problems with syntax of GAMS
Post Reply
User avatar
zadel88
User
User
Posts: 2
Joined: 6 years ago

Especify a variable value

Post by zadel88 »

I have ths sets of restrictions:

R3(t,w) $(ord(t) gt 0 $(ord(t) lt 33 $(ord(w) eq 1))).. sum(j,x(j,t)) =L= sum(o,(y(o,w)));
R4(t,w) $(ord(t) gt 33 $(ord(t) lt 57 $(ord(w) eq 2))).. sum(j,x(j,t)) =L= sum(o,(y(o,w)));
R5(t,w) $(ord(t) gt 9 $(ord(t) lt 41 $(ord(w) eq 3))).. sum(j,x(j,t)) =L= sum(o,(y(o,w)));
R6(t,w) $(ord(t) gt 49 $(ord(t) lt 92 $(ord(w) eq 4))).. sum(j,x(j,t)) =L= sum(o,(y(o,w)));

What i'm trying to do is, in for each of them the variable w to take the especifies value (1,2,3,4) however, when I run it, each restriction is considering ALL the values of w. I have tried different ways of writting it with =, after and before the equation, "and" and either solves the problem.

Any suggestion on how to write this is most welcome. Thanks in advance.
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: Especify a variable value

Post by cladelpino »

Hi, perhaps this correct example will help you:

Code: Select all

set t /t0*t100/;
set w /w1*w4/;
set j /j1*j10/;
set o /o1*o10/;
variables x,y,z;
equations r3,r4,r5,r6;
equation fobj;

fobj.. z=e=x('j1','t2');
R3(t,w)$(ord(t) gt 0 and ord(t) lt 33 and ord(w) eq 1).. sum(j,x(j,t)) =L= sum(o,(y(o,w)));
R4(t,w)$(ord(t) gt 33 and ord(t) lt 57 and ord(w) eq 2).. sum(j,x(j,t)) =L= sum(o,(y(o,w)));
R5(t,w)$(ord(t) gt 9 and ord(t) lt 41 and ord(w) eq 3).. sum(j,x(j,t)) =L= sum(o,(y(o,w)));
R6(t,w)$(ord(t) gt 49 and  ord(t) lt 92 and ord(w) eq 4).. sum(j,x(j,t)) =L= sum(o,(y(o,w)));

model aTest /all/;

solve aTest using lp maximizing z
Good luck!!
Claudio
Post Reply