help about an equation

how can i write equation at the pic?
gams dosent allow this “d(i,s)… 2*x(i,s,2)+x(i,s+1,1)+ x(i,s+1,2) =l= 2;”


ScreenShot_20190519175130.png

Hi,

Looks as if you want to refer to a particular set element explicitly in the third index position of x. In that case, set elements (aka labels) must be quoted.
Helping you would become a lot easier if you share your code such that users can reproduce the exact issue. Just saying GAMS doesn’t allow some equation syntax may lack important context.

Fred

thanks a lot. i am just a beginner about GAMS. so i will be very thanksfull about any help
here is the my model
set
i hemsire numarası /120/
j gün numarası /1
30/
s /129/
k vardiya numarası /1
2/
w hafta sonu /1,2,8,9,15,16,22,23,29,30/
v hafta içi /3,4,5,6,7,10,11,12,13,14,17,18,19,20,21,24,25,26,27,28/
;

variables
x
z amaç fonk;

binary variables
x
;

equations
cost
a(j,k) her gündüz-gece vardiyasında en az 4 hemşire bulunsun
b(i,k) her hemşire ayda en az 4 hafta içi gündüz-gece vardiyasında çalışsın
c(i,k) her hemşire ayda en az 2 hafta sonu gündüz-gece vardiyasında çalışsın
d(i,s)
;

cost … z =e= sum((i,j,k), x(i, j, k)) ;
a(j,k) … sum((i), x(i,j,k)) =g= 4;
b(i,k)… sum((v), x(i,v,k)) =g= 4;
c(i,k)… sum((w), x(i,w,k)) =g= 2;
d(i,s)… 2*x(i,s,2)+x(i,s+1,1)+ x(i,s+1,2) =l= 2;

model ornek1/all/;

solve ornek1 using MIP minizing z;
display x.l, z.l;

Hi,

As indicated in my previous post and by the first error message

*** Error 145 in ...\new1.gms
    Set identifier or quoted element expected

set elements must be quoted. After changing equation d to

d(i,s).. 2*x(i,s,'2')+x(i,s+1,'1')+ x(i,s+1,'2') =l= 2;

the model solves.

I hope this helps!

Fred

thanks a lot it was what i need for solve it. have a good day :slight_smile:

i am so sorry but can i ask one more question
how can i assign x(1,3,2) to 1?
guess x(‘1’,‘3’,‘2’)=1; dosent match what i want

Hi,

A variable has several attributes: https://www.gams.com/latest/docs/UG_Variables.html#UG_Variables_VariableAttributes

You need to specify which one you would like to use, e.g.

x.l('1','3','2')=1;

to set the variable’s level to 1 or

x.fx('1','3','2')=1;

to fix the variable at 1 (upper and lower bound set to 1).

thanks a lot again and again