how to use lag operation including a variable

91 views
Skip to first unread message

YouYaxiong

unread,
May 23, 2012, 1:05:26 PM5/23/12
to gamsworld
hello,everyone
i have a problem about using lag operation including a variable,the
piece of the model as follow:

set j;
parameter e_t(j);
.....
integer variable s(i,j);
.....
equation ff(i,j) the cost per appliance;
......
ff(i,j).. f(i,j) =e= e_t(j+s(i,j)) *p_n(i)*x(i,j)*p1(i,j)
.........

the lag operation used at e_t(j+s(i,j))
when i run the program,there will be a error 62:endogenous lag
operations are illegal.
could anyone tell me how to solve this problem,thanks a lot.


Your sincerely
You Yaxiong

任彦

unread,
May 23, 2012, 10:00:01 PM5/23/12
to gamsworld
> ff(i,j).. f(i,j) =e= e_t(j+s(i,j)) *p_n(i)*x(i,j)*p1(i,j)

> the lag operation used at e_t(j+s(i,j))
> when i run the program,there will be a error 62:endogenous lag
> operations are illegal.

'j+s(i,j)' is illegal and cannot be used as a index.
s(i,j) is a value, while j is an index here ( in fact it is a string).
in e_t(j+s(i,j)) you are using '+' operation for index and values,
this is not illegal in GAMS.

for example:

Set j /1,2,three/;
Parameter S(j)
/
1 11,
2 22,
three 33
/;

then S('1') have value 11 and S('three') have value 33

the order of a index, which is an positive integer, can be obtained using function ord().
for example:

ff(i,j).. f(i,j) =e= e_t(i,j) + ord(j);

HTH,

Yan

Mohamed Hamdy

unread,
Aug 14, 2014, 6:18:43 PM8/14/14
to gams...@googlegroups.com
could you please tell me exactly what is the solution of the above issue if i need to refer to index plus variable
Reply all
Reply to author
Forward
0 new messages