Page 1 of 1

changing the amount of sets in parameter

Posted: Sun Sep 15, 2019 1:32 pm
by Alex_Lee
Hi,

This may sound like a very simple question, maybe it has been asked before.

I want to know how you can remove superfluous sets in a parameter without changing any of the data in the parameter.

Firstly the sets and the parameter are defined as:

Code: Select all

sets
AreaCode,centralamerica,ItemCode,crops,ElementCode,dollars,YearCode,Year,Unit

parameter
Prices_data(AreaCode,centralamerica,ItemCode,crops,ElementCode,dollars,YearCode,Year,Unit)
Some elements of the parameter, when displayed on a listing file, would look like this:

Code: Select all

166.Panama    .56 .Maize     .5532.Producer Price (USD/tonne).1999.1999.USD 281
48 .Costa Rica.56 .Maize     .5532.Producer Price (USD/tonne).1999.1999.USD 217
I want the parameter to look like this:

Code: Select all

parameter
Prices_data(centralamerica,crops,Year)
reducing the amount of sets, so that when displayed in a listing file it would be like this:

Code: Select all

Panama.Maize.1999 281
Costa Rica.Maize.1999 217
Also I'd like to rename the set names, again, without changing the data, so that "centralamerica" has the name "region" and "year" has the name "period", so that the parameter would look like this:

Code: Select all

parameter
Prices_data(region,crops,time)
...is it also possible to change the order the sets with the parameter so it looks like this:

Code: Select all

Prices_data(time,region,crops)

Thanks!

Re: changing the amount of sets in parameter

Posted: Sun Sep 15, 2019 3:16 pm
by Renger
Hi
Yes, this is possible. The most secure way is just summing all the values so all the items are taken from the original tabel

Code: Select all

Prices_data(centralamerica,crops,Year) = sum((AreaCode, ItemDoce, ElementCode, dollars, YearCode), Prices_data(AreaCode,centralamerica,ItemCode,crops,ElementCode,dollars,YearCode,Year,Unit));
The order of the sets in the new parameter is free, so you could have (centralamerica, year, crops) or (crops, year, centralamerica). However, note that when you change the order this might be a little bit slower (as far as I can remember).

If you want to keep the original sets as they are, you can just define an alias:
alias(year,time), (centralamerica, region).

I hope this helps

Renger

Re: changing the amount of sets in parameter

Posted: Sun Sep 15, 2019 5:50 pm
by Alex_Lee
Hi there,

Thanks for the reply.

However, when I do this I get error messages:

Code: Select all

Error 171 Domain violation for set
Error 148 Dimension different - The symbol is referenced with more/less indices as declared
Error 149 Uncontrolled set entered as constant

Re: changing the amount of sets in parameter

Posted: Wed Sep 18, 2019 8:58 am
by Renger
Hi
Please, show me your code that producers the error.
Cheers
Renger