Question related to "Electrical Power Generation 2"
回答済みHow can I implement this example with hydro plants having peak-time hours (the time in which the cost of the electricity is more than normal time) and with load shedding(the time when electricity from hydro plants is not available). Help will be appreciated.
I added two more variables
Regards
-
How can I implement this example with hydro plants having peak-time hours (the time in which the cost of the electricity is more than normal time) and with load shedding(the time when electricity from hydro plants is not available).
Could you please clarify which example you mean?
0 -
I want to change add constraints for hydro plants, I need to add peak-time cost for hydro plants which means how can I add variable cost at certain time for hydro plants and how can I also add load-shedding constraint for hydro plants load shedding means when the hydro power is not available, so other resources must be used for this.
I have added
hydro_shedding = [1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,0,1,0,1,1]for next 24 hour period when the hydro power will be available and when will it not be available.0 -
#this is the changed code# Parameters#Solar panelssp = 1sps = [6]min_load = [1]max_load = [30]base_cost = [1]per_mw_cost = [0.1]startup_cost = [1]#batteriesbt = 1bts = [3]min_load = [15]max_load = [100]base_cost = [2]per_mw_cost = [0.1]startup_cost = [2]#timenperiods = 24maxstart0 = 5period_hours = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]demand = [870,770,670,470,570,670,770,870,970,370,370,570,670,770,870,970,770,460,570,470,607,370,370,570]#hydrohydrounits = 1hydro_avail = 0hydro_shedding = [1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,0,1,0,1,1]hydro_load = [900]hydro_cost = [90]hydro_startup_cost = [1500]model = gp.Model('PowerGeneration2')
ngen1 = model.addVars(sp, nperiods, vtype=GRB.INTEGER, name="ngen1")nstart1 = model.addVars(sp, nperiods, vtype=GRB.INTEGER, name="nstart1")output1 = model.addVars(sp, nperiods, vtype=GRB.CONTINUOUS, name="genoutput1")
ngen2 = model.addVars(bt, nperiods, vtype=GRB.INTEGER, name="ngen2")nstart2 = model.addVars(bt, nperiods, vtype=GRB.INTEGER, name="nstart2")output2 = model.addVars(bt, nperiods, vtype=GRB.CONTINUOUS, name="genoutput2")
hydro = model.addVars(hydrounits, nperiods, vtype=GRB.BINARY, name="hydro")hydrostart = model.addVars(hydrounits, nperiods, vtype=GRB.BINARY, name="hydrostart")hydro_ls = model.addVars(hydrounits,hydro_avail, vtype=GRB.BINARY, name="hydro_ls")# solar panels and batteries count
numgen1 = model.addConstrs(ngen1[type, period] <= sps[type]for type in range(sp) for period in range(nperiods))numgen2 = model.addConstrs(ngen2[type, period] <= bts[type]for type in range(bt) for period in range(nperiods))
# Respect minimum and maximum output per sp type
min_output1 = model.addConstrs((output1[type, period] >= min_load[type] * ngen1[type, period])for type in range(sp) for period in range(nperiods))
max_output1 = model.addConstrs((output1[type, period] <= max_load[type] * ngen1[type, period])for type in range(sp) for period in range(nperiods))
# Respect minimum and maximum output per bt type
min_output2 = model.addConstrs((output2[type, period] >= min_load[type] * ngen2[type, period])for type in range(bt) for period in range(nperiods))
max_output2 = model.addConstrs((output2[type, period] <= max_load[type] * ngen2[type, period])for type in range(bt) for period in range(nperiods))# Meet demand
meet_demand = model.addConstrs(gp.quicksum(output1[type, period] for type in range(sp)) +gp.quicksum(output2[type, period] for type in range(bt)) +gp.quicksum(hydro_load[unit]*hydro[unit,period] for unit in range(hydrounits))>= demand[period]for period in range(nperiods))# Startup constraint
startup0 = model.addConstrs((ngen1[type,0] <= maxstart0 + nstart1[type,0])for type in range(sp))
startup1 = model.addConstrs((ngen1[type,period] <= ngen1[type,period-1] + nstart1[type,period])for type in range(sp) for period in range(1,nperiods))
# Startup constraint
startup2 = model.addConstrs((ngen2[type,0] <= maxstart0 + nstart2[type,0])for type in range(bt))
startup3 = model.addConstrs((ngen2[type,period] <= ngen2[type,period-1] + nstart2[type,period])for type in range(bt) for period in range(1,nperiods))# Hydro startup constraint
hydro_startup0 = model.addConstrs((hydro[unit,0] <= hydrostart[unit,0])for unit in range(hydrounits))
hydro_startup = model.addConstrs((hydro[unit,period] <= hydro[unit,period-1] + hydrostart[unit,period])for unit in range(hydrounits) for period in range(1,nperiods))
# Objective: minimize total cost
active1 = gp.quicksum(base_cost[type]*period_hours[period]*ngen1[type,period]for type in range(sp) for period in range(nperiods))
per_mw1 = gp.quicksum(per_mw_cost[type]*period_hours[period]*(output1[type,period] - min_load[type]*ngen1[type,period])for type in range(sp) for period in range(nperiods))
startup_obj1 = gp.quicksum(startup_cost[type]*nstart1[type,period]for type in range(sp) for period in range(nperiods))
active2 = gp.quicksum(base_cost[type]*period_hours[period]*ngen2[type,period]for type in range(bt) for period in range(nperiods))
per_mw2 = gp.quicksum(per_mw_cost[type]*period_hours[period]*(output2[type,period] - min_load[type]*ngen2[type,period])for type in range(bt) for period in range(nperiods))
startup_obj2 = gp.quicksum(startup_cost[type]*nstart2[type,period]for type in range(bt) for period in range(nperiods))
hydro_active = gp.quicksum(hydro_cost[unit]*period_hours[period]*hydro[unit,period]*hydro_shedding[period]for unit in range(hydrounits) for period in range(nperiods))
hydro_startup = gp.quicksum(hydro_startup_cost[unit]*hydrostart[unit,period]for unit in range(hydrounits) for period in range(nperiods))
model.setObjective(active1 + per_mw1 + startup_obj1 + active2 + per_mw2 + startup_obj2 + hydro_active + hydro_startup)model.optimize()rows = ["solar" + str(t) for t in range(sp)]units = pd.DataFrame(columns=range(nperiods), index=rows, data=0.0)
for t in range(sp):for p in range(nperiods):units.loc["solar"+str(t), p] = ngen1[t,p].xunitsrows = ["batteries" + str(t) for t in range(sp)]units = pd.DataFrame(columns=range(nperiods), index=rows, data=0.0)
for t in range(sp):for p in range(nperiods):units.loc["batteries"+str(t), p] = ngen2[t,p].xunitsrows = ["HydroA"]hydrotable = pd.DataFrame(columns=range(nperiods), index=rows, data=0.0)
for p in range(nperiods):hydrotable.loc["HydroA", p] = int(hydro[0,p].x)hydrotable0 -
It is quite hard to help here without any knowledge about hydro plants.
I think what you might want to consider is to use a time index for your variables, e.g., 1 for each hour of the day. You can then say that variable \(x_t\), i.e., variable at time \(t\) has to fulfill some constraint. Please note that adding a time index can increase the size of the model by a drastic amount, especially if you want to optimize over a longer time horizon. In this case, it might make sense to use a time index for every 4 hours (or similar).
You could add a hydrodown variable which would work similar to your hydrostart variable. This variable would be set to 1 if the hydroplant is not available at a given time index.
0 -
Ok thanks I will look into this
0
サインインしてコメントを残してください。
コメント
5件のコメント