Error 66 - the symbol shown has not been defined or assigned (for objective function)

Problems with syntax of GAMS
Post Reply
sevasta
User
User
Posts: 1
Joined: 7 years ago

Error 66 - the symbol shown has not been defined or assigned (for objective function)

Post by sevasta »

Hello,

I'm struggling with my code. It's a MILP problem for plant and capacity allocation with 210 binary and 5 continuous variables. When I run the code, it returns the error 66 "the symbol shown has not been defined or assigned" in relation to my objective function in the very last solve statement, but the objective function has been defined. Could you take a look at my code and advise what I could be doing wrong please? Thank you!

Code: Select all

sets
i farms /
$call =xls2gms r=farms!B3:B39 i=parameters_for_model.xlsx o=seti.inc
$include seti.inc
/
j plastic /
$call =xls2gms r=plastic!B2:B6 i=parameters_for_model.xlsx o=setj.inc
$include setj.inc
/
p product /
$call =xls2gms r=product!B2:B6 i=parameters_for_model.xlsx o=setp.inc
$include setp.inc
/
l plant location /
$call =xls2gms r=distance_lc!B3:B7 i=parameters_for_model.xlsx o=setl.inc
$include setl.inc
/
c customer /
$call =xls2gms r=demand!B3:B7 i=parameters_for_model.xlsx o=setc.inc
$include setc.inc
/
m month /1*12/
;

scalars
int      interest rate in % /0.08/
infl     rate of inflation in % /0.007/
y        investment lifetime in years /20/
Tcost    transportation cost £ per tn per km /0.31/
Whcost   cost of storing 1 tn of plastic £ per tn /1.4/
Wage     yearly wage of an engineering technician £ per year /22257/
s        share of investment returned as subsidies in % /0/
Pcost    operating costs £ per tn  /21.1/
main     share of investment to be spent on maintenance in %  /0.04/
;

parameters
Alab       labour cost
Inv        investments
Sub        subsidies
Dinb(i,l)  distance between a farm i and a plant l
Doutb(l,c) distance between plant l and customer c
Mpl(i,j)   mass of plastic j generated by farm i
Spl(j,m)   share of plastic j supplied by a farm in month m
Price(p)   price of product p
Conv(p)    conversion coefficient of plastic into product p
Cdisp(j)   cost of disposing 1 tn of plastic of j
Tdisp(j)   cost of transporting 1 tn of disposed plastic j from a farm
D(c,p)     demand of customer c for product p
Toutb(p)   cost of transporting 1 unit of product p
;


$call GDXXRW i=parameters_for_model.xlsx o=indata.gdx  par=Dinb rng=distance_il!B2:G39 rdim=1 cdim=1   par=Doutb rng=distance_lc!B2:G7 rdim=1 cdim=1  par=Spl rng=seasonality!B2:N7 rdim=1 cdim=1  par=Mpl rng=farms!B2:G39 rdim=1 cdim=1   par=D rng=demand!B2:G7 rdim=1 cdim=1   par=Price rng=product!B2:C6 rdim=1   par=Toutb rng=product!B2:B6,D2:D6 rdim=1   par=Conv rng=product!B2:B6,E2:E6 rdim=1   par=Cdisp rng=plastic!B2:C6, rdim=1   par=Tdisp rng=plastic!B2:B6,D2:D6 rdim=1

$GDXIN indata.gdx
$Load Dinb, Doutb, Spl, Mpl, D, Price, Toutb, Conv, Tdisp, Cdisp
$GDXIN

display Conv, Tdisp, Toutb;


parameters
Ainb         inbound transportation cost
Awh          warehousing cost
Aop          operating cost
Amain        maintenance cost
Aoutb        outbound transportation cost
Rprod        revenues from products
Rdisp        revenues from saving on plastic disposal (convenitional)
Df           discounting coefficient
Pmon(l,m)    monthly production - conversion of plastic in location l in month m
Sale(c,p)    sales to customer c of product p
Staff(l)     number of engineering technicians on the plant l
Whstock(m,l) amount of plastic left in the plant l at the end of month m
;


Df = [1-cvpower({1+(int-infl)/(1+infl)},(-y))]/(int-infl);

binary variables
Loc(i,l)   existing link between the farm i and the plant l
Cloc(l,c)  existing link between the plant l and the customer c
;

