$ontext this codes will read the data from the excel file "OneDay" and will calculate the optimization values for 24 hours (this code will only be used once in the whole cycle). The Three output variables from this code that will be used as input to the following code (Dis_h1) are: PP, Mn, Mx Please note that they are converted into parameters in the (Dis_h1) code and used as parameter inputs $offtext sets h number of hours/1*24/ N sources/1*100/ T total number of time intervals (to read all relevant data for RegPerc) /1*21600/ r /1/; Scalar Ef Efficiency/0.9/, Beta /0.05 /, N_N Total Number of sources/100/, phi coefficient /0.01/, si coefficient /0.9/, eta coefficient /0.3/; alias(i,h); *Option ResLim = 30000; Parameter DEP(N,h) Probability, Adep(N,h) Accumulated Probability, En(N,h) Energy consumed, SOI(N,r), MP(N,r), Mci(N,r), Mt(N,r), Et(N,r), FP(h,r), Pup(h,r), Pdw(h,r), ExU(h,r), ExD(h,r), Av(N,h) Availability Coefficient, EPer(r,h), RegPerc(T,r), Comp(N,h); $CALL GDXXRW OneDay.xlsx par=FP rng=FP!A1:B25 par=Pup rng=Pup!A1:B25 par=Pdw rng=Pdw!A1:B25 par=SOI rng=SOI!A1:B101 par=MP rng=MPd!A1:B101 par=Mci rng=Mci!A1:B101 par=Mt rng=Mt!A1:B101 par=Et rng=Et!A1:B101 par=En rng=En!A1:Y101 par=Av rng=Av!A1:Y101 par=ExU rng=ExU!A1:B25 par=ExD rng=ExD!A1:B25 par=RegPerc rng=RegPerc!A1:B43201 par=DEP rng=DEP!A1:Y101 $GDXIN OneDay.gdx $LOAD FP Pup Pdw SOI MP Mci Mt Et En Av ExD ExU RegPerc DEP $GDXIN Variables SO(N,h), Income(h,r) daily income, Cost(h,r) daily cost, Daily_profit; Positive Variables PP(N,h), Mx(N,h), Mn(N,h); Equations Income_e,Cost_e,Daily_profit_e,C_0,C_1,C_2,C_3,C_4,C_5,C_6,C_7,C_8a,C_8b,C_9,C_10,C_11; Comp(N,h)=1/(1-DEP(N,h)); Adep(N,h)$(ord(h)< Mt(N,'1'))=sum(i$[ord(i)<= ord(h)],DEP(N,i)); Adep(N,h)$(ord(h)>= Et(N,'1'))=sum(i$[Et(N,'1') <= ord(h) and ord(i)<= ord(h)],DEP(N,i)) ; Adep(N,h)$(ord(h)>= Mt(N,'1') and ord(h) < Et(N,'1') )=sum(i$[Mt(N,'1') <= ord(h) and ord(i)<= ord(h)],DEP(N,i)); EPer('1',h)=1-((1/N_N)*sum(N,Adep(N,h))); EPer('1','22')=1; EPer('1','23')=1; EPer('1','24')=1; Income_e(h,r).. Income(h,r)=E=EPer(r,h)*((Pup(h,r)*0.001*sum(N,Mn(N,h))+Pdw(h,r)*0.001*sum(N,Mx(N,h))) + Beta*sum(N,(Av(N,h)*((Mx(N,h)*ExD(h,r) + PP(N,h) - Mn(N,h)*ExU(h,r)))))); Cost_e(h,r).. Cost(h,r)=E=EPer(r,h)*0.001*FP(h,r)*(sum(N,Av(N,h)*(Mx(N,h)*ExD(h,r)+PP(N,h)- Mn(N,h)*ExU(h,r)))); Daily_profit_e.. Daily_profit=E=sum(h,Income(h,'1')-Cost(h,'1')); C_0(N,h).. SO(N,h)=E=eta*Mci(N,'1')$(ord(h)=1)+SO(N,h-1)$(ord(h)>1)+(Av(N,h)*(Mx(N,h)*ExD(h,'1') + PP(N,h) - Mn(N,h)*ExU(h,'1'))*Comp(N,h)*Ef)-En(N,h); C_1(N,h).. SO(N,h)=L=Mci(N,'1'); C_2(N,h)$(ord(h)<24).. SO(N,h)=G=phi*Mci(N,'1') ; C_3(N,h)$(ord(h)=24).. SO(N,h)=G=si*Mci(N,'1') ; C_4(N,h).. (PP(N,h)+Mx(N,h))*Comp(N,h)*Ef=L=Mci(N,'1')-(SO(N,h-1)$(ord(h)>1))-(eta*Mci(N,'1')$(ord(h)=1)); C_5(N,h).. (PP(N,h)-Mn(N,h))*Comp(N,h)*Ef+(SO(N,h-1)$(ord(h)>1))+(eta*Mci(N,'1')$(ord(h)=1))=G=En(N,h); C_6(N,h).. (PP(N,h)+Mx(N,h))*Comp(N,h)=L=Av(N,h)*MP(N,'1'); C_7(N,h).. PP(N,h)-Mn(N,h)=G=0; C_8a(N,h).. Mx(N,h)=G=0; C_8b(N,h).. Mn(N,h)=G=0; C_9(N,h).. PP(N,h)=G=0; C_10(N,h)$(Av(N,h)=1).. (SO(N,h)-(SO(N,h-1)$(ord(h)>1))-(eta*Mci(N,'1')$(ord(h)=1)))=L=Av(N,h)*MP(N,'1')*Ef; C_11(N,h)$(Av(N,h)=1).. (SO(N,h)-(SO(N,h-1)$(ord(h)>1))-(eta*Mci(N,'1')$(ord(h)=1)))=G=-Av(N,h)*MP(N,'1')*Ef; Model optimization /all/ ; Solve optimization using lp maximizing Daily_profit; Parameter PPPar(N,h), MnPar(N,h), MxPar(N,h); PPPar(N,h) = PP.l(N,h); MnPar(N,h) = Mn.l(N,h); MxPar(N,h) = Mx.l(N,h); execute_unload 'outopt1h.gdx',PPPar=PP, MnPar=Mn, MxPar=Mx, MP, Mci, En, Av, RegPerc;