Skip to content

Conversation

@FabianHofmann
Copy link
Contributor

@FabianHofmann FabianHofmann commented Jan 23, 2026

Add solving.options.store_model config option that stores the linopy model to a NetCDF file in results/models/ after solving. Includes validation to prevent use with rolling_horizon mode.

Checklist

  • I tested my contribution locally and it works as intended.
  • Code and workflow changes are sufficiently documented.
  • Changed dependencies are added to pixi.toml (using pixi add <dependency-name>).
  • Changes in configuration options are added in config/config.default.yaml.
  • Changes in configuration options are documented in doc/configtables/*.csv.
  • For new data sources or versions, these instructions have been followed.
  • A release note doc/release_notes.rst is added.

Add solving.options.store_model config option that stores the linopy
model to a NetCDF file in results/models/ after solving. Includes
validation to prevent use with rolling_horizon mode.
@FabianHofmann FabianHofmann requested a review from fneum January 23, 2026 11:22
Copy link
Member

@fneum fneum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question about output_model function.

output:
network=RESULTS + "networks/base_s_{clusters}_elec_{opts}.nc",
config=RESULTS + "configs/config.base_s_{clusters}_elec_{opts}.yaml",
model=output_model(RESULTS + "models/base_s_{clusters}_elec_{opts}.nc"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair, but couldn't it just be a lambda-function like elsewhere?

model=lambda w: RESULTS + "...nc" if config_provider("x", "y")(w) else []

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, just since it happens three times I wanted to have something more snappy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The disadvantage I see with this implementation is, that I have to look at different places to understand what configs determine this output.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the dream-case for branch:

model=branch(config_provider("x", "y"), RESULTS + "....nc")

@FabianHofmann FabianHofmann enabled auto-merge (squash) January 28, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants