Problem with conditional summation

Problems with modeling
Post Reply
Andi1205
User
User
Posts: 4
Joined: 6 years ago

Problem with conditional summation

Post by Andi1205 »

Hey everyone,

I'm having a Problem with the summation of a part of a set. After reading numerous threads and the GAMS guide I still can't find the cause of the code not working.

Code:
alias (m,n);

Positive variables
AI(p,m) quantity sold
Q(p,m) quanitity produced

Equations
AMP(p,m)

Restriction:
AMP(p,m).. sum(n$(ord(m) LE n),(Q(p,m))) =G= sum(n$(ord(m) LE n), AI(p,m));
->This restriction is supposed to make sure that there cannot be sold more products than produced until the period.
I get Errors 135 (Incompatibel operands) and 148 (Dimension different) for both sides of this equation but i juzst cant figure out why.

Is there somebody who knows what to change?

Thanks in advance!
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Problem with conditional summation

Post by bussieck »

You managed to use ord for m, now you just need to do the same for n:

Code: Select all

AMP(p,m).. sum(n$(ord(m) LE ord(n)),(Q(p,m))) =G= sum(n$(ord(m) LE (ord(n)), AI(p,m)); 
-Michael
Andi1205
User
User
Posts: 4
Joined: 6 years ago

Re: Problem with conditional summation

Post by Andi1205 »

It's working! Thank you very much!
Post Reply