Error 150: Symbolic Equations Redefined..Cannot define equations. Help!

Problems with syntax of GAMS
Post Reply
anby
User
User
Posts: 3
Joined: 4 months ago

Error 150: Symbolic Equations Redefined..Cannot define equations. Help!

Post by anby » 4 months ago

Hi all,

I am really struggling with the Error 150 which pops up when I run my simple script. I am a beginner with GAMS. I am using the elements of a set (within quotes) to define the individual equations, but it is giving me the error. I think it has got something to do with domain violation, but I can't figure out a way to write it. Every single one of the equations are different, so I don't know of a way to define them other than defining them individually. Here I am showing only 6 equations, but I have over 35 in my actual script. I will really appreciate if you can help me out here.

Thank you,

Anby

Script
Sets
ii actual masses /m26, m27, m28, m29, m30, m31/
j contributions / d1, d2, d3, d4/;

Variables
d(j), mz_sim(ii);

Equations
mz_sim_eqn(ii);

mz_sim_eqn('m26') .. mz_sim('m26') =e= d('d1')*x1;
mz_sim_eqn('m27') .. mz_sim('m27') =e= d('d1')*x2 + d('d2')*x1;
mz_sim_eqn('m28') .. mz_sim('m28') =e= d('d1')*x3 + d('d2')*x2 + d('d3')*x1;
mz_sim_eqn('m29') .. mz_sim('m29') =e= d('d2')*x3 + d('d3')*x2 + d('d4')*x1;
mz_sim_eqn('m30') .. mz_sim('m30') =e= d('d3')*x3 + d('d4')*x2 ;
mz_sim_eqn('m31') .. mz_sim('m31') =e= d('d4')*x3 ;


Here is the output from the .lst file.

394 mz_sim_eqn('m26') .. mz_sim('m26') =e= d('d1')*x1;
395 mz_sim_eqn('m27') .. mz_sim('m27') =e= d('d1')*x2 + d('d2')*x1;
**** $150
**** LINE 137 INPUT GAMS_dir\globalopt_v5.gms
396 mz_sim_eqn('m28') .. mz_sim('m28') =e= d('d1')*x3 + d('d2')*x2 + d('d3')*x1;
**** $150
**** LINE 138 INPUT GAMS_dir\globalopt_v5.gms
397 mz_sim_eqn('m29') .. mz_sim('m29') =e= d('d2')*x3 + d('d3')*x2 + d('d4')*x1;
**** $150
**** LINE 139 INPUT GAMS_dir\globalopt_v5.gms
398 mz_sim_eqn('m30') .. mz_sim('m30') =e= d('d3')*x3 + d('d4')*x2 ;
**** $150
**** LINE 140 INPUT GAMS_dir\globalopt_v5.gms
399 mz_sim_eqn('m31') .. mz_sim('m31') =e= d('d4')*x3 ;
**** $150
**** LINE 141 INPUT GAMS_dir\globalopt_v5.gms

User avatar
Renger
Posts: 127
Joined: 1 year ago

Re: Error 150: Symbolic Equations Redefined..Cannot define equations. Help!

Post by Renger » 4 months ago

Hi Anby

If you define an equation over a set, in Gams you can't write down the single equations. For this you should have defined every single equation like eq_28, eq_29.

It is easier to define a table with the coefficients for the X-Variables and write down one equation definition like this:

Code: Select all

table  d(ii,*)  coefficients
        d1    d2    d3   d4
...
m26
m27
...
;

equations mz_sim_eqn(ii);

mz_sim_eqn(ii) ..
    mz_sim(ii) =e= d(ii,'d4')*x4 + d(ii,'d3')*x3 + d(ii,'d2')*x2 + d(ii,'d1')*x1;


Hope this helps!

Cheers
Renger

anby
User
User
Posts: 3
Joined: 4 months ago

Re: Error 150: Symbolic Equations Redefined..Cannot define equations. Help!

Post by anby » 3 months ago

Renger wrote:
4 months ago
Hi Anby

If you define an equation over a set, in Gams you can't write down the single equations. For this you should have defined every single equation like eq_28, eq_29.

It is easier to define a table with the coefficients for the X-Variables and write down one equation definition like this:

Code: Select all

table  d(ii,*)  coefficients
        d1    d2    d3   d4
...
m26
m27
...
;

equations mz_sim_eqn(ii);

mz_sim_eqn(ii) ..
    mz_sim(ii) =e= d(ii,'d4')*x4 + d(ii,'d3')*x3 + d(ii,'d2')*x2 + d(ii,'d1')*x1;

Hope this helps!

Cheers
Renger
Thank you Renger, appreciate the clarification!

On another note, does GAMS allow table elements to be functions of variables ? For example, when x1, x3 and x3 are variables is the following permitted ?

table d(ii,*) coefficients
d1 d2 d3 d4
m26 x1 x1*x2 x3^2 ...
m27 ....................................
...
;

anby
User
User
Posts: 3
Joined: 4 months ago

Re: Error 150: Symbolic Equations Redefined..Cannot define equations. Help!

Post by anby » 3 months ago

Thanks Renger, appreciate the clarification!

On another note, does GAMS permit tables whose elements consists of variables ? For example, if x1, x2, x3 are variables, then is the following permitted ?

table d(ii,*) coefficients
d1 d2 d3 d4
...
m26 x1 x1*x2 x3*x1 x1^2
m27......................................................
...
;
Renger wrote:
4 months ago
Hi Anby

If you define an equation over a set, in Gams you can't write down the single equations. For this you should have defined every single equation like eq_28, eq_29.

It is easier to define a table with the coefficients for the X-Variables and write down one equation definition like this:

Code: Select all

table  d(ii,*)  coefficients
        d1    d2    d3   d4
...
m26
m27
...
;

equations mz_sim_eqn(ii);

mz_sim_eqn(ii) ..
    mz_sim(ii) =e= d(ii,'d4')*x4 + d(ii,'d3')*x3 + d(ii,'d2')*x2 + d(ii,'d1')*x1;


Hope this helps!

Cheers
Renger

User avatar
Renger
Posts: 127
Joined: 1 year ago

Re: Error 150: Symbolic Equations Redefined..Cannot define equations. Help!

Post by Renger » 3 months ago

no that is not possible.
CHeers
Renger

Post Reply