Positive variables
Cap(l)     capacity of plant l to covernt plastic;

Variables
Z;

equations
Inv1, Staff1(l), WH1(l), WH3(l), WH4(l), WH5(l), WH6(l), WH7(l), WH8(l), WH9(l), WH10(l), WH11(l), WH12(l), WH2(l), Maint, Pmon1(l), Pmon2(l), Pmon3(l), Pmon4(l), Pmon5(l), Pmon6(l), Pmon7(l), Pmon8(l), Pmon9(l), Pmon10(l), Pmon11(l), Pmon12(l), Sales1(c,p), Ainb1, Awh2, Aop3, Aoutb4, Rprod5, Rdisp6, profit, Sub8, Alab9, Link(i), Linkup(l), Linklow(l), Capacity, MassbalanceS, MassbalanceP(p), MassbalanceD(p);

Inv1.. Inv =e= 1000*(sum(l, [(1.8*Cap(l)+2527)$({Cap(l)>1600} and {Cap(l)<25550})]) + sum(l, [(3.3*Cap(l)+96)$(Cap(l)<1600)]) + sum(l, [(1.2*Cap(l)+6893)$(Cap(l)>25550)]));
Staff1(l).. Staff(l)$(sum(i, Loc(i,l))>0) =e= 0.001*Cap(l)+2.44;

Maint.. Amain =e= Inv * main ;

Pmon1(l).. Pmon(l,"1") =e= (sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"1")])$((sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"1")])<Cap(l))+Cap(l)$((sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"1")])>Cap(l));
WH1(l).. Whstock("1",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"1"))-Pmon(l,"1");
Pmon2(l).. Pmon(l,"2") =e= Cap(l)$({Whstock("1",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"2")]}>Cap(l))+(Whstock("1",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"2")])$({(Whstock("1",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"2")])>(0.25*Cap(l))} and {(Whstock("1",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"2")])<Cap(l)});
WH2(l).. Whstock("2",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"2"))+Whstock("1",l)-Pmon(l,"2");
Pmon3(l).. Pmon(l,"3") =e= Cap(l)$({Whstock("2",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"3")]}>Cap(l))+(Whstock("2",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"3")])$({(Whstock("2",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"3")])>(0.25*Cap(l))} and {(Whstock("2",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"3")])<Cap(l)});
WH3(l).. Whstock("3",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"3"))+Whstock("2",l)-Pmon(l,"3");
Pmon4(l).. Pmon(l,"4") =e= Cap(l)$({Whstock("3",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"4")]}>Cap(l))+(Whstock("3",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"4")])$({(Whstock("3",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"4")])>(0.25*Cap(l))} and {(Whstock("3",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"4")])<Cap(l)});
WH4(l).. Whstock("4",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"4"))+Whstock("3",l)-Pmon(l,"4");
Pmon5(l).. Pmon(l,"5") =e= Cap(l)$({Whstock("4",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"5")]}>Cap(l))+(Whstock("4",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"5")])$({(Whstock("4",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"5")])>(0.25*Cap(l))} and {(Whstock("4",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"5")])<Cap(l)});
WH5(l).. Whstock("5",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"5"))+Whstock("4",l)-Pmon(l,"5");
Pmon6(l).. Pmon(l,"6") =e= Cap(l)$({Whstock("5",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"6")]}>Cap(l))+(Whstock("5",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"6")])$({(Whstock("5",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"6")])>(0.25*Cap(l))} and {(Whstock("5",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"6")])<Cap(l)});
WH6(l).. Whstock("6",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"6"))+Whstock("5",l)-Pmon(l,"6");
Pmon7(l).. Pmon(l,"7") =e= Cap(l)$({Whstock("6",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"7")]}>Cap(l))+(Whstock("6",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"7")])$({(Whstock("6",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"7")])>(0.25*Cap(l))} and {(Whstock("6",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"7")])<Cap(l)});
WH7(l).. Whstock("7",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"7"))+Whstock("6",l)-Pmon(l,"7");
Pmon8(l).. Pmon(l,"8") =e= Cap(l)$({Whstock("7",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"8")]}>Cap(l))+(Whstock("7",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"8")])$({(Whstock("7",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"8")])>(0.25*Cap(l))} and {(Whstock("7",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"8")])<Cap(l)});
WH8(l).. Whstock("8",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"8"))+Whstock("7",l)-Pmon(l,"8");
Pmon9(l).. Pmon(l,"9") =e= Cap(l)$({Whstock("8",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"9")]}>Cap(l))+(Whstock("8",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"9")])$({(Whstock("8",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"9")])>(0.25*Cap(l))} and {(Whstock("8",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"9")])<Cap(l)});
WH9(l).. Whstock("9",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"9"))+Whstock("8",l)-Pmon(l,"9");
Pmon10(l).. Pmon(l,"10") =e= Cap(l)$({Whstock("9",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"10")]}>Cap(l))+(Whstock("9",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"10")])$({(Whstock("9",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"10")])>(0.25*Cap(l))} and {(Whstock("9",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"10")])<Cap(l)});
WH10(l).. Whstock("10",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"10"))+Whstock("9",l)-Pmon(l,"10");
Pmon11(l).. Pmon(l,"11") =e= Cap(l)$({Whstock("10",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"11")]}>Cap(l))+(Whstock("10",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"11")])$({(Whstock("10",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"11")])>(0.25*Cap(l))} and {(Whstock("10",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"11")])<Cap(l)});
WH11(l).. Whstock("11",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"11"))+Whstock("10",l)-Pmon(l,"11");
Pmon12(l).. Pmon(l,"12") =e= Cap(l)$({Whstock("11",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"12")]}>Cap(l))+(Whstock("11",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"12")])$((Whstock("11",l)+sum[(i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"12")])<Cap(l));
WH12(l).. Whstock("12",l) =e= sum((i,j), Mpl(i,j)*Loc(i,l)*Spl(j,"12"))+Whstock("11",l)-Pmon(l,"12");
Sales1(c,p).. Sale(c,p) =e= sum((l,j,m),Pmon(l,m)*Conv(p)*Cloc(l,c))$((sum((l,j,m),Pmon(l,m)*Conv(p)*Cloc(l,c)))<D(c,p))+D(c,p)$((sum((l,j,m),Pmon(l,m)*Conv(p)*Cloc(l,c)))>D(c,p));


