Skip to content

Commit

Permalink
Merge branch 'revision/remove-discounting-functionality' into revisio…
Browse files Browse the repository at this point in the history
…n/replace-constraint-tests
  • Loading branch information
p-snft committed Aug 20, 2024
2 parents 2ec9a02 + c5a62ed commit c8263ce
Showing 1 changed file with 28 additions and 72 deletions.
100 changes: 28 additions & 72 deletions src/oemof/solph/flows/_non_convex_flow_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,24 +325,13 @@ def _startup_costs(self):
if self.STARTUPFLOWS:
m = self.parent_block()

if m.es.periods is None:
for i, o in self.STARTUPFLOWS:
if m.flows[i, o].nonconvex.startup_costs[0] is not None:
startup_costs += sum(
self.startup[i, o, t]
* m.flows[i, o].nonconvex.startup_costs[t]
for t in m.TIMESTEPS
)
else:
for i, o in self.STARTUPFLOWS:
if m.flows[i, o].nonconvex.startup_costs[0] is not None:
startup_costs += sum(
self.startup[i, o, t]
* m.flows[i, o].nonconvex.startup_costs[t]
* m.objective_weighting[t]
* ((1 + m.discount_rate) ** -m.es.periods_years[p])
for p, t in m.TIMEINDEX
)
for i, o in self.STARTUPFLOWS:
if m.flows[i, o].nonconvex.startup_costs[0] is not None:
startup_costs += sum(
self.startup[i, o, t]
* m.flows[i, o].nonconvex.startup_costs[t]
for t in m.TIMESTEPS
)

self.startup_costs = Expression(expr=startup_costs)

Expand All @@ -359,24 +348,13 @@ def _shutdown_costs(self):
if self.SHUTDOWNFLOWS:
m = self.parent_block()

if m.es.periods is None:
for i, o in self.SHUTDOWNFLOWS:
if m.flows[i, o].nonconvex.shutdown_costs[0] is not None:
shutdown_costs += sum(
self.shutdown[i, o, t]
* m.flows[i, o].nonconvex.shutdown_costs[t]
for t in m.TIMESTEPS
)
else:
for i, o in self.SHUTDOWNFLOWS:
if m.flows[i, o].nonconvex.shutdown_costs[0] is not None:
shutdown_costs += sum(
self.shutdown[i, o, t]
* m.flows[i, o].nonconvex.shutdown_costs[t]
* m.objective_weighting[t]
* ((1 + m.discount_rate) ** -m.es.periods_years[p])
for p, t in m.TIMEINDEX
)
for i, o in self.SHUTDOWNFLOWS:
if m.flows[i, o].nonconvex.shutdown_costs[0] is not None:
shutdown_costs += sum(
self.shutdown[i, o, t]
* m.flows[i, o].nonconvex.shutdown_costs[t]
for t in m.TIMESTEPS
)

self.shutdown_costs = Expression(expr=shutdown_costs)

Expand All @@ -393,24 +371,13 @@ def _activity_costs(self):
if self.ACTIVITYCOSTFLOWS:
m = self.parent_block()

if m.es.periods is None:
for i, o in self.ACTIVITYCOSTFLOWS:
if m.flows[i, o].nonconvex.activity_costs[0] is not None:
activity_costs += sum(
self.status[i, o, t]
* m.flows[i, o].nonconvex.activity_costs[t]
for t in m.TIMESTEPS
)
else:
for i, o in self.ACTIVITYCOSTFLOWS:
if m.flows[i, o].nonconvex.activity_costs[0] is not None:
activity_costs += sum(
self.status[i, o, t]
* m.flows[i, o].nonconvex.activity_costs[t]
* m.objective_weighting[t]
* ((1 + m.discount_rate) ** -m.es.periods_years[p])
for p, t in m.TIMEINDEX
)
for i, o in self.ACTIVITYCOSTFLOWS:
if m.flows[i, o].nonconvex.activity_costs[0] is not None:
activity_costs += sum(
self.status[i, o, t]
* m.flows[i, o].nonconvex.activity_costs[t]
for t in m.TIMESTEPS
)

self.activity_costs = Expression(expr=activity_costs)

Expand All @@ -427,24 +394,13 @@ def _inactivity_costs(self):
if self.INACTIVITYCOSTFLOWS:
m = self.parent_block()

if m.es.periods is None:
for i, o in self.INACTIVITYCOSTFLOWS:
if m.flows[i, o].nonconvex.inactivity_costs[0] is not None:
inactivity_costs += sum(
(1 - self.status[i, o, t])
* m.flows[i, o].nonconvex.inactivity_costs[t]
for t in m.TIMESTEPS
)
else:
for i, o in self.INACTIVITYCOSTFLOWS:
if m.flows[i, o].nonconvex.inactivity_costs[0] is not None:
inactivity_costs += sum(
(1 - self.status[i, o, t])
* m.flows[i, o].nonconvex.inactivity_costs[t]
* m.objective_weighting[t]
* ((1 + m.discount_rate) ** -m.es.periods_years[p])
for p, t in m.TIMEINDEX
)
for i, o in self.INACTIVITYCOSTFLOWS:
if m.flows[i, o].nonconvex.inactivity_costs[0] is not None:
inactivity_costs += sum(
(1 - self.status[i, o, t])
* m.flows[i, o].nonconvex.inactivity_costs[t]
for t in m.TIMESTEPS
)

self.inactivity_costs = Expression(expr=inactivity_costs)

Expand Down

0 comments on commit c8263ce

Please sign in to comment.