i tried to save i th term of a parameter in a scalar but gams says Uncontrolled set entered as constant. can anybody help me?
here is my code
sets i /1*3/
j/1*3/;
scalar counter /1/
a /0/
b /0/;
parameters
dinf(i) /1*3 0/ ;
a= dinf(i)$(ord(i) = counter);
display a
problem in using ord
Re: problem in using ord
Sajjad,
In the example below are a couple ways to do what you ask.
In the example below are a couple ways to do what you ask.
Code: Select all
set i / 1*3 /;
singleton set s(i);
scalar
counter / 1 /
a / NA /
b / NA /
;
parameter dinf(i);
dinf(i) = ord(i);
a = sum{i$[ord(i) = counter], dinf(i)};
* singleton sets can have at most one member, so
* we can do things with them we cannot do with multi-element sets.
s(i)$[ord(i) = counter] = yes;
b = dinf(s);
display a, b;