Sum top border

Hi everyone! I’m a newbie here and really can’t find a solution to this problem:

I have defined set t from 1 to 24

And I need to write sum of parameter e(t) from 1 to t!

This was my try: sum(t,e(t))$(ord(t)<t))

Any ideas?


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 Ivan,
write it like this: sum(t$(ord(t)<t)),e(t))
in SUM put the condition for the index after indexes and before the variable.

On Thursday, May 21, 2015 at 3:38:09 PM UTC+3, Ivan Martić wrote:

Hi everyone! I’m a newbie here and really can’t find a solution to this problem:

I have defined set t from 1 to 24

And I need to write sum of parameter e(t) from 1 to t!

This was my try: sum(t,e(t))$(ord(t)<t))

Any ideas?


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 Ivan



Here you go (take a good look at the technique used; I think you will understand it)



set t /1*24/;



parameter e(t);


\

  • Initialize e(t) with some dummy values

e(t) = uniform(0,10);



parameter sumet(t);



alias(t,tt);



sumet(t) = sum(tt$(ord(tt) < ord(t)), e(t));



display e;



Cheers



Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Ivan Martic
Sent: Donnerstag, 21. Mai 2015 14:43
To: gamsworld@googlegroups.com
Subject: Sum top border



Hi everyone, I’m new with gams and I can’t really find a solution to this problem anywhere…

I have defined set t from 1 to 24.

And I need to write a sum of e(t) from 1 to t!

My try: sum(t,e(t))$(ord(t)<t)) but it has 3 errors…

Any ideas?


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.

Hi Renger!

I need to write that sum twice in this objective function:

c… objective_fun=e=ktu*sum(t,kappa_tu(t))+(sum(t,e(t))+zeta)*lambda+(s0+(sum(tt$(ord(tt) < ord(t)), e(t)))*sum(t,ni_st(t))+(kst-s0-(sum(tt$(ord(tt) < ord(t)), e(t))))*sum(t,kappa_st(t));

and it keeps telling me that set for ord is not controlled and that uncontrolled set is entered as a constant…

On Thursday, May 21, 2015 at 3:02:23 PM UTC+2, Renger van Nieuwkoop wrote:

Hi Ivan



Here you go (take a good look at the technique used; I think you will understand it)



set t /1*24/;



parameter e(t);


\

  • Initialize e(t) with some dummy values

e(t) = uniform(0,10);



parameter sumet(t);



alias(t,tt);



sumet(t) = sum(tt$(ord(tt) < ord(t)), e(t));



display e;



Cheers



Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Ivan Martic
Sent: Donnerstag, 21. Mai 2015 14:43
To: gams...@googlegroups.com
Subject: Sum top border



Hi everyone, I’m new with gams and I can’t really find a solution to this problem anywhere…

I have defined set t from 1 to 24.

And I need to write a sum of e(t) from 1 to t!

My try: sum(t,e(t))$(ord(t)<t)) but it has 3 errors…

Any ideas?


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.


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 Ivan

This is because the part with the alias gives you for every t the sum up to t, like in my example sumet(t). Now you have to sum over t itself e.g. sum(t, sumet(t)) if you want to use the total sum in your expression.

Otherwise you will have something like: objective_fun =E= sumet(t); You can see here that on the left hand you have a scalar and on the right hand side a vector.

In your case it therefore hast o be sum(t, (sum(tt$(ord(tt) < ord(t)), e(t)))*sum(t,ni_st(t))).



Hope this helps

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Ivan Martic
Sent: Donnerstag, 21. Mai 2015 16:13
To: gamsworld@googlegroups.com
Subject: Re: Sum top border



Hi Renger!

I need to write that sum twice in this objective function:

c… objective_fun=e=ktu*sum(t,kappa_tu(t))+(sum(t,e(t))+zeta)*lambda+(s0+(sum(tt$(ord(tt) < ord(t)), e(t)))*sum(t,ni_st(t))+(kst-s0-(sum(tt$(ord(tt) < ord(t)), e(t))))*sum(t,kappa_st(t));

and it keeps telling me that set for ord is not controlled and that uncontrolled set is entered as a constant…

On Thursday, May 21, 2015 at 3:02:23 PM UTC+2, Renger van Nieuwkoop wrote:

Hi Ivan



Here you go (take a good look at the technique used; I think you will understand it)



set t /1*24/;



parameter e(t);


\

  • Initialize e(t) with some dummy values

e(t) = uniform(0,10);



parameter sumet(t);



alias(t,tt);



sumet(t) = sum(tt$(ord(tt) < ord(t)), e(t));



display e;



Cheers



Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Ivan Martic
Sent: Donnerstag, 21. Mai 2015 14:43
To: gams...@googlegroups.com
Subject: Sum top border



Hi everyone, I’m new with gams and I can’t really find a solution to this problem anywhere…

I have defined set t from 1 to 24.

And I need to write a sum of e(t) from 1 to t!

My try: sum(t,e(t))$(ord(t)<t)) but it has 3 errors…

Any ideas?


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.


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.

Hi everybody, it’s me again :slight_smile:

