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 duplicated discounting #1028

Merged
merged 8 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/whatsnew/v0-5-2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Bug fixes
bias towards investments happening earlier in the optimization horizon.
* Fix bugs in multi-period documentation.
* Fix y intersect of OffsetConverter
* Fix duplicated discounting of fixed costs for multi-period investment

Testing
#######
Expand Down
2 changes: 1 addition & 1 deletion src/oemof/solph/components/_generic_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ def _objective_expression(self):
m.es.periods_years[p],
range_limit,
)
) * (1 + m.discount_rate) ** (-m.es.periods_years[p])
)

for n in self.EXISTING_INVESTSTORAGES:
if n.investment.fixed_costs[0] is not None:
Expand Down
6 changes: 3 additions & 3 deletions src/oemof/solph/components/experimental/_sink_dsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ def _objective_expression(self):
m.es.periods_years[p],
range_limit,
)
) * (1 + m.discount_rate) ** (-m.es.periods_years[p])
)

for g in self.EXISTING_INVESTDSM:
if g.investment.fixed_costs[0] is not None:
Expand Down Expand Up @@ -3301,7 +3301,7 @@ def _objective_expression(self):
m.es.periods_years[p],
range_limit,
)
) * (1 + m.discount_rate) ** (-m.es.periods_years[p])
)

for g in self.EXISTING_INVESTDSM:
if g.investment.fixed_costs[0] is not None:
Expand Down Expand Up @@ -5800,7 +5800,7 @@ def _objective_expression(self):
m.es.periods_years[p],
range_limit,
)
) * (1 + m.discount_rate) ** (-m.es.periods_years[p])
)

for g in self.EXISTING_INVESTDSM:
if g.investment.fixed_costs[0] is not None:
Expand Down
5 changes: 2 additions & 3 deletions src/oemof/solph/flows/_investment_flow_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,9 +1024,8 @@ def _objective_expression(self):
* (1 + m.discount_rate) ** (-pp)
for pp in range(
m.es.periods_years[p],
range_limit,
)
) * (1 + m.discount_rate) ** (-m.es.periods_years[p])
range_limit)
)

for i, o in self.EXISTING_INVESTFLOWS:
if m.flows[i, o].investment.fixed_costs[0] is not None:
Expand Down
142 changes: 71 additions & 71 deletions tests/lp_files/converter_invest_multi_period.lp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

min
objective:
+3.5273767282312036 InvestmentFlowBlock_invest(powerplant_gas_coal_electricityBus_0)
+2.328225392441188 InvestmentFlowBlock_invest(powerplant_gas_coal_electricityBus_1)
+1.1525868279411837 InvestmentFlowBlock_invest(powerplant_gas_coal_electricityBus_2)
+32.94298610923851 InvestmentFlowBlock_invest(powerplant_gas_coal_electricityBus_0)
+21.74383477344849 InvestmentFlowBlock_invest(powerplant_gas_coal_electricityBus_1)
+10.764274640321037 InvestmentFlowBlock_invest(powerplant_gas_coal_electricityBus_2)
+50 flow(powerplant_gas_coal_electricityBus_0_0)
+50 flow(powerplant_gas_coal_electricityBus_0_1)
+49.01960784313725 flow(powerplant_gas_coal_electricityBus_1_2)
Expand Down Expand Up @@ -44,28 +44,28 @@ c_e_BusBlock_balance(electricityBus_2_5)_:
+1 flow(powerplant_gas_coal_electricityBus_2_5)
= 0

c_e_BusBlock_balance(gasBus_0_0)_:
+1 flow(gasBus_powerplant_gas_coal_0_0)
c_e_BusBlock_balance(coalBus_0_0)_:
+1 flow(coalBus_powerplant_gas_coal_0_0)
= 0

c_e_BusBlock_balance(gasBus_0_1)_:
+1 flow(gasBus_powerplant_gas_coal_0_1)
c_e_BusBlock_balance(coalBus_0_1)_:
+1 flow(coalBus_powerplant_gas_coal_0_1)
= 0

