Hi, I want to know the price and total cost assuming there are three scenarios regarding the wind realization.
I can run my code and get the result, but it shows:
**** Dimension error for : generation
**** Dimension error for : price
**** Dimension error for : startup
Could you please check my code and tell me what to do? Thank you very much.
My code is:
##################### Declaring Sets #################################
Sets
i set of conventional generation technologies
r set of RES generation technologies /Wind, PV/
t set of hours /18760/
s set of wind scenarios /s1, s2, s3/
*the scenarios for wind powert generation should be used to implement an uncertain wind-feed-in
;
*##################### Declaring Parameters #############################
Parameters
vc(i) unit cost (� per MWh)
sc(i) startup costs (� per MW)
cap(i) installed capacity for each technology i
cap_RES(r) installed capacity for each RES technology r
pf(t,s,r) hourly production factor for RES
af(i) availability factor for conv. technologies
demand(t) electricity demand
g_min(i) minimum generation
RESup upload of hourly production factors for wind and PV
techup technology upload
**************** Implement investment and uncertainty parameters ***********************************
ic(i) annual investment costs
cap_max(i) maximum capacity for technology i
;
*####################### Upload from Excel Excel ##############################
*1.Create Text File which includes the information where which parameter is to find
$onecho > ImportInfo.txt
set=i Rng=Technology!A2 Cdim=0 Rdim=1
Par=techup Rng=Technology!A1 Cdim=1 Rdim=1
Par=RESup Rng=RES!A1 Cdim=2 Rdim=1
Par=demand Rng=Demand!A2 Cdim=0 Rdim=1
$offecho
*2.Convert Excel File to a .gdx file
$call GDXXRW I=Input_SW.xlsx O=Output.gdx @ImportInfo.txt
*3.Read the elements
$gdxin Output.gdx
$Load i
$Load techup, RESup, demand
$gdxin
*Define parameters from the upload-parameter ‘techup’
vc(i)=techup(i,‘vc’) ;
sc(i)=techup(i,‘sc’) ;
g_min(i)=techup(i,‘g_min’) ;
cap(i)=techup(i,‘cap_max’) ;
af(i)=techup(i,‘af’);
pf(t,s,r)=RESup(t,s,r);
*Define renewable parameters
cap_RES(‘wind’) = 61474;
cap_RES(‘pv’) = 51479;
**************** Declare investment and uncertainty parameters ********************
ic(i)=techup(i,‘annual investment costs’)
;
*Display data to see that everything is uploaded correctly
Display i, t, vc, sc, g_min, cap, af, demand, pf, cap_RES, RESup, ic, s;
$stop
$stop
$stop
*##################### Declaring Variables #############################
Variable
COST total cost of electricity production
;
Positive Variables
**************** apply uncertainty to existing variables*******************************
G(s,i,t) generation of technology i at time t under wind scenarios s
G_RES(s,r,t) generation of RES technology r at time t under wind scenarios s
P_ON(s,i,t) online capacity of technology i at time t under wind scenarios s
SU(s,i,t) start up variable under wind scenarios s
**************** Implement investment variables *******************************
iv(i) investment capacity of technology i under wind scenarios s
;
*##################### Declaring Equations #############################
Equations
obj minimizing total costs
res_dem energy balance (supplly=demand)
res_G_RES maximum for RES generation depends on hourly pf anc cap_RES
res_start startup restriction
res_min_gen minimum generation
res_max_gen maximum generation
res_max_online maximum online restriction
*************** Implement investment equation *
\
res_max_Cap maximum capacity
;
obj… COST =E=(1/3)*SUM((s,i,t), vc(i)*G(s,i,t)+sc(i)*SU(s,i,t)+iv(i)*ic(i))
;
res_dem(s,t)… SUM(i, G(s,i,t)) + SUM(r,G_RES(s,r,t)) =E= demand(t)
;
res_G_RES(r,t,s)… G_RES(s,r,t) =L= cap_RES(r)*pf(t,s,r)
;
res_start(s,i,t)… SU(s,i,t) =G= P_ON(s,i,t)-P_ON(s,i,t-1)
;
res_min_gen(s,i,t)… P_ON(s,i,t)*g_min(i) =L= G(s,i,t)
;
res_max_gen(s,i,t)… G(s,i,t) =L= P_ON(s,i,t)
;
res_max_online(s,i,t)… P_ON(s,i,t) =L= cap(i)*af(i)
;
*************** Declate investment equation and adapt previous *******************************
res_max_Cap(i)… iv(i) =L= cap(i)
;
- ######################### Solving the Model ##############################
model PSE
/all/
;
solve PSE using LP minimizing COST
;
- ######################### Reporting ######################################
Declaring Report Parameters
parameter
generation(s,t,,i)
price(t,,s)
startup(s,i,t)
modelstats()
solvestats()
;
generation(s,t,‘no_uncertainty’,i) = G.L(s,i,t) ;
price(t,‘no_uncertainty’,s) = res_dem.M(t,s) ;
- Marginal of Energy Balance gives the price (Shadow variable of the energy balance)
startup(s,t,‘no_uncertainty’,i) = SU.L(s,i,t) ;
modelstats(‘no_uncertainty’) = PSE.modelstat ;
solvestats(‘no_uncertainty’) = PSE.modelstat ;
display generation, price, startup, modelstats, solvestats ;
- or: sometimes it is enough to just display the results in GAMS.
- e.g.:
display G.L, P_ON.L, res_dem.M ;
*################################# Excel Export ###############################
*1. Create Text file which includes the information where which parameter is to put
$onecho >out.tmp
Par=generation Rng=generation!A2 Cdim=2 Rdim=1
Par=price Rng=Price!A2 Cdim=1 Rdim=1
Par=startup Rng=StartUp!B2 Cdim=1 Rdim=2
Par=modelstats Rng=Stats!B2 Cdim=0 Rdim=1
Par=solvestats Rng=Stats!E2 Cdim=0 Rdim=1
$offecho
*2. Put the data in a .gdx file
execute_unload ‘Results.gdx’
;
*3.Convert the .gdx file to an excel file
execute ‘gdxxrw Results.gdx o=Results.xlsx @out.tmp’
Top
1 Post • Page 1 Of 1
Return To “Syntax”