Error 142 suffix is not allowed

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

Error 142 suffix is not allowed

Post by Pras24 »

Hello everyone,

I am a new GAMS user. I have tried to model my case using GAMS but I am still in the learning process.

Code: Select all

Sets
   s "CDU cuts" /offgas,LSRN,HSRN,SRK,SRMD,SRGO,Residue/
   j "type of k" /k0,k1,k2,k3,k4/
   i "type of a" /a0,a1,a2,a3,a4/



Parameter

   x1       'cut-point temperature of offgas'
   x2        'cut-point temperature of LSRN'
   x3         'cut-point temperature of HSRN'
   x4          'cut-point temperature of SRK'
   x5         'cut-point temperature of SRMD'
   x6        'cut-point temperature of SRGO'
   x7      'cut-point temperature of Residue'   ;

   x1.up = -10 ;
   x1.lo = -50 ;
   x2.up = 220 ;
   x2.lo = 90  ;
   x3.up = 380 ;
   x3.lo = 180 ;
   x4.up = 520  ;
   x4.lo = 330  ;
   x5.up = 630 ;
   x5.lo = 420 ;
   x6.up = 1050 ;
   x6.lo = 610 ;
   x7.up = 1200 ;
   x7.lo = 950 ;


Parameter a(i)   'value of type a'

      / a0           4.040637061
        a1           -0.047271899
        a2           0.000324992
        a3           -2.84324E-07
        a4           8.15312E-011  /;

Parameter k(j)   'value of type k'

      / k0           0
        k1           1
        k2           2
        k3           3
        k4           4  /;

Parameter

   F1      'Flowrate of CDU offgas yield in bpsd'
   F2         'Flowrate of CDU LSRN yield in bpsd'
   F3        'Flowrate of CDU HSRN yield in bpsd'
   F4          'Flowrate of CDU SRK yield in bpsd'
   F5         'Flowrate of CDU SRMD yield in bpsd'
   F6        'Flowrate of CDU SRGO yield in bpsd'
   F7      'Flowrate of CDU Residue yield in bpsd'   ;

   F1 =g= 86000 ;
   F2 =g= 29000 ;
   F3 =g= 72000 ;
   F4 =g= 14000 ;
   F5 =g= 20000 ;
   F6 =g= 21000 ;
   F7 =g= 8000;


Variables

   Y1       'CDU yield of offgas in Vol'
   Y2         'CDU yield of LSRN in Vol'
   Y3         'CDU yield of HSRN in Vol'
   Y4         'CDU yield of SRK in Vol'
   Y5        'CDU yield of SRMD in Vol'
   Y6         'CDU yield of SRGO in Vol'
   Y7     'CDU yield of Residue in Vol'
   P                 'CDU total profit'
 ;

Scalars  VF    'crude oil feed flowrate'  /225000/
        PF   'price of crude oil'  /55/  ;

Equations
   EQ1     'CDU yield of offgass'
   EQ2     'CDU yield of LSRN'
   EQ3     'CDU yield of HSRN'
   EQ4     'CDU yield of SRK'
   EQ5     'CDU yield of SRMD'
   EQ6     'CDU yield of SRGO'
   EQ7     'CDU yield of Residue'
   EQ8     'Flowrate of offgas'
   EQ9     'Flowrate of LSRN'
   EQ10    'Flowrate of HSRN'
   EQ11    'Flowrate of SRK'
   EQ12    'Flowrate of SRMD'
   EQ13    'Flowrate of SRGO'
   EQ14    'Flowrate of Residue'
   EQ15    'Define Objective Function'  ;

   EQ1..Y1   =e= sum((i,j),a(i)*(x1**k(j)))  ;
   EQ2..Y2     =e= sum((i,j),a(i)*(x2**k(j)))  ;
   EQ3..Y3     =e= sum((i,j),a(i)*(x3**k(j)))  ;
   EQ4..Y4      =e= sum((i,j),a(i)*(x4**k(j)))  ;
   EQ5..Y5     =e= sum((i,j),a(i)*(x5**k(j)))  ;
   EQ6..Y6    =e= sum((i,j),a(i)*(x6**k(j)))   ;
   EQ7..Y7  =e= sum((i,j),a(i)*(x7**k(j)))  ;
   EQ8..F1   =e= VF * (Y1/100)    ;
   EQ9..F2    =e= VF * ((Y2 - Y1)/100) ;
   EQ10..F3    =e= VF * ((Y3 - Y2)/100)  ;
   EQ11..F4     =e= VF * ((Y4 - Y3)/100) ;
   EQ12..F5    =e= VF * ((Y5 - Y4)/100)  ;
   EQ13..F6     =e= VF * ((Y6-Y5)/100)   ;
   EQ14..F7  =e= VF*F7                  ;
   EQ15..P =e= F1*5+F2*6+F3*7+F4*8+F5*9+F6*10+F7*11-VF*PF    ;