c_e_BusBlock_balance(gasBus_1_2)_:
+1 flow(gasBus_powerplant_gas_coal_1_2)
c_e_BusBlock_balance(coalBus_1_2)_:
+1 flow(coalBus_powerplant_gas_coal_1_2)
= 0

c_e_BusBlock_balance(gasBus_1_3)_:
+1 flow(gasBus_powerplant_gas_coal_1_3)
c_e_BusBlock_balance(coalBus_1_3)_:
+1 flow(coalBus_powerplant_gas_coal_1_3)
= 0

c_e_BusBlock_balance(gasBus_2_4)_:
+1 flow(gasBus_powerplant_gas_coal_2_4)
c_e_BusBlock_balance(coalBus_2_4)_:
+1 flow(coalBus_powerplant_gas_coal_2_4)
= 0

c_e_BusBlock_balance(gasBus_2_5)_:
+1 flow(gasBus_powerplant_gas_coal_2_5)
c_e_BusBlock_balance(coalBus_2_5)_:
+1 flow(coalBus_powerplant_gas_coal_2_5)
= 0

c_e_BusBlock_balance(thermalBus_0_0)_:
Expand All @@ -92,150 +92,150 @@ c_e_BusBlock_balance(thermalBus_2_5)_:
+1 flow(powerplant_gas_coal_thermalBus_2_5)
= 0

c_e_BusBlock_balance(coalBus_0_0)_:
+1 flow(coalBus_powerplant_gas_coal_0_0)
= 0

c_e_BusBlock_balance(coalBus_0_1)_:
+1 flow(coalBus_powerplant_gas_coal_0_1)
c_e_BusBlock_balance(gasBus_0_0)_:
+1 flow(gasBus_powerplant_gas_coal_0_0)
= 0

c_e_BusBlock_balance(coalBus_1_2)_:
+1 flow(coalBus_powerplant_gas_coal_1_2)
c_e_BusBlock_balance(gasBus_0_1)_:
+1 flow(gasBus_powerplant_gas_coal_0_1)
= 0

c_e_BusBlock_balance(coalBus_1_3)_:
+1 flow(coalBus_powerplant_gas_coal_1_3)
c_e_BusBlock_balance(gasBus_1_2)_:
+1 flow(gasBus_powerplant_gas_coal_1_2)
= 0

c_e_BusBlock_balance(coalBus_2_4)_:
+1 flow(coalBus_powerplant_gas_coal_2_4)
c_e_BusBlock_balance(gasBus_1_3)_:
+1 flow(gasBus_powerplant_gas_coal_1_3)
= 0

