sum with different values

Problems with syntax of GAMS
Post Reply
BieneMaja
User
User
Posts: 2
Joined: 3 weeks ago

sum with different values

Post by BieneMaja »

Hi,

is would be great if someone could support me with an idea concerning my syntax-issue. As I started working with GAMS a few months ago, I am pretty new to its syntax and thus my question might be easy. Nevertheless, it would be great to get an idea from an experienced user.

In general i have a minimizing algorithms with one positive variable x(t,i) that depends on a set t (time) and a parameter i. I am looking for a syntax that describes a sum over a limited timeframe.
Something like:

sum ((i,j),x(t++j,i))

So the sume should cover the parameter i, however for different times relativly to the value t. This should be described by the set j /1*24/.

I am sorry I do not know to post a minimum example for my problem. I hope someone can help me regarding this issue.

Thank you for your support in this matter.

With best regards
BieneMaja
User avatar
bussieck
Moderator
Moderator
Posts: 1049
Joined: 7 years ago

Re: sum with different values

Post by bussieck »

Here is a working minimal example. Hope this helps. -Michael

Code: Select all

set i 'departments' / i1*i5 /
    j '8 hour slice' / j1*j8 /
    t 'one week in hours' / t1*t168 /;
    

parameter d(i,t) 'demand'; d(i,t) = UniformInt(1,10);
parameter d8(i,t) 'demand for the next 8 hours';

d8(i,t) = sum(j, d(i,t++(ord(j)-1)));

display d,d8;
BieneMaja
User
User
Posts: 2
Joined: 3 weeks ago

Re: sum with different values

Post by BieneMaja »

Thank you very much! This is fantastic and helps me a lot – I really appreciate it!
Post Reply