Aggregated subset to store the results

Hello everyone,

I have an issue. I built a model with a set of regions (45 countries). But in my results I would like to aggregate some countries so that I can have both outputs by country and / or by region. Let’s take this example.


Set r countries /A, B, C, D, E, F, G, H, I, K, L, M/


Now I want to create the following set rg whose elements are in set r as follows :

Set r countries /A, B, C, D, E, F, G, H, I, K, L, M/

rg regions /R1, R2, R3/

With R1 (A, B, C) R2 (D, E, F, G) R3 (H, I, J, K, L, M).

I have tried this:

Set r countries /A, B, C, D, E, F, G, H, I, K, L, M/


rg2 regions /R1, R2, R3/

rg(rg2, r) aggregated regions 

/R1. (A, B, C) 
R2. (D, E, F, G) 
R3. (H, I, J, K, L, M)/

But this is a two dimensional set. Normally, I wanted something like rg(r) so that from a parameter like

Parameter 

Cost(r) ;

I can display the results for cost(r) or cost(rg) knowing that in rg, R1 would take the sum of A, B, C contents, R2 the sum for D, E, F, G and so on.

How, can I adress this issue?

Thanks in advance for your help.

There is no semantic information in rg and it just represents some entity relation between r and rh2 as in many relational databases. Why should it sum, and not do a product, or min, or max, or whatever. You need to program this:

Set r countries /A, B, C, D, E, F, G, H, I, J, K, L, M/
    rg2 regions /R1, R2, R3/
    rg(rg2, r) aggregated regions  /R1. (A, B, C), R2. (D, E, F, G) , R3. (H, I, J, K, L, M)/;

Parameter cost(r); cost(r) = uniform(0,1);
Parameter costrg2(rg2); costrg2(rg2) = sum(rg(rg2,r), cost(r));
display cost, costrg2;

-Michael

Dear Michael,

Thanks a lot for your reply. I have now overcome that issue following your suggestion. The summation seems convenient compared to max, min and so on for the simple reason that in my code the regional output is the sum of countries output belonging to that region.

Best regards,

Rodrigue