c_e_BusBlock_balance(coalBus_2_5)_:
+1 flow(coalBus_powerplant_gas_coal_2_5)
c_e_BusBlock_balance(gasBus_2_4)_:
+1 flow(gasBus_powerplant_gas_coal_2_4)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_0_0)_:
-0.58 flow(powerplant_gas_coal_electricityBus_0_0)
+0.3 flow(gasBus_powerplant_gas_coal_0_0)
c_e_BusBlock_balance(gasBus_2_5)_:
+1 flow(gasBus_powerplant_gas_coal_2_5)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_electricityBus_0_0)_:
-0.2 flow(powerplant_gas_coal_electricityBus_0_0)
+0.3 flow(coalBus_powerplant_gas_coal_0_0)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_0_0)_:
-0.58 flow(powerplant_gas_coal_thermalBus_0_0)
+0.5 flow(gasBus_powerplant_gas_coal_0_0)
c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_0_0)_:
-0.58 flow(powerplant_gas_coal_electricityBus_0_0)
+0.3 flow(gasBus_powerplant_gas_coal_0_0)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_thermalBus_0_0)_:
-0.2 flow(powerplant_gas_coal_thermalBus_0_0)
+0.5 flow(coalBus_powerplant_gas_coal_0_0)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_0_1)_:
-0.58 flow(powerplant_gas_coal_electricityBus_0_1)
+0.3 flow(gasBus_powerplant_gas_coal_0_1)
c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_0_0)_:
-0.58 flow(powerplant_gas_coal_thermalBus_0_0)
+0.5 flow(gasBus_powerplant_gas_coal_0_0)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_electricityBus_0_1)_:
-0.2 flow(powerplant_gas_coal_electricityBus_0_1)
+0.3 flow(coalBus_powerplant_gas_coal_0_1)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_0_1)_:
-0.58 flow(powerplant_gas_coal_thermalBus_0_1)
+0.5 flow(gasBus_powerplant_gas_coal_0_1)
c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_0_1)_:
-0.58 flow(powerplant_gas_coal_electricityBus_0_1)
+0.3 flow(gasBus_powerplant_gas_coal_0_1)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_thermalBus_0_1)_:
-0.2 flow(powerplant_gas_coal_thermalBus_0_1)
+0.5 flow(coalBus_powerplant_gas_coal_0_1)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_1_2)_:
-0.58 flow(powerplant_gas_coal_electricityBus_1_2)
+0.3 flow(gasBus_powerplant_gas_coal_1_2)
c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_0_1)_:
-0.58 flow(powerplant_gas_coal_thermalBus_0_1)
+0.5 flow(gasBus_powerplant_gas_coal_0_1)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_electricityBus_1_2)_:
-0.2 flow(powerplant_gas_coal_electricityBus_1_2)
+0.3 flow(coalBus_powerplant_gas_coal_1_2)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_1_2)_:
-0.58 flow(powerplant_gas_coal_thermalBus_1_2)
+0.5 flow(gasBus_powerplant_gas_coal_1_2)
c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_1_2)_:
-0.58 flow(powerplant_gas_coal_electricityBus_1_2)
+0.3 flow(gasBus_powerplant_gas_coal_1_2)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_thermalBus_1_2)_:
-0.2 flow(powerplant_gas_coal_thermalBus_1_2)
+0.5 flow(coalBus_powerplant_gas_coal_1_2)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_1_3)_:
-0.58 flow(powerplant_gas_coal_electricityBus_1_3)
+0.3 flow(gasBus_powerplant_gas_coal_1_3)
c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_1_2)_:
-0.58 flow(powerplant_gas_coal_thermalBus_1_2)
+0.5 flow(gasBus_powerplant_gas_coal_1_2)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_electricityBus_1_3)_:
-0.2 flow(powerplant_gas_coal_electricityBus_1_3)
+0.3 flow(coalBus_powerplant_gas_coal_1_3)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_1_3)_:
-0.58 flow(powerplant_gas_coal_thermalBus_1_3)
+0.5 flow(gasBus_powerplant_gas_coal_1_3)
c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_1_3)_:
-0.58 flow(powerplant_gas_coal_electricityBus_1_3)
+0.3 flow(gasBus_powerplant_gas_coal_1_3)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_thermalBus_1_3)_:
-0.2 flow(powerplant_gas_coal_thermalBus_1_3)
+0.5 flow(coalBus_powerplant_gas_coal_1_3)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_2_4)_:
-0.58 flow(powerplant_gas_coal_electricityBus_2_4)
+0.3 flow(gasBus_powerplant_gas_coal_2_4)
c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_1_3)_:
-0.58 flow(powerplant_gas_coal_thermalBus_1_3)
+0.5 flow(gasBus_powerplant_gas_coal_1_3)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_electricityBus_2_4)_:
-0.2 flow(powerplant_gas_coal_electricityBus_2_4)
+0.3 flow(coalBus_powerplant_gas_coal_2_4)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_2_4)_:
-0.58 flow(powerplant_gas_coal_thermalBus_2_4)
+0.5 flow(gasBus_powerplant_gas_coal_2_4)
c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_2_4)_:
-0.58 flow(powerplant_gas_coal_electricityBus_2_4)
+0.3 flow(gasBus_powerplant_gas_coal_2_4)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_thermalBus_2_4)_:
-0.2 flow(powerplant_gas_coal_thermalBus_2_4)
+0.5 flow(coalBus_powerplant_gas_coal_2_4)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_2_5)_:
-0.58 flow(powerplant_gas_coal_electricityBus_2_5)
+0.3 flow(gasBus_powerplant_gas_coal_2_5)
c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_2_4)_:
-0.58 flow(powerplant_gas_coal_thermalBus_2_4)
+0.5 flow(gasBus_powerplant_gas_coal_2_4)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_electricityBus_2_5)_:
-0.2 flow(powerplant_gas_coal_electricityBus_2_5)
+0.3 flow(coalBus_powerplant_gas_coal_2_5)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_2_5)_:
-0.58 flow(powerplant_gas_coal_thermalBus_2_5)
+0.5 flow(gasBus_powerplant_gas_coal_2_5)
c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_electricityBus_2_5)_:
-0.58 flow(powerplant_gas_coal_electricityBus_2_5)
+0.3 flow(gasBus_powerplant_gas_coal_2_5)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_coalBus_thermalBus_2_5)_:
-0.2 flow(powerplant_gas_coal_thermalBus_2_5)
+0.5 flow(coalBus_powerplant_gas_coal_2_5)
= 0

