Is there a way to get GAMS to interpret/extract values from the set text? eg extract the numerical values 1 and 2 from: set x /1, 2/;

We have a set that represents years:

set year / 2001 * 2030/

What I would like to get is a parameter from this, eg YEAR_VALUE(‘2001’) would = 2001, YEAR_VALUE(‘2002’) would = 2002, and so on.

Currently I am using a pre-processing .gms file that reads the set and then using put statements writes out a text file that sets this parameter up. Something roughly like:

loop (year) do
put “YEAR_VALUE('”, year.tl, "') = ", year.tl /;
endloop;

But is an easier way to do this, and in particular a way to do it without needing to run a separate pre-processing .gms?

Thanks
A


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

Hi A



You could use:



YEAR_VALUE(year) = ord(year) + 2000;



Cheers



Renger



Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von AC
Gesendet: Donnerstag, 21. März 2013 23:37
An: gamsworld@googlegroups.com
Betreff: Is there a way to get GAMS to interpret/extract values from the set text? eg extract the numerical values 1 and 2 from: set x /1, 2/;



We have a set that represents years:

set year / 2001 * 2030/

What I would like to get is a parameter from this, eg YEAR_VALUE(‘2001’) would = 2001, YEAR_VALUE(‘2002’) would = 2002, and so on.

Currently I am using a pre-processing .gms file that reads the set and then using put statements writes out a text file that sets this parameter up. Something roughly like:

loop (year) do
put “YEAR_VALUE('”, year.tl, "') = ", year.tl /;
endloop;

But is an easier way to do this, and in particular a way to do it without needing to run a separate pre-processing .gms?

Thanks
A


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\