Model CDUVer5 /all/;
Solve CDUVer5 using NLP maximizing P  ;

When I hit the run button, i get an error message 142 (suffix is not allowed).

Can somebody teach me how to fix this.

Thank you.

Best regards,

Wegik Dwi Prasetyo
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Error 142 suffix is not allowed

Post by Renger »

Hi Wegik
It looks like you mix the concept of parameter, variables and equations.

Variables can have bounds, levels and marginals and you can set them by using the extension .UP, .LO for bounds, .L for levels and .M for marginals.
Parameters are constants and do not have bounds (well, you could say it is a variable where the upper- and lower bounds are equal to the value of the parameter). If you define a parameter, you set the value without .L.

Code: Select all

parameter p;

p = 1;

variable X;
X.LO = -10;
I strongly suggest that you study at least the tutorial by Rick Rosenthal.

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Pras24
User
User
Posts: 4
Joined: 4 years ago

Re: Error 142 suffix is not allowed

Post by Pras24 »

Thank you Renger for your suggestion.

May I ask again?
I have done some revision to the code as following :
Sets
s "CDU cuts" /offgas,LSRN,HSRN,SRK,SRMD,SRGO,Res/
j "type of k" /k0,k1,k2,k3,k4/
i "type of a" /a0,a1,a2,a3,a4/
o "cut-point temperature of s" /x1,x2,x3,x4,x5,x6,x7/

VARIABLES
x1 'cut-point temperature of offgas'
x2 'cut-point temperature of LSRN'
x3 'cut-point temperature of HSRN'
x4 'cut-point temperature of SRK'
x5 'cut-point temperature of SRMD'
x6 'cut-point temperature of SRGO'
x7 'cut-point temperature of Res' ;

PARAMETER DEMAND(s) demand for product s
/offgas 86000
LSRN 29000
HSRN 72000
SRK 14000
SRMD 20000
SRGO 21000
Res 8000/;

PARAMETER LOWER(s,o) lower bound on.. .;

LOWER("offgas","x1")= -50 ;
LOWER("LSRN","x2")=90 ;
LOWER("HSRN","x3")=180 ;
LOWER("SRK","x4")=330 ;
LOWER("SRMD","x5")=420 ;
LOWER("SRGO","x6")=610 ;
LOWER("Res","x7")=950 ;

PARAMETER UPPER(s,o) upper bound on...;

UPPER("offgas","x1")= -10 ;
UPPER("LSRN","x2") =220 ;
UPPER("HSRN","x3") =380 ;
UPPER("SRK","x4") =520 ;
UPPER("SRMD","x5") =630 ;
UPPER("SRGO","x6") =1050 ;
UPPER("Res","x7") =1200 ;


Parameter a(i) 'value of type a'

/ a0 4.040637061
a1 -0.047271899
a2 0.000324992
a3 -2.84324E-07
a4 8.15312E-011 /;

Parameter k(j) 'value of type k'

/ k0 0
k1 1
k2 2
k3 3
k4 4 /;

Variables

F1 'Production rate of CDU offgas yield in bpsd'
F2 'Production rate of CDU LSRN yield in bpsd'
F3 'Production rate of CDU HSRN yield in bpsd'
F4 'Production rate of CDU SRK yield in bpsd'
F5 'Production rate of CDU SRMD yield in bpsd'
F6 'Production rate of CDU SRGO yield in bpsd'
F7 'Production rate of CDU Res yield in bpsd'
Y1 'CDU yield of offgas in Vol'
Y2 'CDU yield of LSRN in Vol'
Y3 'CDU yield of HSRN in Vol'
Y4 'CDU yield of SRK in Vol'
Y5 'CDU yield of SRMD in Vol'
Y6 'CDU yield of SRGO in Vol'
Y7 'CDU yield of Res in Vol'
P 'CDU total profit';

POSITIVE VARIABLES F1,F2,F3,F2,F3,F4,F5,F6,F7,Y1,Y2,Y3,Y4,Y5,Y6,Y7;

Scalars VF 'crude oil feed flowrate' /225000/
PF 'price of crude oil' /55/ ;