I have another sum related question… I need to write this problem in GAMS → p(t) = sum (s(T)-k(T)) from T=t to 24 and I don’t know how to write it… set t is from 1 to 24…

anyone?

On Thursday, May 21, 2015 at 4:29:37 PM UTC+2, Renger van Nieuwkoop wrote:

Hi Ivan

This is because the part with the alias gives you for every t the sum up to t, like in my example sumet(t). Now you have to sum over t itself e.g. sum(t, sumet(t)) if you want to use the total sum in your expression.

Otherwise you will have something like: objective_fun =E= sumet(t); You can see here that on the left hand you have a scalar and on the right hand side a vector.

In your case it therefore hast o be sum(t, (sum(tt$(ord(tt) < ord(t)), e(t)))*sum(t,ni_st(t))).



Hope this helps

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Ivan Martic
Sent: Donnerstag, 21. Mai 2015 16:13
To: gams...@googlegroups.com
Subject: Re: Sum top border



Hi Renger!

I need to write that sum twice in this objective function:

c… objective_fun=e=ktu*sum(t,kappa_tu(t))+(sum(t,e(t))+zeta)*lambda+(s0+(sum(tt$(ord(tt) < ord(t)), e(t)))*sum(t,ni_st(t))+(kst-s0-(sum(tt$(ord(tt) < ord(t)), e(t))))*sum(t,kappa_st(t));

and it keeps telling me that set for ord is not controlled and that uncontrolled set is entered as a constant…

On Thursday, May 21, 2015 at 3:02:23 PM UTC+2, Renger van Nieuwkoop wrote:

Hi Ivan



Here you go (take a good look at the technique used; I think you will understand it)



set t /1*24/;



parameter e(t);


\

  • Initialize e(t) with some dummy values

e(t) = uniform(0,10);



parameter sumet(t);



alias(t,tt);



sumet(t) = sum(tt$(ord(tt) < ord(t)), e(t));



display e;



Cheers



Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Ivan Martic
Sent: Donnerstag, 21. Mai 2015 14:43
To: gams...@googlegroups.com
Subject: Sum top border



Hi everyone, I’m new with gams and I can’t really find a solution to this problem anywhere…

I have defined set t from 1 to 24.

And I need to write a sum of e(t) from 1 to t!

My try: sum(t,e(t))$(ord(t)<t)) but it has 3 errors…

Any ideas?


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.


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.


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.

Same procedure:



p(t) = sum(tt$(ord(tt) ge t), s(tt) – k(tt));



Cheers

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Ivan Martic
Sent: Mittwoch, 10. Juni 2015 21:08
To: gamsworld@googlegroups.com
Subject: Re: Sum top border



Hi everybody, it’s me again :slight_smile:

I have another sum related question… I need to write this problem in GAMS → p(t) = sum (s(T)-k(T)) from T=t to 24 and I don’t know how to write it… set t is from 1 to 24…

anyone?

On Thursday, May 21, 2015 at 4:29:37 PM UTC+2, Renger van Nieuwkoop wrote:

Hi Ivan

This is because the part with the alias gives you for every t the sum up to t, like in my example sumet(t). Now you have to sum over t itself e.g. sum(t, sumet(t)) if you want to use the total sum in your expression.

Otherwise you will have something like: objective_fun =E= sumet(t); You can see here that on the left hand you have a scalar and on the right hand side a vector.

In your case it therefore hast o be sum(t, (sum(tt$(ord(tt) < ord(t)), e(t)))*sum(t,ni_st(t))).



Hope this helps

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Ivan Martic
Sent: Donnerstag, 21. Mai 2015 16:13
To: gams...@googlegroups.com
Subject: Re: Sum top border



Hi Renger!

I need to write that sum twice in this objective function:

c… objective_fun=e=ktu*sum(t,kappa_tu(t))+(sum(t,e(t))+zeta)*lambda+(s0+(sum(tt$(ord(tt) < ord(t)), e(t)))*sum(t,ni_st(t))+(kst-s0-(sum(tt$(ord(tt) < ord(t)), e(t))))*sum(t,kappa_st(t));

and it keeps telling me that set for ord is not controlled and that uncontrolled set is entered as a constant…

On Thursday, May 21, 2015 at 3:02:23 PM UTC+2, Renger van Nieuwkoop wrote:

Hi Ivan



Here you go (take a good look at the technique used; I think you will understand it)



set t /1*24/;



parameter e(t);


\

  • Initialize e(t) with some dummy values

e(t) = uniform(0,10);



parameter sumet(t);



alias(t,tt);



sumet(t) = sum(tt$(ord(tt) < ord(t)), e(t));



display e;



Cheers



Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Ivan Martic
Sent: Donnerstag, 21. Mai 2015 14:43
To: gams...@googlegroups.com
Subject: Sum top border



Hi everyone, I’m new with gams and I can’t really find a solution to this problem anywhere…

I have defined set t from 1 to 24.

And I need to write a sum of e(t) from 1 to t!

My try: sum(t,e(t))$(ord(t)<t)) but it has 3 errors…

Any ideas?


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.


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.


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.