Set is under control already

Problems with modeling
Post Reply
irem_06
User
User
Posts: 1
Joined: 4 years ago

Set is under control already

Post by irem_06 »

In my Gams code i have problem. My objective function is written below;

OBJ.. OBJFUNC=E= SUM((I,K), Demand(I)*Length(I,K)*X(I,K)+ Sum((K), F(i)*Y(K)));

BINARY VARIABLES Y(K), X(I,K), F(i); (My binary variables are written here)

I want to add fixed cost variable my obj function---[/attachment]
ss.JPG
( please examine

Set is under control already - How can i fixed it= :cry: :cry:
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Set is under control already

Post by Renger »

Hi
Check your parentheses in the objective function and you will see why Gams is complaining. You are summing the fixed costs over K again, so Gams complains that the set is already under control.
Just drop the second sum.
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Sandrina
User
User
Posts: 5
Joined: 2 years ago

Re: Set is under control already

Post by Sandrina »

Hello!
I have a problem with this same error 125.
The constraint I want to write is as follows:
Image
So, in GAMS I typed: cstr35(b,m,i,j,n,t).. sum(j, v(b,m,i,j,t)) + sum(n, v1(b,m,i,n,t)) =e= sum(k, o(b,m,j,k,t)) + sum(k, o1(b,m,n,k,t));
I have two errors saying the "Set is under control already". One immediately following the j of the first sum and one immediately following the n of the second sum.
How can I solve this problem?

Thank you very much!
Attachments
image.png
image.png (3.41 KiB) Viewed 3215 times
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Set is under control already

Post by abhosekar »

you define equation for"every" j and n. Inside that equation, you are again summing over all b and n. Now when GAMS sees sum(j, v(b,m,i,j,t)), it does not understand if the "j" you are referring to the one over which you define equation, or the one over which you define the sum.

First thing in your case is to make sure if you want to write this equation for all j and n. If not, you can change the statement to cstr35(b,m,i,t)..

If you are sure that you want to write equation over all j and n and you also want to sum over j and n, you have to use alias.
alias(j, jj);
alias(n, nn);

cstr35(b,m,i,j,n,t).. sum(jj, v(b,m,i,jj,t)) + sum(nn, v1(b,m,i,nn,t)) =e= sum(k, o(b,m,j,k,t)) + sum(k, o1(b,m,n,k,t));

notice how alias can help GAMS differentiate between the 'j' used for sum and 'j' used for equation.


- Atharv
towkins
User
User
Posts: 8
Joined: 2 years ago

Re: Set is under control already

Post by towkins »

Thanks a lot for your explanation!
abhosekar wrote: 2 years ago you define equation for"every" j and n. Inside that equation, you are again summing over all b and n. Now when GAMS sees sum(j, v(b,m,i,j,t)), it does not understand if the "j" you are referring to the one over which you define equation, or the one over which you define the sum.

First thing in your case is to make sure if you want to write this equation for all j and n. If not, you can change the statement to cstr35(b,m,i,t)..

If you are sure that you want to write equation over all j and n and you also want to sum over j and n, you have to use alias.
alias(j, jj);
alias(n, nn);

cstr35(b,m,i,j,n,t).. sum(jj, v(b,m,i,jj,t)) + sum(nn, v1(b,m,i,nn,t)) =e= sum(k, o(b,m,j,k,t)) + sum(k, o1(b,m,n,k,t));

notice how alias can help GAMS differentiate between the 'j' used for sum and 'j' used for equation.


- Atharv
towkins
User
User
Posts: 8
Joined: 2 years ago

Re: Set is under control already

Post by towkins »

Yesss !! Just drop the second sum !! Thanks
Renger wrote: 4 years ago Hi
Check your parentheses in the objective function and you will see why Gams is complaining. You are summing the fixed costs over K again, so Gams complains that the set is already under control.
Just drop the second sum.
Cheers
Renger
Post Reply