Page 1 of 1

Problem with conditional summation

Posted: Sun Mar 03, 2019 3:39 pm
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!

Re: Problem with conditional summation

Posted: Mon Mar 04, 2019 7:47 am
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

Re: Problem with conditional summation

Posted: Mon Mar 04, 2019 10:08 am
by Andi1205
It's working! Thank you very much!