Skip to content

Preserve InvestmentUp / RetirementUp = 0 as 'forbid investment'#109

Closed
erikfilias wants to merge 1 commit into
masterfrom
fix/invest-up-zero-semantics
Closed

Preserve InvestmentUp / RetirementUp = 0 as 'forbid investment'#109
erikfilias wants to merge 1 commit into
masterfrom
fix/invest-up-zero-semantics

Conversation

@erikfilias
Copy link
Copy Markdown
Contributor

The input pipeline was filling NaN cells in InvestmentUp / RetirementUp with 0 at CSV-load time, then overriding 0 with 1.0 a few lines later. The combined effect was that an explicit 0 in the CSV (which the column docstring describes as a fraction in [0, 1]) silently became 1.0, letting the solver build the candidate up to MaximumPower / TTC. Users who wrote 0 to forbid investment got the opposite behaviour with no warning.

Fix: at CSV-load time, fill NaN with the documented default — 1.0 for upper-bound columns (InvestmentUp, RetirementUp) and 0.0 for everything else. The redundant 'where(par > 0.0, 1.0)' overrides for pGenUpInvest, pGenUpRetire, pNetUpInvest, pH2PipeUpInvest, pHeatPipeUpInvest are then deleted. Also extends the per-column fill behaviour from dfGeneration to dfNetwork / dfNetworkHydrogen / dfNetworkHeat for consistency.

Adds a regression test (test_invest_up_zero_enforces_no_investment) on case 9n with InvestmentUp=0 set on the single network candidate; verifies the resulting vNetworkInvest is 0. The same code path applies to pGenUpInvest, pGenUpRetire, pH2PipeUpInvest, pHeatPipeUpInvest.

Migration note: legacy CSVs that used 0 as a 'no upper bound' sentinel must leave the cell blank (NaN) for the previous behaviour.

The input pipeline was filling NaN cells in InvestmentUp / RetirementUp
with 0 at CSV-load time, then overriding 0 with 1.0 a few lines later.
The combined effect was that an explicit 0 in the CSV (which the column
docstring describes as a fraction in [0, 1]) silently became 1.0, letting
the solver build the candidate up to MaximumPower / TTC. Users who wrote
0 to forbid investment got the opposite behaviour with no warning.

Fix: at CSV-load time, fill NaN with the documented default — 1.0 for
upper-bound columns (InvestmentUp, RetirementUp) and 0.0 for everything
else. The redundant 'where(par > 0.0, 1.0)' overrides for pGenUpInvest,
pGenUpRetire, pNetUpInvest, pH2PipeUpInvest, pHeatPipeUpInvest are then
deleted. Also extends the per-column fill behaviour from dfGeneration
to dfNetwork / dfNetworkHydrogen / dfNetworkHeat for consistency.

Adds a regression test (test_invest_up_zero_enforces_no_investment) on
case 9n with InvestmentUp=0 set on the single network candidate; verifies
the resulting vNetworkInvest is 0. The same code path applies to
pGenUpInvest, pGenUpRetire, pH2PipeUpInvest, pHeatPipeUpInvest.

Migration note: legacy CSVs that used 0 as a 'no upper bound' sentinel
must leave the cell blank (NaN) for the previous behaviour.
@erikfilias erikfilias added the enhancement New feature or request label Apr 30, 2026
@erikfilias erikfilias self-assigned this Apr 30, 2026
@erikfilias erikfilias requested a review from arght April 30, 2026 09:04
@arght
Copy link
Copy Markdown
Contributor

arght commented Apr 30, 2026

The way to forbid an investment is to assign a value of 0.00001 to the upper bound, which will be internally translated to 0. This is the convention used by openTEPES across all files and can be explicitly added to the documentation, if not yet. I don't see the need to change the convention specifically for this file.

@erikfilias
Copy link
Copy Markdown
Contributor Author

erikfilias commented Apr 30, 2026

Thanks, @arght — I hadn't seen the 1e-5 convention spelled out anywhere in the input docs for it and you are right about we should keep the copenTEPES convention. Glad to close this and switch our cross-evaluation tooling to use the 1e-5 upper bound instead. If it helps, I will open another tiny docs-only PR adding a note next to the InvestmentUp / RetirementUp column descriptions in the README docs — purely the convention, no behaviour change. Closing this PR now.

@erikfilias erikfilias closed this Apr 30, 2026
@arght
Copy link
Copy Markdown
Contributor

arght commented Apr 30, 2026

Ok. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants