how to control the index of a set nested in a loop

Hello to everyone

I need to perform a parameter scan. I want to scan 3 parameter in a combinatorial manner. In order to do that I created 3 vector sets with alternative parameter values
and putted the solve statement in a 3 nested loops, something like:
loop i)
loop j)
loopz)
parameter1=par1(i);
parameter2=par2(j);
parameter3=-par3(z);

SOLVE …USING NLP MAXIMIZING …;
I created a 2-dimensional set to collect results. I would like to store result in column vectors with the number of columns being equal to ijz (1 column per loop cycle)
the problem is that if I was not able to control the column index of the 2-dimensional table result. I tryied to define a cycle counter in the most nested loop
and to put the second index of table result under the control of such counter but GAMS doesn’t accept parameters as set index.

Is there a rapid way to put a set index under the control of a parameter (loop counter in my case)?

Thank you in advance for your suggestions
Sandro


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/-Gor0FAJ40MJ.
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.

Hi Sandro
Try to create a set, e.g. SET R, with a number of elements at least card(i)*card(j)*card(z).
Then, after the solve statement in your nested loop, assign the results to:

results(… whatever …, r) $(ord(r) eq (((ord(i)-1)*card(j) + (ord(j)-1))*card(z) + ord(z))) = … whatever.L … (i,j,z) ;


Alternatively, even simpler, just use a scalar that you increment in your nested loop :

scalar count / 0 / ;
loop(i,
loop(j,
loop(z,
count = count + 1 ;

SOLVE …
results(… whatever …, r) $(ord(r) eq count) = … whatever.L … (i,j,z) ;

);
);
);


hope this helps
cheers
dax


Le dimanche 9 septembre 2012 12:45:36 UTC+2, sandro a écrit :

Hello to everyone

I need to perform a parameter scan. I want to scan 3 parameter in a combinatorial manner. In order to do that I created 3 vector sets with alternative parameter values
and putted the solve statement in a 3 nested loops, something like:
loop i)
loop j)
loopz)
parameter1=par1(i);
parameter2=par2(j);
parameter3=-par3(z);

SOLVE …USING NLP MAXIMIZING …;
I created a 2-dimensional set to collect results. I would like to store result in column vectors with the number of columns being equal to ijz (1 column per loop cycle)
the problem is that if I was not able to control the column index of the 2-dimensional table result. I tryied to define a cycle counter in the most nested loop
and to put the second index of table result under the control of such counter but GAMS doesn’t accept parameters as set index.

Is there a rapid way to put a set index under the control of a parameter (loop counter in my case)?

Thank you in advance for your suggestions
Sandro


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/hJ7_M5CrlG4J.
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.

Il giorno martedì 11 settembre 2012 09:59:41 UTC+2, Dax ha scritto:

Hi Sandro
Try to create a set, e.g. SET R, with a number of elements at least card(i)*card(j)*card(z).
Then, after the solve statement in your nested loop, assign the results to:

results(… whatever …, r) $(ord(r) eq (((ord(i)-1)*card(j) + (ord(j)-1))*card(z) + ord(z))) = … whatever.L … (i,j,z) ;


Alternatively, even simpler, just use a scalar that you increment in your nested loop :

scalar count / 0 / ;
loop(i,
loop(j,
loop(z,
count = count + 1 ;

SOLVE …
results(… whatever …, r) $(ord(r) eq count) = … whatever.L … (i,j,z) ;

);
);
);


hope this helps
cheers
dax


Hi Dax

Thank you for the reply
Yes at the end I used the scalar counter method, and I accessed to the horizontal set index through it.

Thank you for your suggestions, I wil try also the first option you mentioned. Thank you again for you help

Sandro


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/VvFUUVrQfw4J.
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.