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] ( please examine
Set is under control already - How can i fixed it=
Set is under control already
Re: Set is under control already
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
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
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Re: Set is under control already
Hello!
I have a problem with this same error 125.
The constraint I want to write is as follows:
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!
I have a problem with this same error 125.
The constraint I want to write is as follows:
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 (3.41 KiB) Viewed 3215 times
Re: Set is under control already
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
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
Re: Set is under control already
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
Re: Set is under control already
Yesss !! Just drop the second sum !! Thanks