changing the amount of sets in parameter

Problems with modeling
Post Reply
Alex_Lee
User
User
Posts: 3
Joined: 1 month ago

changing the amount of sets in parameter

Post by Alex_Lee » 1 month ago

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!

User avatar
Renger
Posts: 398
Joined: 3 years ago

Re: changing the amount of sets in parameter

Post by Renger » 1 month ago

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
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

Alex_Lee
User
User
Posts: 3
Joined: 1 month ago

Re: changing the amount of sets in parameter

Post by Alex_Lee » 1 month ago

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

User avatar
Renger
Posts: 398
Joined: 3 years ago

Re: changing the amount of sets in parameter

Post by Renger » 1 month ago

Hi
Please, show me your code that producers the error.
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

Post Reply