Ainb1..  Ainb =e= sum((j,i,l), Dinb(i,l)*Tcost*Mpl(i,j)*Loc(i,l));
Awh2..   Awh =e= WHcost*sum((m,l), Whstock(m,l));
Aop3..   Aop =e= Pcost*sum((l,j,m), Pmon(l,m));
Aoutb4.. Aoutb =e= sum((l,c,p), Sale(c,p)*Toutb(p)*Doutb(l,c));
Rprod5.. Rprod =e= sum((i,j,l,p), Price(p)*Mpl(i,j)*Loc(i,l)*Conv(p));
Rdisp6.. Rdisp =e= sum((i,j), Mpl(i,j)*(Cdisp(j)+Tdisp(j)));
Sub8..   Sub =e= s*Inv;
Alab9..  Alab =e= Wage*sum(l, Staff(l));

Link(i)..    sum(l,Loc(i,l)) =e= 1;
Linkup(l)..  Cap(l)$((sum(i, Loc(i,l))>0)) =g= 200;
Linklow(l).. Cap(l)$((sum(i, Loc(i,l))>0)) =l= 25550;

Capacity..        10*sum(l, Cap(l)) =g= sum((i,j), Mpl(i,j));
MassbalanceS..    sum((i,j), Mpl(i,j)) =e= sum((l,m),Pmon(l,m));
MassbalanceP(p).. sum((l,m), Pmon(l,m)*Conv(p)) =e= sum(c, Sale(c,p));
MassbalanceD(p).. sum((i,j), Mpl(i,j)*Conv(p)) =l= sum((c,l), D(c,p)*Cloc(l,c));

profit.. Z =e= (Ainb + Awh + Amain + Aop + Alab + Aoutb)*Df + Inv - Sub - (Rprod + Rdisp)*Df;

model agriplastic /all/;
solve agriplastic using mip minimizing Z;
Agnessa
sandeep_mnit
User
User
Posts: 7
Joined: 7 years ago

Re: Error 66 - the symbol shown has not been defined or assigned (for objective function)

Post by sandeep_mnit »

Hi,

Hope your problem is solved. anyway here is the solution to your problem.

This error comes when (any) input parameter is not provided.
Just check all the input parameter is provided. You can use display command.
Post Reply