c_e_ConverterBlock_relation(powerplant_gas_coal_gasBus_thermalBus_2_5)_:
-0.58 flow(powerplant_gas_coal_thermalBus_2_5)
+0.5 flow(gasBus_powerplant_gas_coal_2_5)
= 0

c_e_InvestmentFlowBlock_total_rule(powerplant_gas_coal_electricityBus_0)_:
-1 InvestmentFlowBlock_invest(powerplant_gas_coal_electricityBus_0)
+1 InvestmentFlowBlock_total(powerplant_gas_coal_electricityBus_0)
Expand Down Expand Up @@ -343,18 +343,18 @@ bounds
0 <= flow(powerplant_gas_coal_thermalBus_1_3) <= +inf
0 <= flow(powerplant_gas_coal_thermalBus_2_4) <= +inf
0 <= flow(powerplant_gas_coal_thermalBus_2_5) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_0_0) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_0_1) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_1_2) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_1_3) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_2_4) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_2_5) <= +inf
0 <= flow(coalBus_powerplant_gas_coal_0_0) <= +inf
0 <= flow(coalBus_powerplant_gas_coal_0_1) <= +inf
0 <= flow(coalBus_powerplant_gas_coal_1_2) <= +inf
0 <= flow(coalBus_powerplant_gas_coal_1_3) <= +inf
0 <= flow(coalBus_powerplant_gas_coal_2_4) <= +inf
0 <= flow(coalBus_powerplant_gas_coal_2_5) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_0_0) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_0_1) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_1_2) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_1_3) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_2_4) <= +inf
0 <= flow(gasBus_powerplant_gas_coal_2_5) <= +inf
0 <= InvestmentFlowBlock_total(powerplant_gas_coal_electricityBus_0) <= +inf
0 <= InvestmentFlowBlock_total(powerplant_gas_coal_electricityBus_1) <= +inf
0 <= InvestmentFlowBlock_old(powerplant_gas_coal_electricityBus_1) <= +inf
Expand Down
4 changes: 2 additions & 2 deletions tests/lp_files/dsm_module_DIW_invest_multi_period.lp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ objective:
+0.9611687812379853 SinkDSMDIWInvestmentBlock_dsm_do_shift(demand_dsm_5_5)
+96.11687812379853 SinkDSMDIWInvestmentBlock_dsm_do_shed(demand_dsm_5)
+76.46810240317063 SinkDSMDIWInvestmentBlock_invest(demand_dsm_0)
+49.710949277906536 SinkDSMDIWInvestmentBlock_invest(demand_dsm_1)
+24.239842660236203 SinkDSMDIWInvestmentBlock_invest(demand_dsm_2)
+50.47234572422055 SinkDSMDIWInvestmentBlock_invest(demand_dsm_1)
+24.986309764465627 SinkDSMDIWInvestmentBlock_invest(demand_dsm_2)

