$TITLE TASK TWO *$offsymxref *$offlisting *$ifi %system.MIP% == cplex $goto cont *$ifi %system.MIP% == gurobi $goto cont *$exit *$label cont Sets y years in the planning horizon /1*20/ h hours in a year averaged over 30 days in a month /1*288/ eD Existing diesel generators /1*7/ l Number of segments of the piecewise linear function /1,2,3/ nD New diesel generators /1,2/ lim hourly operation and maintenace cost /low,high/; Alias(eD,De) Alias(nD,Dn) alias(h,h1) alias(y,y1) *---------------Existing Diesel Generator Data---------------------------------- Table ExDdata(*,*) data of existing diesel generators CapExD a b c GH Pglow Pgupp * kW L/hr/kw^2 L/hr/kw l/hr h KW KW 1 330 -0.0006 0.5212 -15 10000 153 330 2 330 -0.0006 0.5212 -15 10000 153 330 3 330 -0.0006 0.5212 -15 35339 153 330 4 330 -0.0006 0.5212 -15 35339 153 330 5 500 0.00003 0.2105 10.3 64696 280 500 6 540 0.00003 0.2144 10.3 10000 285 540 7 550 0.00003 0.2105 10.3 100000 280 550; *1 330 -0.0006 0.5212 -15 23559 175 330 *2 330 -0.0006 0.5212 -15 23559 175 330 *3 330 -0.0006 0.5212 -15 35339 175 330 *4 330 -0.0006 0.5212 -15 35339 175 330 *5 500 0.00003 0.2105 10.3 64696 280 500 *6 540 0.00003 0.2144 10.3 30191 270 540 *7 550 0.00003 0.2105 10.3 100000 270 550; Parameters MLExD(eD) Minimum loading of the existing diesel generator in percentage TExD(l,eD) Upper limit of block l and lower limit of block 2 of the piecewise linear fuel consumption funtion of the existing gen SLExD(l,eD) slope of each block in the piecewise linear fuel consumption funtion of the existing gen AExD(eD) Coefficient of the piecewise linearfuel consum ption function of existing diesel gen; SLExD('1','1') = 0.288; SLExD('2','1') = 0.271; SLExD('3','1') = 0.153; SLExD('1','2') = 0.288; SLExD('2','2') = 0.271; SLExD('3','2') = 0.153; SLExD('1','3') = 0.288; SLExD('2','3') = 0.271; SLExD('3','3') = 0.153; SLExD('1','4') = 0.288; SLExD('2','4') = 0.271; SLExD('3','4') = 0.153; SLExD('1','5') = 0.29; SLExD('2','5') = 0.244; SLExD('3','5') = 0.244; SLExD('1','6') = 0.235; SLExD('2','6') = 0.235; SLExD('3','6') = 0.294; SLExD('1','7') = 0.29; SLExD('2','7') = 0.244; SLExD('3','7') = 0.244; TExD('1','1') = 212; TExD('2','1') = 271; TExD('1','2') = 212; TExD('2','2') = 271; TExD('1','3') = 212; TExD('2','3') = 271; TExD('1','4') = 212; TExD('2','4') = 271; TExD('1','5') = 370; TExD('2','5') = 460; TExD('1','6') = 370; TExD('2','6') = 455; TExD('1','7') = 370; TExD('2','7') = 460; MLExD(eD) = 0.4; AExD(eD) = ExDdata(eD,"a")* ExDdata(eD,"Pglow")** 2 + ExDdata(eD,"b")* ExDdata(eD,"Pglow") + ExDdata(eD,"c"); Table HOMExD(eD,lim) Hourly O&M cost of existing diesel gens in $ per kWh low high 1 0.0218 0.0248 2 0.0218 0.0248 3 0.0218 0.0248 4 0.0218 0.0248 5 0.0218 0.0248 6 0.0218 0.0248 7 0.0218 0.0248 scalar Dcost desiel cost in $ per litre /1.3/ ToM minimum percentage a year a desiel gen must be off-line for maintenance /0.1/ Beta generation reserve margin in percentage /0.1/ d discount rate in percentage/0.08/; *---------------New diesel generator data--------------------------------------- Table Nddata(*,*) Capacities of existing diesel generators in kW UCapnD a b c Pglow Pgupp * KW L/hr/kw^2 L/hr/kw l/hr KW KW 1 320 -0.0002 0.3287 3 164 320 2 520 -0.00003 0.2227 10.3 265 520 Table UCnD(nD,lim) Unit cost of new desiel generators in $ per kW low high 1 727 738 2 727 738 Parameters SLnD(l,nD) slope of the block in the piecewise linear fuel consumption funtion of the new gen TnD(l,nD) Upper limit of block l and lower limit of block 2 of the piecewise linear fuel consumption funtion of the new gen HOMnD(nD) Hourly operation and maintenace cost of new desiel gen in $ per kWh MLnD(nD) Minimum loading of the new desiel generators in percentage GHL(nD) useful life of new desiel generators in hours AnewD(nD) Coefficient of the piecewise linearfuel consumption function of new diesel gen; HOMnD(nD) = 0.0191; MLnD(nD) = 0.4; GHL(nD) = 100000; TnD('1','1') = 216; TnD('2','1') = 268; TnD('1','2') = 350; TnD('2','2') = 435; SLnD('1','1') = 0.288; SLnD('2','1') = 0.250; SLnD('3','1') = 0.231; SLnD('1','2') = 0.259; SLnD('2','2') = 0.271; SLnD('3','2') = 0.271; AnewD(nD)= nDdata(nD,"a")* nDdata(nD,"pglow")** 2 + nDdata(nD,'b')* nDdata(nD,"pglow") + nDdata(nD,'c'); display Anewd; *---------------------------load data------------------------------------------- Parameter PD(y,h) Power demand in kW; $CALL GDXXRW i=ProjectDATA.xlsx o=projectdata.gdx par=PD rng=Load!B7:KD27 rdim=1 cdim=1 $GDXIN projectdata.gdx $Load PD $GDXIN Display PD; *---------------------------VARIABLES------------------------------------------- Variables obj NPC of operating existing equipment alongside purchase and operation of new diesel RE and storage *---------------Variables associted with existing desiel generator-------------- FconExD(eD,y,h) hourly fuel consumption of existing diesel gens in Litre per kWh UExD(eD,y,h) on and off state of the existing diesel generators PgExD(eD,y,h) power generated by existing diesel generators in kW SExD(l,eD,y,h) steps in the piecewise linear of the fuel consumption function of existing diesel *---------------Variables associated with the new diesel generator-------------- FconND(nD,y,h) hourly fuel consumption of new diesel gens. in Litre per kWh PgnD(nD,y,h) power generated by new diesel generators in kW UnD(nD,y,h) on and off state of the new diesel generators CapnD(nD,y,h) aggregate capacity of new diesel generators in kW NCAnD(nD,y,h) new capacity addition of diesel generatos in kW CCnD NPV of total cost of purchasing new diesel in $ OMCeD NPV of existing diesel O&M cost in $ OMCnD NPV of new diesel O&M cost in $ FCdsl NPV of total diesel fuel cost UnDPur(nD,y,h) purchase of new diesel generator CapuND(nD,y,h) dummy variable to linearize a product in kW SnD(l,nD,y,h) steps in the piecewise linear of the fuel consumption function of new diesel Positive variables PgExD,SExD,PgnD,CapnD,CapuND,test SnD,OMCeD,FconExD,FCdsl,xtotal,NCAnD,OMCnD,CCnD,FconND; Binary variable UExD,UnD,UnDPur, ungi(nd,y,h); Free variables obj; *ungi.fx(nd,y1,h1)$((ord(y1) lt 3)and(ord(y1) gt 10)) =0; PgExD.up(eD,y,h) = ExDdata(eD,"Pgupp"); PgnD.up(nD,y,h) = Nddata(nD,"Pgupp"); *PgnD.fx(nD,y,h)= 0 $(ord(y)le 3); *-------------Stand-by mode operation of existing diesel generator-------------- PgExD.fx('3','1',h)= 0; PgExD.fx('4','1',h)= 0; PgExD.fx('5','1',h)= 0; PgExD.fx('6','1',h)= 0; PgExD.fx('1','2',h)= 0; PgExD.fx('2','2',h)= 0; PgExD.fx('7','2',h)= 0; PgExD.fx('3','3',h)= 0; PgExD.fx('4','3',h)= 0; PgExD.fx('5','3',h)= 0; PgExD.fx('6','3',h)= 0; PgExD.fx('1','4',h)= 0; PgExD.fx('2','4',h)= 0; PgExD.fx('7','4',h)= 0; PgExD.fx('3','5',h)= 0; PgExD.fx('4','5',h)= 0; PgExD.fx('5','5',h)= 0; PgExD.fx('6','5',h)= 0; PgExD.fx('1','6',h)= 0; PgExD.fx('2','6',h)= 0; PgExD.fx('7','6',h)= 0; PgExD.fx('3','7',h)= 0; PgExD.fx('4','7',h)= 0; PgExD.fx('5','7',h)= 0; PgExD.fx('6','7',h)= 0; PgExD.fx('1','8',h)= 0; PgExD.fx('2','8',h)= 0; PgExD.fx('7','8',h)= 0; PgExD.fx('3','9',h)= 0; PgExD.fx('4','9',h)= 0; PgExD.fx('5','9',h)= 0; PgExD.fx('6','9',h)= 0; PgExD.fx('1','10',h)= 0; PgExD.fx('2','10',h)= 0; PgExD.fx('7','10',h)= 0; PgExD.fx('3','11',h)= 0; PgExD.fx('4','11',h)= 0; PgExD.fx('5','11',h)= 0; PgExD.fx('6','11',h)= 0; PgExD.fx('1','12',h)= 0; PgExD.fx('2','12',h)= 0; PgExD.fx('7','12',h)= 0; PgExD.fx('3','13',h)= 0; PgExD.fx('4','13',h)= 0; PgExD.fx('5','13',h)= 0; PgExD.fx('6','13',h)= 0; PgExD.fx('1','14',h)= 0; PgExD.fx('2','14',h)= 0; PgExD.fx('7','14',h)= 0; PgExD.fx('3','15',h)= 0; PgExD.fx('4','15',h)= 0; PgExD.fx('5','15',h)= 0; PgExD.fx('6','15',h)= 0; PgExD.fx('1','16',h)= 0; PgExD.fx('2','16',h)= 0; PgExD.fx('7','16',h)= 0; PgExD.fx('3','17',h)= 0; PgExD.fx('4','17',h)= 0; PgExD.fx('5','17',h)= 0; PgExD.fx('6','17',h)= 0; PgExD.fx('1','18',h)= 0; PgExD.fx('2','18',h)= 0; PgExD.fx('7','18',h)= 0; PgExD.fx('3','19',h)= 0; PgExD.fx('4','19',h)= 0; PgExD.fx('5','19',h)= 0; PgExD.fx('6','19',h)= 0; PgExD.fx('1','20',h)= 0; PgExD.fx('2','20',h)= 0; PgExD.fx('7','20',h)= 0; *CapnD.fx(nD,'1','1') = 0; UnDPur.fx(nD,y,h)$((ord(y)lt 3)and(ord(y) gt 10))= 0 ; *PD(y,h)$(ord(y) ge 3)=1.15*PD(y,h) ; Equations TotalCost the net present cost-objective function FuelcostDsl fuel cost of the diesel generators OMcostD1 O&M cost of existing diesel generators OMcostD2 O&M cost of new diesel generators ExDFcon(eD,y,h) fuel consumption of existing diesel generator nDFcon(nD,y,h) fuel consumption of new diesel generators CcostnD cost of new diesel generator *--------------------------------constraints------------------------------------ DemCons1(y,h) supply-demand balance Adqlim1(y,h) generation adequancy limit DemCons2(y,h) supply-demand balance Adqlim2(y,h) generation adequancy limit *----------------------Dynamic addition of new capacity------------------------- NewDsl(nD,y,h) new diesel capacity addition *NewDsl1(nD,y,h) ComND(nD,y,h) Commissioning of new diesel *ComND1(nD,y,h) *----------------sequencialize hour and year indices---------------------------- SComND(nD,y,h) Commissioning of new diesel with hour and year sequentialized *SComND1(nD,y,h) *----------------------Diesel generator limits---------------------------------- PgMaxND maximum power generation limit from new diesel generators *--linearization of the non-linear product of continous and binary variables---- PgmaxNd1(nD,y,h) pgmaxNd2(nD,y,h) PgmaxNd3(nD,y,h) PgmaxNd4(nD,y,h) PgminNd(nD,y,h) minimum power generation limit from new diesel generators PgmaxExD(eD,y,h) maximum power generation limit from existing diesel generators PgminExd(eD,y,h) minimum power generation limit from existing diesel generators *---------------------------Diesel generator Life------------------------------- Step1ExD(l,eD,y,h) Step2ExD(l,eD,y,h) Step3ExD(l,eD,y,h) step4ExD(l,eD,y,h) stepExD(eD,y,h) Power produced in block l of the piecewise linear fuel consumption function of existing diesel gen Step1nD(l,nD,y,h) Step2nD(l,nD,y,h) Step3nD(l,nD,y,h) step4nD(l,nD,y,h) stepnD(nd,y,h) Power produced in block l of the piecewise linear fuel consumption function of new diesel gen *---------------------------Diesel generator Life------------------------------- ExDlife(eD) Ndlife(nD) *-----------------------annual O&M Time Availability---------------------------- ExDconst(eD,y) Existing diesel operation and maintenace time nDconst(nD,y) New diesel operation and maintenace time; NewDsl(nD,y,h).. Nddata(nD,"UcapnD")* UnDPur(nD,y,h) =E= NCAnD(nD,y,h); *NewDsl1(nD,y,h)$((ord(y) Lt 3) and (ord(y) gt 10)).. NCAnD(nD,y,h) =e= 0; ComND(nD,y,h)..CapnD(nD,y,h) + NCAnD(nD,y,h) =E= CapnD(nD,y,h+1); **ComND(nD,y,h)$(ord(h) le 287).. CapnD(nD,y,h+1) =e= CapnD(nD,y,h)+ Nddata(nD,"UcapnD")*ungi(nd,y,h); **ComND(nD,y,h).. CapnD(nD,y,h) =e= sum(y1$(ord(y1) le ord(y)), sum(h1$(ord(h1) le ord(h)), Nddata(nD,"UcapnD")*ungi(nd,y1,h1))); *ComND1(nD,y,h)$(ord(h) le 287).. CapnD(nD,y,h+1) =e= CapnD(nD,y,h)+ NCAnD(nD,y,h ); *ComND1(nD,y,h)$((ord(y) gt 10) and (ord(h) le 287))..CapnD(nD,y,h+1)=e=0; SComND(nD,y,h)..CapnD(nD,y,'288') + NCAnD(nD,y,'288') =E= CapnD(nD,y+1,'1') $ ((ord(y) ge 3) and (ord(y)lt 20)); *SComND(nD,y,h) $ (ord(y)le 4).. CapnD(nD,y+1,'1') =e= CapnD(nD,y,h)+ NCAnD(nD,y,h); *SComND1(nD,y,h) $ (ord(y)gt 4).. CapnD(nD,y+1,'1') =e= 0; PgMaxND(nD,y,h).. CapUnD(nD,y,h) =G= PgnD(nD,y,h); *PgMaxNDtest(nD,y,h).. PgnD(nD,y,h) =L= UnD(nD,y,h)*100000; PgmaxNd1(nD,y,h)..5*(Nddata(nD,"UcapnD")*UnD(nD,y,h)) =G= CapuND(nD,y,h) ; pgmaxNd2(nD,y,h)..CapnD(nD,y,h) =G= CapuND(nD,y,h); PgmaxNd3(nD,y,h)..CapnD(nD,y,h)-5*(Nddata(nD,"UcapnD"))*(1-UnD(nD,y,h)) =L= CapuND(nD,y,h); PgmaxNd4(nD,y,h).. CapuND(nD,y,h) =G= 0; PgminnD(nD,y,h).. MLnD(nD)*CapuND(nD,y,h) =L= PgnD(nD,y,h); PgmaxExD(eD,y,h)..ExDdata(eD,'CapExD')*UExD(eD,y,h) =G= PgExD(eD,y,h); PgminExd(eD,y,h)..MLExD(eD)*ExDdata(eD,'CapExD')*UExD(eD,y,h) =L= PgExD(eD,y,h); Ndlife(nD).. Sum(y,sum(h,(30*UnD(nD,y,h)))) =L= GHL(nD); ExDlife(eD).. Sum(y,sum(h,(30*UExD(eD,y,h))))=L=ExDdata(eD,'GH'); ExDconst(eD,y).. sum(h,UExD(eD,y,h))=L= 288*(1-TOM); nDconst(nD,y).. sum(h,UnD(nD,y,h))=L= 288*(1-TOM); *OMcostD.. OMCD =e= sum(y,(sum(h,30*((sum((eD,lim),(HOMExD(eD,lim)*PgExD(eD,y,h))))+(sum(nD,(HOMnD(nD)*PgnD(nD,y,h)))))))/(power((1+d),(ord(y))-1))); OMcostD1..sum(y,(sum(h,30*((sum((eD,lim),(HOMExD(eD,lim)*PgExD(eD,y,h)))))))/(power((1+d),(ord(y))-1)))=E= OMCeD; OMcostD2..sum(y,(sum(h,30*(sum(nD,(HOMnD(nD)*PgnD(nD,y,h))))))/(power((1+d),(ord(y))-1)))=E= OMCnD; CcostnD..sum(y,((sum((nD),UCnD(nD,'low') * (sum(h, NCAnD(nD,y,h)))))/((1+d)**(ord(y)-1)))) =E= CCnD; *CcostnD..sum(y,((sum((nD),UCnD(nD,'low')*(sum(h,NCAnD(nD,y,h)))))))/((1+d)**(ord(y)-1)))) =E= CCnD; DemCons1(y,h)$(ord(y) lt 3).. sum(eD, PgExD(eD,y,h)) =g= PD(y,h); DemCons2(y,h)$(ord(y) ge 3).. sum(eD, PgExD(eD,y,h)) + sum(nD,PgnD(nD,y,h)) =g= PD(y,h); Adqlim1(y,h)$(ord(y) lt 3).. sum(eD,(ExDdata(eD,'CapExD')* UExD(eD,y,h))) =G= (1+Beta)* PD(y,h); Adqlim2(y,h)$(ord(y) ge 3).. sum(eD,(ExDdata(eD,'CapExD')* UExD(eD,y,h)))+ sum(nD,CapnD(nD,y,h)) =G= (1+Beta)* PD(y,h); *Adqlim(y,h).. (1+Beta)*PD(y,h) =l= sum(eD,(ExDdata(eD,'CapExD')* UExD(eD,y,h)))+ sum(nD,(Nddata(nD,"UcapnD")*UnD(nD,y,h))); *step1ExD(l,eD,y,h)$(ord(l) eq 1)..TExD('1',eD) - MLExD(eD)*ExDdata(eD,'CapExD') =G= SExD('1',eD,y,h); step1ExD(l,eD,y,h)$(ord(l) eq 1)..TExD('1',eD) - ExDdata(eD,"Pglow") =G= SExD('1',eD,y,h); Step2ExD(l,eD,y,h)$(ord(l) eq 2).. TExD('2',eD) - TExD('1',eD) =G= SExD('2',eD,y,h); step3ExD(l,eD,y,h)$(ord(l) eq 3).. ExDdata(eD,"Pgupp") - TExD('2',eD) =G= SExD('3',eD,y,h); stepExD(eD,y,h)..sum(l, SExD(l,eD,y,h)) + ExDdata(eD,"Pglow")* UExD(eD,y,h) =E= PgExd(eD,y,h); *stepExD(eD,y,h)..sum(l, SExD(l,eD,y,h)) + (MLExD(eD)*ExDdata(eD,'CapExD'))* UExD(eD,y,h) =E= PgExd(eD,y,h); step4ExD(l,eD,y,h)..SExD(l,eD,y,h) =g= 0; ExDFcon(eD,y,h)..AExD(eD)*UExD(eD,y,h)+ sum(l,(SLExD(l,eD)* SExD(l,eD,y,h))) =E= FconExD(eD,y,h); step1nD(l,nD,y,h)$(ord(l) eq 1).. TnD('1',nD) - NDdata(nD,"Pglow") =G= SnD('1',nD,y,h); *step1nD(l,nD,y,h)$(ord(l) eq 1).. (TnD('1',nD) - MLnD(nD))* CapuND(nD,y,h) =G= SnD('1',nD,y,h); step2nD(l,nD,y,h)$(ord(l) eq 2).. TnD('2',nD) - TnD('1',nD) =G= SnD('2',nD,y,h); step3nD(l,nD,y,h)$(ord(l) eq 3).. NDdata(nD,"Pgupp") - TnD('2',nD) =G= SnD('3',nD,y,h); *step3nD(l,nD,y,h)$(ord(l) eq 3).. Nddata(nD,"UcapnD") - TnD('2',nD) =G= SnD('3',nD,y,h); stepnD(nd,y,h).. PgnD(nd,y,h)=e= sum(l, SnD(l,nD,y,h)) + NDdata(nD,"Pglow")* UnD(nD,y,h); step4nD(l,nD,y,h).. SnD(l,nD,y,h) =G= 0; nDFcon(nD,y,h)..sum(l,(SLnD(l,nD)*SnD(l,nD,y,h))) + AnewD(nD)*UnD(nD,y,h) =E= FconND(nD,y,h); FuelcostDsl..sum(y,((Dcost)*sum(h,30*((sum(eD,FconExD(eD,y,h)))+(sum(Dn,FconnD(Dn,y,h)))))/power((1+d),(ord(y))-1))) =E= FCdsl; TotalCost..CCnD + OMCeD + OMCnD+ FCdsl =E= obj; model Project1 / NewDsl ComND SComND PgMaxND PgmaxNd1 pgmaxNd2 PgmaxNd3 PgmaxNd4 PgminnD PgmaxExD PgminExd Ndlife nDconst CcostnD step1nD step2nD step3nD step4nD stepnD nDFcon OMcostD1 OMcostD2 ExDlife ExDconst DemCons1 DemCons2 Adqlim1 Adqlim2 step1ExD step2ExD step3ExD step4ExD stepExD ExDFcon FuelcostDsl TotalCost /; option limrow = 1e9; option limcol=1e9; option mip = cplex; option reslim = 30000; project1.optCR = 0.25; solve Project1 using mip minimizing obj; display CCnD.L,OMCeD.L,OMCnD.L,FCdsl.L,obj.L,PgnD.L,PgExD.L,UnDPur.L;