Add include_objective_constant parameter to optimize#1509
Merged
FabianHofmann merged 15 commits intomasterfrom Jan 26, 2026
Merged
Add include_objective_constant parameter to optimize#1509FabianHofmann merged 15 commits intomasterfrom
FabianHofmann merged 15 commits intomasterfrom
Conversation
Add parameter to control whether the objective constant (capital costs of existing infrastructure) is included as a variable in the objective function. Setting to False improves LP numerical conditioning. - Add include_objective_constant parameter to optimize() and create_model() - Raise FutureWarning when parameter not explicitly set (default will change) - Add comprehensive tests for the new parameter
fneum
reviewed
Jan 5, 2026
Member
fneum
left a comment
There was a problem hiding this comment.
Great! Just one question about skipping the objective constant calculation as well with include_objective_constant.
lkstrp
reviewed
Jan 5, 2026
Member
lkstrp
left a comment
There was a problem hiding this comment.
Minor framing stuff and two things:
- When running
n.optimize_create_modeland any other functions which runs define_objective without going throughn.optimizeyou don't get the warning. At least forcreate_modelit should be added, is it? - We should add a params option to
pypsa.optionsforinclude_objective_constant
f12abbf to
e54936e
Compare
Co-authored-by: Lukas Trippe <[email protected]>
Co-authored-by: Lukas Trippe <[email protected]>
lkstrp
reviewed
Jan 19, 2026
Member
lkstrp
left a comment
There was a problem hiding this comment.
I added some changes, mainly just framing.
Except your last commit, I am happy to merge this now
lkstrp
approved these changes
Jan 22, 2026
fneum
approved these changes
Jan 23, 2026
Member
fneum
left a comment
There was a problem hiding this comment.
Failing CI due to test on FutureWarning.
The conftest.py sets this option to True globally, so tests expecting FutureWarning when the option is None need to reset it first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the feature request from #503:
include_objective_constantparameter ton.optimize()andn.optimize.create_model()to control whether the objective constant (capital costs of existing infrastructure) is included as a variable in the objective functioninclude_objective_constant=None(default), raises aFutureWarningindicating the default will change fromTruetoFalsein a future versionFalseimproves LP numerical conditioning by not including the constant as a variableobjective_constantis still calculated and stored on the network regardless of this parameterChecklist
docs.docs/release-notes.mdof the upcoming release is included.Closes #503