GAMS partial sums

Hi

How can I compute the sum on only part of a set

for example k= [1;10] sum(k, F(k)) but for k>2 …

is it done by defining a different set or is there a gams notation for it?

thank you


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.

Dear RL,

You need to learn how to use the ord() function and also the $ condition.

http://www.gams.com/mccarl/mccarlhtml/ord.htm
http://www.gams.com/mccarl/mccarlhtml/$_conditionals.htm

In your case:

sum(k$(ord(k) > 2), F(k))


Cheers,
Pedro


On Wed, Jul 22, 2015 at 9:42 PM, RL wrote:

Hi

How can I compute the sum on only part of a set

for example k= [1;10] sum(k, F(k)) but for k>2 …

is it done by defining a different set or is there a gams notation for it?

thank you


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.



\

PEDRO JAVIER RAMÍREZ TORREALBA
Ingeniero Civil Eléctrico PUC
MSc en Ingeniería Eléctrica PUC
Londres, REINO UNIDO

Celular: +44-(0)75-8069-3119


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.

Reply-to: gamsworld@googlegroups.com

Thank you

On Thursday, 23 July 2015 13:20:08 UTC+1, PowerChile wrote:

Dear RL,

You need to learn how to use the ord() function and also the $ condition.

http://www.gams.com/mccarl/mccarlhtml/ord.htm
http://www.gams.com/mccarl/mccarlhtml/$_conditionals.htm

In your case:

sum(k$(ord(k) > 2), F(k))


Cheers,
Pedro


On Wed, Jul 22, 2015 at 9:42 PM, RL wrote:

Hi

How can I compute the sum on only part of a set

for example k= [1;10] sum(k, F(k)) but for k>2 …

is it done by defining a different set or is there a gams notation for it?

thank you


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



\

PEDRO JAVIER RAMÍREZ TORREALBA
Ingeniero Civil Eléctrico PUC
MSc en Ingeniería Eléctrica PUC
Londres, REINO UNIDO

Celular: +44-(0)75-8069-3119


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, other option is directly testing this whenever needed (eq declaration, sums, prod) mostly by () (read the manual for their use) . Both ways are (afaik) equivalent. Which strategy results in less code depends on what type of conditionals are part of your formulation. Subsets are great for conditionals that repeat a lot, and individual () conditionals are great for a set you test in many different ways.

Good luck!
Best,
Claudio
El 24/07/2015 03:37, “Frank Ward” escribió:

Dear GAMS user,



You could define a subset of k for all elements of k, larger than (ord greater than) 2, summing over that subset.



That’s likely the easiest.



Frank Ward



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of RL
Sent: Wednesday, July 22, 2015 2:43 PM
To: gamsworld
Subject: GAMS partial sums



Hi



How can I compute the sum on only part of a set



for example k= [1;10] sum(k, F(k)) but for k>2 …



is it done by defining a different set or is there a gams notation for it?



thank you


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.