issue with assigning values to a parameter

Hi, I am a new user of GAMS. Now I have an issue with assigning values
to a parameter Pr in a loop code as follows:


set scen /16/;
t /t1
t3/;
s /s1*s2/;

parameter Pr(scen);
Scaler Numb /0/;

loop(t,
loop(s,
Numb=Numb+1;
Pr(‘Numb’)=0.3*Numb;
);
);

The error code is 170 Domain violation for element for " Pr(‘Numb’)
=0.3*Numb". But I don’t know how I can correct it.

In addition, is there any way that I don’t have to determine the
number of members in set Scen which is determined by the loop over t
and s?

Any help is highly appreciated!

Hailey





\

This kind of strenghtens my conviction that set elements should never
be labelled as pure integers.
Set elements are only character strings. So a set element called “1”
will solely be interpreted as a character, but never with the value
1.

One easy way – but there are definitely more elegant means – to
solve your problem is the following


set scen /scen1scen6/
t /t1
t3/
s /s1*s2/;

parameter Pr(scen);
Scalar Numb /0/;

loop(t,
loop(s,
Numb=Numb+1;
Pr(scen) $(ord(scen) eq Numb) = 0.3*Numb ;
);
);

cheers
dax


On Jan 17, 11:57 pm, Hailey wrote:

Hi, I am a new user of GAMS. Now I have an issue with assigning values
to a parameter Pr in a loop code as follows:


set scen /16/;
t /t1
t3/;
s /s1*s2/;

parameter Pr(scen);
Scaler Numb /0/;

loop(t,
loop(s,
Numb=Numb+1;
Pr(‘Numb’)=0.3*Numb;
);
);

The error code is 170 Domain violation for element for " Pr(‘Numb’)
=0.3*Numb". But I don’t know how I can correct it.

In addition, is there any way that I don’t have to determine the
number of members in set Scen which is determined by the loop over t
and s?

Any help is highly appreciated!

Hailey

\