Skip to content

Commit

Permalink
[fix bug] 01. scale withdraw benefits; 02. add generation flow upper …
Browse files Browse the repository at this point in the history
…limit of hydropower plant
  • Loading branch information
github-actions[bot] committed Sep 18, 2024
1 parent 2cdffb7 commit 3b9e5d5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
6 changes: 4 additions & 2 deletions prepshot/_model/cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,15 @@ def income_rule(self) -> poi.ExprBuilder:
model = self.model
if model.params['isinflow']:
coef = 3600 * model.params['dt'] * model.params['price']
vf = model.params['var_factor']
w = model.params['weight']
income = sum(
model.withdraw[s, h, m, y] * coef
model.withdraw[s, h, m, y] * coef * vf[y]
for s in model.station
for h in model.hour
for m in model.month
for y in model.year
)
) / w
return income

return poi.ExprBuilder(0)
Expand Down
3 changes: 2 additions & 1 deletion prepshot/_model/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def gen_up_bound_rule(
The constraint of the model.
"""
model = self.model
lhs = model.gen[h, m, y, z, te] - model.cap_existing[y, z, te]
lhs = model.gen[h, m, y, z, te] \
- model.cap_existing[y, z, te] * model.params['dt']
return model.add_linear_constraint(lhs, poi.Leq, 0)


Expand Down
31 changes: 31 additions & 0 deletions prepshot/_model/hydro.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ def __init__(self, model : object) -> None:
model.station, model.hour, model.month, model.year,
rule=self.outflow_up_bound_rule
)
model.genflow_up_bound_cons = poi.make_tupledict(
model.station, model.hour, model.month, model.year,
rule=self.genflow_up_bound_rule
)
model.storage_low_bound_cons = poi.make_tupledict(
model.station, model.hour, model.month, model.year,
rule=self.storage_low_bound_rule
Expand Down Expand Up @@ -373,6 +377,33 @@ def outflow_up_bound_rule(
lhs = model.outflow[s, h, m, y] - max_outflow
return model.add_linear_constraint(lhs, poi.Leq, 0)

def genflow_up_bound_rule(
self, s : str, h : int, m : int, y : int
) -> poi.ConstraintIndex:
"""Upper bound of generation flow.
Parameters
----------
s : str
hydropower plant.
h : int
Hour.
m : int
Month.
y : int
Year.
Returns
-------
poi.ConstraintIndex
The constraint of the model.
"""
model = self.model
rc = model.params['reservoir_characteristics']
max_genflow = rc['GQ_max', s]
lhs = model.genflow[s, h, m, y] - max_genflow
return model.add_linear_constraint(lhs, poi.Leq, 0)

def storage_low_bound_rule(
self, s : str, h : int, m : int, y : int
) -> poi.ConstraintIndex:
Expand Down

0 comments on commit 3b9e5d5

Please sign in to comment.