Accessing array

Hi,
I am quite new to GAMS and I encountered one problem I cannot solve by
myself. Could you help please? I create parameter, I imagine it as an
array and I need to access the 4th position in it. It is possible to
do it by myParameter(‘4’) but I need to call it my a variable. How
should I do it? I enclose the simple code.

set i /1*5/;
parameter myParameter(i) /1 2, 2 8, 3 1, 4 9, 5 123/;
scalar k /4/;
scalar value;

value = myParameter(‘4’);
value = myParameter(k);
*first one is possible, second one isnt.

Thanks for any help.

Lukas Adam

\

Hi Lukas
You can use the ord function
E.g.

loop(i$(ord(i) eq k),
value = myParameter(i)$(ord(i) eq k)
);

Renger


On Thu, Oct 21, 2010 at 10:27 PM, Lukas Adam wrote:

Hi,
I am quite new to GAMS and I encountered one problem I cannot solve by
myself. Could you help please? I create parameter, I imagine it as an
array and I need to access the 4th position in it. It is possible to
do it by myParameter(‘4’) but I need to call it my a variable. How
should I do it? I enclose the simple code.

set i /1*5/;
parameter myParameter(i) /1 2, 2 8, 3 1, 4 9, 5 123/;
scalar k /4/;
scalar value;

value = myParameter(‘4’);
value = myParameter(k);
*first one is possible, second one isnt.

Thanks for any help.

Lukas Adam


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Renger van Nieuwkoop


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.