s.t.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ objective:
+0.9611687812379853 SinkDSMDIWInvestmentBlock_dsm_do_shift(demand_dsm_5_5)
+96.11687812379853 SinkDSMDIWInvestmentBlock_dsm_do_shed(demand_dsm_5)
+57.62165571222974 SinkDSMDIWInvestmentBlock_invest(demand_dsm_0)
+39.12361323621548 SinkDSMDIWInvestmentBlock_invest(demand_dsm_1)
+23.087255832295018 SinkDSMDIWInvestmentBlock_invest(demand_dsm_2)
+39.8850096825295 SinkDSMDIWInvestmentBlock_invest(demand_dsm_1)
+23.833722936524442 SinkDSMDIWInvestmentBlock_invest(demand_dsm_2)

s.t.

Expand Down
4 changes: 2 additions & 2 deletions tests/lp_files/dsm_module_DLR_invest_multi_period.lp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ objective:
+0.9611687812379853 SinkDSMDLRInvestmentBlock_balance_dsm_up(demand_dsm_2_5)
+96.11687812379853 SinkDSMDLRInvestmentBlock_dsm_do_shed(demand_dsm_5)
+76.46810240317063 SinkDSMDLRInvestmentBlock_invest(demand_dsm_0)
+49.710949277906536 SinkDSMDLRInvestmentBlock_invest(demand_dsm_1)
+24.239842660236203 SinkDSMDLRInvestmentBlock_invest(demand_dsm_2)
+50.47234572422055 SinkDSMDLRInvestmentBlock_invest(demand_dsm_1)
+24.986309764465627 SinkDSMDLRInvestmentBlock_invest(demand_dsm_2)

s.t.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ objective:
+0.9611687812379853 SinkDSMDLRInvestmentBlock_balance_dsm_up(demand_dsm_2_5)
+96.11687812379853 SinkDSMDLRInvestmentBlock_dsm_do_shed(demand_dsm_5)
+57.62165571222974 SinkDSMDLRInvestmentBlock_invest(demand_dsm_0)
+39.12361323621548 SinkDSMDLRInvestmentBlock_invest(demand_dsm_1)
+23.087255832295018 SinkDSMDLRInvestmentBlock_invest(demand_dsm_2)
+39.8850096825295 SinkDSMDLRInvestmentBlock_invest(demand_dsm_1)
+23.833722936524442 SinkDSMDLRInvestmentBlock_invest(demand_dsm_2)

s.t.

Expand Down
2 changes: 1 addition & 1 deletion tests/lp_files/dsm_module_oemof_extended.lp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ c_e_SinkDSMOemofBlock_dsm_sum_constraint(demand_dsm_0)_:
+0.99 SinkDSMOemofBlock_dsm_up(demand_dsm_0)
+0.99 SinkDSMOemofBlock_dsm_up(demand_dsm_1)
-1 SinkDSMOemofBlock_dsm_do_shift(demand_dsm_1)
= 0.0
= 0

bounds
0 <= SinkDSMOemofBlock_dsm_do_shift(demand_dsm_0) <= +inf
Expand Down
4 changes: 2 additions & 2 deletions tests/lp_files/dsm_module_oemof_invest_multi_period.lp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ objective:
+0.9611687812379853 SinkDSMOemofInvestmentBlock_dsm_do_shift(demand_dsm_5)
+96.11687812379853 SinkDSMOemofInvestmentBlock_dsm_do_shed(demand_dsm_5)
+76.46810240317063 SinkDSMOemofInvestmentBlock_invest(demand_dsm_0)
+49.710949277906536 SinkDSMOemofInvestmentBlock_invest(demand_dsm_1)
+24.239842660236203 SinkDSMOemofInvestmentBlock_invest(demand_dsm_2)
+50.47234572422055 SinkDSMOemofInvestmentBlock_invest(demand_dsm_1)
+24.986309764465627 SinkDSMOemofInvestmentBlock_invest(demand_dsm_2)

s.t.

Expand Down