Equations
EQ1 'CDU yield of offgass'
EQ2 'CDU yield of LSRN'
EQ3 'CDU yield of HSRN'
EQ4 'CDU yield of SRK'
EQ5 'CDU yield of SRMD'
EQ6 'CDU yield of SRGO'
EQ7 'CDU yield of Res'
EQ8 'Demand constraint of offgas'
EQ9 'Demand constraint of LSRN'
EQ10 'Demand constraint of HSRN'
EQ11 'Demand constraint of SRK'
EQ12 'Demand constraint of SRMD'
EQ13 'Demand constraint of SRGO'
EQ14 'Demand constraint of Res'
EQ15 'Flowrate of offgas'
EQ16 'Flowrate of LSRN'
EQ17 'Flowrate of HSRN'
EQ18 'Flowrate of SRK'
EQ19 'Flowrate of SRMD'
EQ20 'Flowrate of SRGO'
EQ21 'Flowrate of Res'
EQ22 'Total yield constraint'
EQ23 'Total mass balance constraint'
EQ24 'Define Objective Function' ;


EQ1..Y1 =e= sum((i,j),a(i)*(x1**k(j))) ;
EQ2..Y2 =e= sum((i,j),a(i)*(x2**k(j))) ;
EQ3..Y3 =e= sum((i,j),a(i)*(x3**k(j))) ;
EQ4..Y4 =e= sum((i,j),a(i)*(x4**k(j))) ;
EQ5..Y5 =e= sum((i,j),a(i)*(x5**k(j))) ;
EQ6..Y6 =e= sum((i,j),a(i)*(x6**k(j))) ;
EQ7..Y7=e=100-Y6;
EQ8..F1-VF * (Y1/100)=e=0;
EQ9..F2-VF * ((Y2 - Y1)/100) =e=0;
EQ10..F3-VF * ((Y3 - Y2)/100)=e=0;
EQ11..F4-VF * ((Y4 - Y3)/100)=e=0 ;
EQ12..F5-VF * ((Y5 - Y4)/100)=e=0;
EQ13..F6-VF * ((Y6-Y5)/100) =e=0 ;
EQ14..F7-VF * ((100-Y6)/100)=e=0 ;
EQ15.. F1 =g= DEMAND("offgas") ;
EQ16.. F2 =g= DEMAND("LSRN") ;
EQ17.. F3 =g= DEMAND("HSRN") ;
EQ18.. F4 =g= DEMAND("SRK") ;
EQ19.. F5 =g= DEMAND("SRMD") ;
EQ20.. F6 =g= DEMAND("SRGO") ;
EQ21.. F7 =g= DEMAND("Res") ;
EQ22..100-(Y1+Y2+Y3+Y4+Y5+Y6+Y7)=e=0;
EQ23.. VF-(F1+F2+F3+F4+F5+F6+F7)=e=0;
EQ24..P =e= F1*60+F2*70+F3*80+F4*90+F5*100+F6*110+F7*59-VF*PF ;

Model CDUVer12 /all/;
Solve CDUVer12 using NLP maximizing P;
DISPLAY F1.l,F2.l,F3.l,F4.l,F5.l,F6.l,F7.l,Y1.l,Y2.l,Y3.l,Y4.l,Y5.l,Y6.l,Y7.l
P.l;

The problem is I want to have a simpler algebraic equation for F and Y, so the equations are not taking much space. I have been thinking to use the sets but I can not figure it out.

And in the equation, there is x variables and these variables have upper and lower bound. Am i writing the equation correctly? because in Variables ,I use x. But in parameter, I use LOWER(s,o) and UPPER(s,o).

Thank you.

best regards,

Wegik
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Error 142 suffix is not allowed

Post by Renger »

Hi Wegik

You are on track. Gams allows you to use indexed variables and parameters, so you can write your model using this feature. I made some changes to your code. Have a good look at what I did and continue from there. BTW: Better to attach your code file, or put it in a code block (use the button </>). It is good practice to make a distinction between variables and parameters. This makes reading your code easier. I prefer variables in upper case and parameters in lower case. As you try to raise a variable to a negative power, you should use power(x,k[)/i] and not x**k.
Cheear
Renger


Code: Select all

Sets
s "CDU cuts" /offgas,LSRN,HSRN,SRK,SRMD,SRGO,Res/
j "type of k" /k0,k1,k2,k3,k4/
i "type of a" /a0,a1,a2,a3,a4/
;

VARIABLES
    X(s) 'cut-point temperature';


