a suffix is missing error Topic is solved

Problems with syntax of GAMS
Post Reply
seydaseyda
User
User
Posts: 31
Joined: 3 years ago

a suffix is missing error

Post by seydaseyda »

Hi everyone,


I am super new on Gams. It will be so nice for me if you can help me!

I used alias i and j to show people. And I defined the x(i) as a binary variable. and of course I have another binary which is x(j) but however I could not use this x(j) on any constraints.
The error says ''a suffix is missing''error 141 also error 143.


Thanks in advance
Last edited by seydaseyda 3 years ago, edited 2 times in total.
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: a suffix is missing error

Post by abhosekar »

Please follow tutorials and examples from GAMS documentation. https://www.gams.com/latest/docs/UG_MAI ... l_Examples

You have to define constraint name and constraint as follows.

Code: Select all

equation
con1;

con1(i).. w(i)=e=sum(j,K(i,j)*x(j))*x(i);
further, this constraint is not the best way to model since it contains multiplication of two binary variables.
You can use big-M formulation to linearize this.

Code: Select all

equations
con1a, con1b;

con1a(i).. w(i) =l= sum(j,K(i,j)*x(j)) + M*(1- x(i));
con1b(i).. w(i) =l= M*x(i);
where I assume you have defined w as a positive variable; M is a big enough number (usually upper bound on w).

- Atharv
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: a suffix is missing error

Post by abhosekar »

In your previous code, you defined w as a variable. In this code, you are defining it as a parameter (I think it should be a variable). This will be enough to get rid of your error.

I see that you have -w(i) in the objective which makes me rethink my constraints. If you are maximizing your objective, then the current constraints should work.
However, if you are minimizing, we need to do more.


eq5(i)..w(i)=l=sum(j, K(i,j)*x(j))+Mi*(1-x(i));
eq5a(i)..w(i)=g=sum(j, K(i,j)*x(j))-Mi*(1-x(i));

eq6(i)..w(i)=l=Mi*x(i);
eq6a(i)..w(i)=g=-Mi*x(i);

This is a better way.

- Atharv
seydaseyda
User
User
Posts: 31
Joined: 3 years ago

Re: a suffix is missing error

Post by seydaseyda »

Thanks again, it worked!
YCCC97
User
User
Posts: 6
Joined: 2 years ago

Re: a suffix is missing error

Post by YCCC97 »

Hey there! Greetings!
So, is it possible to do so? I'm encounter the same problem where my previous part was equation and then i want to use some of the variable from the previous part to next part(parameter). If yes, how should i correct my equations? Actually i need the model to help me find the Frij and MFij, then the rest of the equation should use parameter section to calculate. But yeah, i encounter the error code "A suffix is missing...", many thanks!

Equation
Eq1 Total MF of supply must equal or less than supply to demand
Eq2a Sending C and N simultaneously from supply to demand side
Eq2b Sending C and N simultaneously from supply to demand side
Eq2c Sending C and N simultaneously from supply to demand side
Eq2d Sending H from supply to demand side
Eq2e Sending O from supply to demand side
Eq2f Sending other components from supply to demand side
Eq3 Total fraction used for each supply must less than 1
Eq4a Sum of demand MF must equal to sum of supply and external supply
Eq4b Sum of demand C must equal to sum of supply and external supply
Eq4c Sum of demand N must equal to sum of supply and external supply
;

Eq1(i).. (MFi(i))=G=sum[(j),MFij(i,j)];
Eq2a(i,j).. MFij(i,j) =E=(Frij(i,j))*[Ci(i)+Ni(i)];
Eq2b(i,j).. Cij(i,j) =E= Frij(i,j)*Ci(i);
Eq2c(i,j).. Nij(i,j) =E= Frij(i,j)*Ni(i);
Eq2d(i,j).. Hij(i,j) =E= [H(i)/C(i)]*[Cij(i,j)];
Eq2e(i,j).. Oij(i,j) =E= [O(i)/C(i)]*[Cij(i,j)];
Eq2f(i,j).. Otherij(i,j) =E=[Other(i)/C(i)]*[Cij(i,j)];
Eq3(i,j).. Frij(i,j)=L=1;
Eq4a(j).. MFj(j)=E=sum[i,MFij(i,j)];
Eq4b(j).. Cj(j)=E=sum(i,Cij(i,j));
Eq4c(j).. Nj(j)=E=sum(i,Nij(i,j));
Eq0F.. OF =E= sum[(i,j),MFij(i,j)]*1;

Parameter
Cmole Carbon mole received by each demand
Hmole Hydrogen mole received by each demand
Omole Oxygen mole received by each demand
Nmole Nitrogen mole received by each demand
;

Cmole(j)=sum[i,Cij(i,j)]/Cmw;
Hmole(j)=sum[i,Hij(i,j)]/Hmw;
Omole(j)=sum[i,Oij(i,j)]/Omw;
Nmole(j)=sum[i,Nij(i,j)]/Nmw;
abhosekar wrote: 3 years ago In your previous code, you defined w as a variable. In this code, you are defining it as a parameter (I think it should be a variable). This will be enough to get rid of your error.

I see that you have -w(i) in the objective which makes me rethink my constraints. If you are maximizing your objective, then the current constraints should work.
However, if you are minimizing, we need to do more.


eq5(i)..w(i)=l=sum(j, K(i,j)*x(j))+Mi*(1-x(i));
eq5a(i)..w(i)=g=sum(j, K(i,j)*x(j))-Mi*(1-x(i));

eq6(i)..w(i)=l=Mi*x(i);
eq6a(i)..w(i)=g=-Mi*x(i);

This is a better way.

- Atharv
Post Reply