Unknown error when creating a new variable

Problems with modeling
Post Reply
mgarnhamo
User
User
Posts: 5
Joined: 3 months ago

Unknown error when creating a new variable

Post by mgarnhamo » 4 weeks ago

Hello!
I'm creating a model on reuse of greywater in a household, minimizing freshwater use. I added a cost parameter but it doesn't show any results and it tells me it has 1 error, which i couldn't know what was causing it.

Here goes the model:

Code: Select all

option limrow = 0;
option limcol = 0;
option solprint = on;
option sysout = off;

*option LP=CPLEX;
*option MIP=CPLEX;
option NLP=SNOPT;
*option MINLP=DICOPT;
option OPTCR=0;
$ontext

a = 0.25
Wi >= a*(sum(F(t,i))+ sum(FWi))



CFW(i,j)*FW(i) + M(i,j) = W(i)*CW(i,j) + F(i,t)*CF(i,j,t)
Sum[i,*F(i,t)*CF(i,j,t)]*R(t,j) = Sum[i,F(t,i)]*CT(i,t,j)
fw(5)=0 y f(5,t)=0

                                        [M(i,j)] [W(i),CF(i,j)]
                                              ||      /\
                                              V       ||
[Agua potable,CFW] =FW(i)=> [Operación i] =F(i,t),CF(i,j)=> [Tratamiento t, R(t,j)]
                                 /\                                 ||
                                 \\                                //
                                   ========FT(i,t),CT(t,j)=========
pfw = precio por litro de agua potable
h = tiempo de operación anualizado
pp(t) = precio por las tuberías

$offtext
SETS
j contaminante /j1*j4/
i operacion /i1*i5/
t tratamientos /t1*t2/

PARAMETERS


x(i) flujo minimo de agua por operacion /i1=72,i2=152,i3=32,i4=164,i5=144/
cfw(j) restricciones para j en operaciones con agua potable /j1=0,j2=0,j3=1,j4=10/
cnp(j) restricciones para j en operaciones con agua no potable /j1=4.2,j2=5.0,j3=0.5,j4=3.2/
pt(t)  costo por litro de los tratamientos /t1=18.44, t2=0.418/
b(t)   factor exponencial por tratamiento /t1=0.65,t2=0.97/
pp(t)  precio por litro? de las tuberías /t1=10, t2=14/   ;

Table Cin(i,j) max que puede ingresar de contaminante j a la operación i (CFW*FW+CT*FT):(FT+FW)=C'in<Cin

         j1      j2      j3      j4
     i1  0       0       1       10
     i2  10      15      3       25.4
     i3  10      15      3       25.4
     i4  10      15      3       25.4
     i5  10      15      3       25.4    ;

Table Cout(i,j) max que puede salir de cont. j de la operación i  M+C'in-W*CW=F(i.t)*CF<Cout

         j1      j2      j3      j4
     i1  463.3   245     23.33   50.1
     i2  81.32   59.47   3.95    50.19
     i3  232.5   59.47   73.25   50.28
     i4  361.2   267.6   52.44   50.67
     i5  297.8   347.8   15.28   50.76   ;

Table M(i,j) mass of pollutant j added in operation i. it is not a restriction it is a data

         j1      j2      j3      j4
     i1  33.36   17.64   1.61    2.89
     i2  10.84   6.76    0.14    3.77
     i3  7.12    1.42    2.25    0.80
     i4  57.6    41.42   8.11    4.14
     i5  41.44   47.92   1.77    3.65    ;

Table R(t,j) 1 - factor removal of the contaminant j in the treatment t

         j1      j2      j3      j4
     t1  0.14    0.03    1       0.93
     t2  0.6     0.01    0.01    0.04    ;


VARIABLES

apot
fw(i)     agua potable que entra para cada proceso i
w(i)      aguas negras de cada proceso i
f(i,t)    aguas que serán reutilizadas en t luego de ser usadas en i
ft(i,t)   agua reutilizada luego del tratamiento t para el proceso i
cf(i,j)   concentracion de j en las aguas que salen de i
ct(t,j)   concentracion de j de las aguas que salen de t
cw(i,j)   concentracion de j de las aguas que se desechan de i
cost

;

