However, the (D,0) part gives my an error (error 145 “Set identifier or quoted element expected” and 148 “Dimension different - The symbol is referenced with more/less indices as declared”)
My variables are defined as follows:
SMP(MP,T)
SD(D,T)
And my parameters are :
CSMP(MP)
/CHOCOLATE 0.1
FRUIT 0.35/
CSD(D)
/DESERT1 0.25
DESERT2 0.25/
How do I access and define the 0 position of a variable? Or GAMS doesn’t work that way ?
If anyone could give me some clues or help, I would appreciate it
Hi
You should treat set elements as strings, even if they are numbers. This means that SMP(D,0) is not understood by Gams and should be SMP(D,“0”).
If you need the value of a set element in a calculation, you can use .val (e.g. t.val) for the value of a numeric set element and ord(t) for numeric or string elements. (ord gives the position in the set).
If I use the ORD, how should I use it? I don’t think value is the right one to use because my set is not numeric, it is a set of string element.
Like this ? SMP(MP,ORD(0)) ?
If it helps, this is the constraint I am trying to implement
Hi
I assumed T was time like this T /0*10/. But now you sent the code, it is more clear: It should be
INITSTOCKD(D) .. SD(D,"PRINTEMPS") =E= SID(D);
GAMS gave you already a hint: “170 Domain violation for element”. It didn’t recognized “0” as a set element.
If you want to use ord in expression like that you could use