PARAMETER demand(s) demand for product s
/offgas 86000
LSRN 29000
HSRN 72000
SRK 14000
SRMD 20000
SRGO 21000
Res 8000/;

PARAMETER lower(s) lower bound on.. .;

lower("offgas") = -50 ;
lower("lsrn")   =90 ;
lower("hsrn")   =180 ;
lower("srk")    =330 ;
lower("srmd")   =420 ;
lower("srgo")   =610 ;
lower("res")    =950 ;

parameter upper(s) upper bound on...;

upper("offgas") = -10 ;
upper("lsrn")   =220 ;
upper("hsrn")   =380 ;
upper("srk")    =520 ;
upper("srmd")   =630 ;
upper("srgo")   =1050 ;
upper("res")    =1200 ;


Parameter a(i) 'value of type a'

/ a0 4.040637061
a1 -0.047271899
a2 0.000324992
a3 -2.84324E-07
a4 8.15312E-011 /;

Parameter k(j) 'value of type k'

/ k0 0
k1 1
k2 2
k3 3
k4 4 /;

parameter fc(s);

fc('offgas') = 60;
fc('LSRN') = 70;
fc('HSRN') = 80;
fc('SRK') = 90;
fc('SRMD') = 100;
fc('SRGO') = 110;
fc('Res') = 59;

Positive Variables
    F(s)
    Y(s)
    ;
Variable
    P 'CDU total profit';


Scalars
    vf 'crude oil feed flowrate' /225000/
    pf 'price of crude oil' /55/ ;

Equations
EQS(s) 'CDU yield'
EQ7 'CDU yield of Res'
EQ8 'Demand constraint of offgas'
EQ9 'Demand constraint of LSRN'
EQ10 'Demand constraint of HSRN'
EQ11 'Demand constraint of SRK'
EQ12 'Demand constraint of SRMD'
EQ13 'Demand constraint of SRGO'
EQ14 'Demand constraint of Res'
EQF(s) 'Flowrate'
EQY 'Total yield constraint'
EQVF 'Total mass balance constraint'
EQ24 'Define Objective Function' ;

EQS(s)$(not sameas(s,'RES'))..
    Y(s) =e= sum((i,j),a(i)*power(x(s),k(j))) ;
EQ7..Y('RES')=e=100 - Y("SRGO");
EQ8..F("Offgas")-VF * (Y("OFFGAS")/100)=e=0;
EQ9..F("LSRN")-VF * ((Y("LSRN") - Y("HSRN"))/100) =e=0;
EQ10..F("HSRN")-VF * ((Y("HSRN") - Y("SRK"))/100)=e=0;
EQ11..F("SRK")-VF * ((Y("SRK") - Y("HSRN"))/100)=e=0 ;
EQ12..F("SRMD")-VF * ((Y("SRMD") - Y("SRK"))/100)=e=0;
EQ13..F("SRGO")-VF * ((Y("SRGO")-Y("SRMD"))/100) =e=0 ;
EQ14..F("Res")-VF * ((100-Y("SRGO"))/100)=e=0 ;
EQF(s).. F(s) =g= demand(s) ;
EQY..100-sum(s, Y(s))=e=0;
EQVF.. VF-sum(s, F(s))=e=0;
EQ24..P =e= sum(s, fc(s)*f(s)) - vf * PF ;

X.LO(s) = lower(s);
X.UP(s) = upper(s);
Model CDUVer12 /all/;
Solve CDUVer12 using NLP maximizing P;
DISPLAY F.L, Y.L, P.l;
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Pras24
User
User
Posts: 4
Joined: 4 years ago

Re: Error 142 suffix is not allowed

Post by Pras24 »

I run the new code.
However, it said an initial function value is too large (larger than 1.0E+10).
It suggests to scale the variables and/or equations or add bounds.


I tried to scale down the scalar (crude oil feed and demands), however the result is the same.

What should I change?

Thank you.
Pras24
User
User
Posts: 4
Joined: 4 years ago

Re: Error 142 suffix is not allowed

Post by Pras24 »

I scale the lower and upper bound.
But after execution it is said no super basic variables (infeasible solution).

What could be wrong?
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Error 142 suffix is not allowed

Post by Renger »

Hi
It might be the following problem: If you scale, you should scale all parameters in a consistent way. Not just one.
For example if you had an equation like
VARX * parB =E= parC;
you should not only scale parB but also parC.
If you have infeasibilities, either you still have problems in your equations or your problem has no solution.
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply