Expressions container - #882
Conversation
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
FabianHofmann
left a comment
There was a problem hiding this comment.
this is extremely non-controversial. let's pull this in. Just to test potential future regressions let's also catch the case that returned and stored expression are the same (as suggested below)
Merging this PR will improve performance by 21.24%
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
Co-authored-by: Fabian Hofmann <fab.hof@gmx.de>
for more information, see https://pre-commit.ci
|
@FabianHofmann @FBumann I can't really understand the memory benchmarking results. It's showing a regression in one and massive improvements in others. I can understand regressions if the expressions container is being used but I can't understand performance improvements: there should be none. |
|
@brynpickering I think the benchmarks are in a dirty state where the reference run is from master before several package version updates and not the latest master. At least this is how I understood @FBumann. So let's ignore it and just look at the other tests |
|
Merging master into here should resolve this |
Partially closes #881
Note
Initial implementation in #871 was human-generated. I've cherry-picked that and then iterated on it with Claude to close some implementation gaps and to add tests/docs.
Note
This does not address the concept of lazy expressions from #881 as I wanted to keep this PR lightweight and less controversial.
Changes proposed in this Pull Request
Model.add_expressionsregisters aLinearExpressionorQuadraticExpressionunder a name (auto-generated asexpr0,expr1, ... if omitted), accessible afterwards viaModel.expressions(anExpressionscontainer mirroringModel.variables/Model.constraints) and removable viaModel.remove_expressions.Named expressions are persisted by
Model.to_netcdf/linopy.read_netcdfand preserved byModel.copy,copy.copy,copy.deepcopy, and pickling.Checklist
AGENTS.md).doc.doc/release_notes.rstof the upcoming release is included.