Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove internal discounting for NonConvexFlow #1110

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
160 changes: 0 additions & 160 deletions tests/lp_files/activity_costs_multi_period.lp

This file was deleted.

Loading
Loading