Need help to programm j≠i Topic is solved

Problems with modeling
Post Reply
Bingo LI
User
User
Posts: 12
Joined: 1 year ago

Need help to programm j≠i

Post by Bingo LI » 1 month ago

Hello all,
I want to programm a formulation: sum(t, sum(j∈N & j≠i, P(i,j,t))). The code is as follows:

Code: Select all

set
     i    / 1,2,3 /
     t   / 1*24 /;
alias(i,j);
sum((t,j)$(t,j<>i), p(i,j,t))
However, the programm repor some errors:
148 Dimension different - The symbol is referenced with more/less indices as declared
Could someone can help me to correct it.
Thanks.
Li

Fred
Posts: 151
Joined: 2 years ago

Re: Need help to programm j≠i

Post by Fred » 1 month ago

Hi,

Your code snippet is obviously incomplete and if executed, it does not result in the error you describe.
- it does not declare p
- the sum() must be assigned to some other symbol
- the sum does not control i
- not sure what the t in the dollar condition is supposed to do
- j<>i is no valid GAMS syntax (if j and i are sets)

Maybe you want to do something like:

Code: Select all

set i    / 1,2,3 /
    t   / 1*24 /;
alias(i,j);
parameter p(i,j,t);
scalar x;
p(i,j,t) = uniformint(1,10);
x = sum((i,j,t)$(not sameas(i,j)), p(i,j,t));
display p,x;


I hope this helps!

Fred

Bingo LI
User
User
Posts: 12
Joined: 1 year ago

Re: Need help to programm j≠i

Post by Bingo LI » 1 month ago

Hi Fred,
Thank you for your prompt reply. It solves my problem perfectly.
Just as you said, I misinterpret the GAMS syntax 'j ≠i ' as 'j<>i '.
Again, thank you!

Best,
Li

Post Reply