simple fraction operation, with one step less?

Dear colleagues, since the operation below is the same in a different order, but it does not work, two questions come to my mind: why it does not work? how can be made without intermediate steps? Thanks and happy Sunday

*I want to create a new parameter with the share of each area type in my regions,

sets region/world,myregion/,area/urban,forest,riverside/;
parameter
myparameter(region,area)
share_of_each_area(region,area);
myparameter(region,area)=normal(7,2);
display myparameter;

*an option to obtain the desired share is to create another parameter with the total and divide by it
parameter total_area(region);
total_area(region)= sum(area,myparameter(region,area));
display total_area;

share_of_each_area(region,area)=myparameter(region,area)/total_area(region);
display share_of_each_area;

*I would like to do it without the intermediate step of creating a parameter for the total amount, but I get an error in the following code, which is the same in another order
share_of_each_area(region,area)=myparameter(region,area)/sum(area,myparameter(region,area));
display share_of_each_area;


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.
For more options, visit https://groups.google.com/d/optout.

Hi Roger

You have to define an alias for area (e.g. alias(area, aarea)) and then use the alias for summing (e.g. sum(aarea,myparameter(region,aarea)):wink:

If you use area instead of aarea in the sum, Gams gets confused, because the assignment is defined over the set area and then it should sum over the set at the same time. Note, that while summing over aarea, you should also use aarea in myparameter, otherwise the same value of myparameter is summed aarea times (it is always good to sum shares and check if they are 1).



Cheers

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Roger Cremades Rodeja
Sent: Sonntag, 3. Mai 2015 10:32
To: gamsworld@googlegroups.com
Subject: simple fraction operation, with one step less?



Dear colleagues, since the operation below is the same in a different order, but it does not work, two questions come to my mind: why it does not work? how can be made without intermediate steps? Thanks and happy Sunday



*I want to create a new parameter with the share of each area type in my regions,



sets region/world,myregion/,area/urban,forest,riverside/;

parameter

myparameter(region,area)

share_of_each_area(region,area);

myparameter(region,area)=normal(7,2);

display myparameter;



*an option to obtain the desired share is to create another parameter with the total and divide by it

parameter total_area(region);

total_area(region)= sum(area,myparameter(region,area));

display total_area;



share_of_each_area(region,area)=myparameter(region,area)/total_area(region);

display share_of_each_area;



*I would like to do it without the intermediate step of creating a parameter for the total amount, but I get an error in the following code, which is the same in another order

share_of_each_area(region,area)=myparameter(region,area)/sum(area,myparameter(region,area));

display share_of_each_area;


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.
For more options, visit https://groups.google.com/d/optout.


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.
For more options, visit https://groups.google.com/d/optout.

Renger, I very much appreciate your help, thanks a lot and have a nice day! Roger

2015-05-04 8:41 GMT+02:00 Renger van Nieuwkoop :

Hi Roger

You have to define an alias for area (e.g. alias(area, aarea)) and then use the alias for summing (e.g. sum(aarea,myparameter(region,aarea)):wink:

If you use area instead of aarea in the sum, Gams gets confused, because the assignment is defined over the set area and then it should sum over the set at the same time. Note, that while summing over aarea, you should also use aarea in myparameter, otherwise the same value of myparameter is summed aarea times (it is always good to sum shares and check if they are 1).



Cheers

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Roger Cremades Rodeja
Sent: Sonntag, 3. Mai 2015 10:32
To: gamsworld@googlegroups.com
Subject: simple fraction operation, with one step less?



Dear colleagues, since the operation below is the same in a different order, but it does not work, two questions come to my mind: why it does not work? how can be made without intermediate steps? Thanks and happy Sunday



*I want to create a new parameter with the share of each area type in my regions,



sets region/world,myregion/,area/urban,forest,riverside/;

parameter

myparameter(region,area)

share_of_each_area(region,area);

myparameter(region,area)=normal(7,2);

display myparameter;



*an option to obtain the desired share is to create another parameter with the total and divide by it

parameter total_area(region);

total_area(region)= sum(area,myparameter(region,area));

display total_area;



share_of_each_area(region,area)=myparameter(region,area)/total_area(region);

display share_of_each_area;



*I would like to do it without the intermediate step of creating a parameter for the total amount, but I get an error in the following code, which is the same in another order

share_of_each_area(region,area)=myparameter(region,area)/sum(area,myparameter(region,area));

display share_of_each_area;


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.
For more options, visit https://groups.google.com/d/optout.


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.
For more options, visit https://groups.google.com/d/optout.

\

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.
For more options, visit https://groups.google.com/d/optout.