POSITIVE VARIABLES
fw(i)     'fresh water that goes into the operation i (L/day)'
w(i)      'waste water from operation i (L/day)'
f(i,t)    'grey water that will be treated in t after being used in i (L/day)'
ft(i,t)   'reused water from treatment t going to be used in i (L/day)'
cf(i,j)   'concentration of j in waters coming from i (mg/L)'
ct(t,j)   'concentration of j in waters coming from t (mg/L)'
cw(i,j)
cost
;
EQUATIONS
funobj, volumenin, toilet1, toilet2, waste,eq1, eq2, eq3, eq4, eq5, eq7, eq8, costo ;
funobj.. apot =E= sum(i,fw(i)) ;
volumenin(i)..  sum(t,ft(i,t))+fw(i)=G=x(i)     ;
toilet1(i).. fw('i5')=E=0 ;
toilet2(i).. sum(t,f('i5',t))=E=0 ;
waste(i)..  w(i) =G= 0.25*(sum(t,ft(i,t))+fw(i));
eq1(i,j)..  (fw(i)*cfw(j)+sum(t,ct(t,j)*ft(i,t)))/(sum(t,ft(i,t))+fw(i))=L= Cin(i,j)  ;
eq2(i,j)..  M(i,j)+(fw(i)*cfw(j)+sum(t,ct(t,j)*ft(i,t)))/(sum(t,ft(i,t))+fw(i))=E= w(i)*cf(i,j)+sum(t,f(i,t))*cf(i,j) ;
eq3(t,j)..  sum(i,f(i,t)*cf(i,j))*R(t,j) =E= sum(i,ft(i,t))*ct(t,j) ;
eq4(i,j)..  cf(i,j) =L= Cout(i,j) ;
eq5(i)..   fw(i)+sum(t,ft(i,t)) =E= w(i)+sum(t,f(i,t))   ;
eq7(t).. sum(i,f(i,t))=E=sum(i,ft(i,t))   ;
eq8(i,j).. cf(i,j)=L=Cout(i,j)  ;
costo.. cost =E= 10*sum(i,fw(i))+0.5*sum(i,sum(t,pt(t)*(f(i,t)**b(t))))+0.5*sum(i,sum(t,pp(t)*f(i,t)**0.5)) ;
MODEL  aguapotable /all/;

fw.l(i)   = 1;
w.l(i)    = 1;
f.l(i,t)  = 0.01;
ft.l(i,t) = 0.01;
cf.l(i,j) = 1;
ct.l(t,j) = 1;

SOLVE  aguapotable using nlp minimizing apot ;
Thanks in advance to anyone who could help! :)

User avatar
bussieck
Moderator
Moderator
Posts: 645
Joined: 5 years ago

Re: Unknown error when creating a new variable

Post by bussieck » 4 weeks ago

SNOPT is a local solver and gets stuck in bad points of your non-convex model. This is a good case for a global solver, like Antigone, Baron, Lindo, or Scip. With that we can easily solve the model:

Code: Select all

               S O L V E      S U M M A R Y

     MODEL   aguapotable         OBJECTIVE  apot
     TYPE    NLP                 DIRECTION  MINIMIZE
     SOLVER  BARON               FROM LINE  131

**** SOLVER STATUS     1 Normal Completion
**** MODEL STATUS      1 Optimal
**** OBJECTIVE VALUE              249.0000

 RESOURCE USAGE, LIMIT          0.430 10000000000.000
 ITERATION COUNT, LIMIT         0    2147483647
 EVALUATION ERRORS              0             0
-Michael

mgarnhamo
User
User
Posts: 5
Joined: 3 months ago

Re: Unknown error when creating a new variable

Post by mgarnhamo » 3 weeks ago

Thanks! it worked now!
Although i just erased the SNOPT part because i couldn't add Baron or other solver to the code, how can i do that?

User avatar
bussieck
Moderator
Moderator
Posts: 645
Joined: 5 years ago

Re: Unknown error when creating a new variable

Post by bussieck » 3 weeks ago

Although i just erased the SNOPT part because i couldn't add Baron or other solver to the code, how can i do that?
Not sure what you mean. Just change "option nlp=baron;" (or any of the other code). BARON has been part of the GAMS system for 20 years now. You might need a license. Contact you sales rep in case you can't make this work.

-Michael

mgarnhamo
User
User
Posts: 5
Joined: 3 months ago

Re: Unknown error when creating a new variable

Post by mgarnhamo » 3 weeks ago

It's a matter of license indeed, i don't mind not having Baron because the model works fine without it, but thanks a lot for the response!

- Matías

Post Reply