RE: subsets in equations

101 views
Skip to first unread message

Renger van Nieuwkoop

unread,
May 14, 2013, 6:16:36 AM5/14/13
to gams...@googlegroups.com

Hi Ines

This has nothing to do with subsets. You defined the equation youttotal over the set g and then in the equation itself you sum over g.  The set g is under control for the equations (you will have equations for all elements of g), so Gams starts writing down the equation for the first element. By summing over g in the equation itself you are using g again, but in another way. Now you want to sum over all the elements (I assume), but Gams is working with g equal to the first element for the equation itself and now it should use in the sum suddenly all elements of g.

If you would like to sum over all the elements of g, you should use an alias for g (for example ag):

 

Alias(g,ag);

youttotal(g).. youtt(g) =e= sum(ag, yout(ag))+1 ;

 

although, I can’t imagine that this makes sense, as youtt(g) will have the same value for all g…

 

Cheers

Renger

 

 

From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Ines Vilarinho
Sent: Dienstag, 14. Mai 2013 12:06
To: gams...@googlegroups.com
Subject: subsets in equations

 


Hi All,

I am having problems in defining the subsets in the equations because I never did this.
I wrote:

sets

j components /elem1, elem2, elem3/
g(j) gas components /elem1, elem2/

Positive Variables
yout(g) outlet molar mass in the gas phase
youtt(g) total molar fraction of gas phase

Equations
youttotal(g) total mol fraction of gas phase


youttotal(g).. youtt(g) =e= sum(g, yout(g))+1 ;

The error that appear is: error 125 - The set is under control already.

Can you advice me in what should I do?

Thanks a lot for your help! :)

Regards from Portugal,
Inês

--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to
gams...@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.
 
 

Renger van Nieuwkoop

unread,
May 14, 2013, 6:48:29 AM5/14/13
to <gamsworld@googlegroups.com>
You are right, just use alias
r

Sent from my iPhone

Am 14.05.2013 um 12:43 schrieb "Ines Vilarinho" <inessvi...@gmail.com>:

Hi Renger,

Thank you very much for your reply.

Actually my yout(g) is a number but as it is defined by sum of all yout(g) I thought I had to put the subset but if not great :).

If I understand correctly the alias will say that I only want to use the elements and not g right? And do I need to define ag?

If not, maybe the best way to write is:

Alias(g,ag);

youttotal.. youtt =e= sum(ag, yout(ag))+1 ;

what do you think?

Thanks again.
Inês

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

Reply all
Reply to author
Forward
0 new messages