Example notebook

[1]:
import matplotlib.pyplot as plt

from pommes import configure_logging, test_case_path
from pommes.io.build_input_dataset import (
    build_input_parameters,
    read_config_file,
)
from pommes.io.save_solution import save_solution
from pommes.model.build_model import build_model
from pommes.model.data_validation.dataset_check import check_inputs

configure_logging()
[2]:
scenario = "ref"
suffix = "_02161113"

output_folder = f"{test_case_path}/output/{scenario}{suffix}"
solver = "highs"  # ["gurobi", "xpress", "highs", "mosek"]
[3]:
config = read_config_file(file_path=test_case_path / "config.yaml")

model_parameters = build_input_parameters(config)
model_parameters = check_inputs(model_parameters)
Inputs    27 files, 90 parameters, 2 area x 4 year_op x 10 hour            1.1 s
WARNING   Missing variables in input dataset. Adding defaults:
          combined_max_yearly_production: nan (type=float64)
          conversion_initial_production_budget: nan (type=float64)
          operation_year_weight: 1.0 (type=float64)
          storage_initial_level: nan (type=float64)
          storage_energy_to_power_ratio: nan (type=float64)
Checks    113 parameters after the defaults                                0.0 s
[4]:
model = build_model(model_parameters)
/pommes/pommes/model/build_model.py:261: LinopySemanticsWarning: Variable 'operation_load_shedding_power' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_load_shedding_power.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_load_shedding_power - operation_spillage_power - p.demand
/pommes/pommes/model/build_model.py:270: LinopySemanticsWarning: Variable 'operation_load_shedding_power' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_load_shedding_power.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_load_shedding_power <= p.load_shedding_max_capacity,
/pommes/pommes/model/build_model.py:270: LinopySemanticsWarning: NaN in the constraint RHS was silently kept as 'no constraint at this row' by legacy auto-mask. Under v1 this raises ValueError.
  Resolve:   `mask=` on the variable for explicit per-row masking
             or `.fillna(value)` if the NaN was a data error.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_load_shedding_power <= p.load_shedding_max_capacity,
/pommes/pommes/model/build_model.py:280: LinopySemanticsWarning: NaN in the constraint RHS was silently kept as 'no constraint at this row' by legacy auto-mask. Under v1 this raises ValueError.
  Resolve:   `mask=` on the variable for explicit per-row masking
             or `.fillna(value)` if the NaN was a data error.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_spillage_power <= p.spillage_max_capacity,
/pommes/pommes/model/build_model.py:293: LinopySemanticsWarning: Variable 'operation_load_shedding_power' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_load_shedding_power.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  + (operation_load_shedding_power * p.load_shedding_cost).sum(
/pommes/pommes/model/conversion.py:380: LinopySemanticsWarning: NaN in the multiplicative factor was silently treated as 0 by legacy (so the variable was zeroed out at that slot). Under v1 this raises ValueError.
  Resolve:   `.fillna(value)` (data error)
             or `mask=` / `.where(cond)` / `.reindex(...)` on the variable (intended absence).
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  -p.conversion_ramp_up
/pommes/pommes/model/conversion.py:384: LinopySemanticsWarning: Variable 'operation_conversion_power' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_conversion_power.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_conversion_power
/pommes/pommes/model/conversion.py:396: LinopySemanticsWarning: NaN in the multiplicative factor was silently treated as 0 by legacy (so the variable was zeroed out at that slot). Under v1 this raises ValueError.
  Resolve:   `.fillna(value)` (data error)
             or `mask=` / `.where(cond)` / `.reindex(...)` on the variable (intended absence).
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  -p.conversion_ramp_down
/pommes/pommes/model/conversion.py:400: LinopySemanticsWarning: Variable 'operation_conversion_power' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_conversion_power.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_conversion_power.shift(hour=1)
/pommes/pommes/model/conversion.py:429: LinopySemanticsWarning: NaN in the constraint RHS was silently kept as 'no constraint at this row' by legacy auto-mask. Under v1 this raises ValueError.
  Resolve:   `mask=` on the variable for explicit per-row masking
             or `.fillna(value)` if the NaN was a data error.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  yearly_production <= p.conversion_max_yearly_production,
/pommes/pommes/model/conversion.py:547: LinopySemanticsWarning: NaN in the multiplicative factor was silently treated as 0 by legacy (so the variable was zeroed out at that slot). Under v1 this raises ValueError.
  Resolve:   `.fillna(value)` (data error)
             or `mask=` / `.where(cond)` / `.reindex(...)` on the variable (intended absence).
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  (planning_conversion_power_capacity * p.conversion_annuity_cost)
/pommes/pommes/model/conversion.py:547: LinopySemanticsWarning: Variable 'planning_conversion_power_capacity' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `planning_conversion_power_capacity.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  (planning_conversion_power_capacity * p.conversion_annuity_cost)
/pommes/pommes/model/storage.py:496: LinopySemanticsWarning: NaN in the multiplicative factor was silently treated as 0 by legacy (so the variable was zeroed out at that slot). Under v1 this raises ValueError.
  Resolve:   `.fillna(value)` (data error)
             or `mask=` / `.where(cond)` / `.reindex(...)` on the variable (intended absence).
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  - planning_storage_power_capacity * p.storage_energy_to_power_ratio
/pommes/pommes/model/storage.py:496: LinopySemanticsWarning: Variable 'planning_storage_power_capacity' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `planning_storage_power_capacity.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  - planning_storage_power_capacity * p.storage_energy_to_power_ratio
/pommes/pommes/model/storage.py:495: LinopySemanticsWarning: Variable 'planning_storage_energy_capacity' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `planning_storage_energy_capacity.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  planning_storage_energy_capacity
/pommes/pommes/model/storage.py:503: LinopySemanticsWarning: NaN in the constraint RHS was silently kept as 'no constraint at this row' by legacy auto-mask. Under v1 this raises ValueError.
  Resolve:   `mask=` on the variable for explicit per-row masking
             or `.fillna(value)` if the NaN was a data error.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  planning_storage_power_capacity.sum("year_dec")
/pommes/pommes/model/storage.py:536: LinopySemanticsWarning: NaN in the constraint RHS was silently kept as 'no constraint at this row' by legacy auto-mask. Under v1 this raises ValueError.
  Resolve:   `mask=` on the variable for explicit per-row masking
             or `.fillna(value)` if the NaN was a data error.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  planning_storage_energy_capacity.sum("year_dec")
/pommes/pommes/model/storage.py:585: LinopySemanticsWarning: NaN in the multiplicative factor was silently treated as 0 by legacy (so the variable was zeroed out at that slot). Under v1 this raises ValueError.
  Resolve:   `.fillna(value)` (data error)
             or `mask=` / `.where(cond)` / `.reindex(...)` on the variable (intended absence).
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  planning_storage_power_capacity * p.storage_annuity_cost_power
/pommes/pommes/model/storage.py:585: LinopySemanticsWarning: Variable 'planning_storage_power_capacity' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `planning_storage_power_capacity.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  planning_storage_power_capacity * p.storage_annuity_cost_power
/pommes/pommes/model/storage.py:586: LinopySemanticsWarning: NaN in the multiplicative factor was silently treated as 0 by legacy (so the variable was zeroed out at that slot). Under v1 this raises ValueError.
  Resolve:   `.fillna(value)` (data error)
             or `mask=` / `.where(cond)` / `.reindex(...)` on the variable (intended absence).
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  + planning_storage_energy_capacity
/pommes/pommes/model/storage.py:586: LinopySemanticsWarning: Variable 'planning_storage_energy_capacity' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `planning_storage_energy_capacity.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  + planning_storage_energy_capacity
/pommes/pommes/model/transport.py:153: LinopySemanticsWarning: Variable 'operation_transport_power' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_transport_power.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  flows = flows.to_linexpr()
/pommes/pommes/model/transport.py:153: LinopySemanticsWarning: Variable 'operation_transport_power' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_transport_power.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  flows = flows.to_linexpr()
/pommes/pommes/model/transport.py:444: LinopySemanticsWarning: NaN in the constraint RHS was silently kept as 'no constraint at this row' by legacy auto-mask. Under v1 this raises ValueError.
  Resolve:   `mask=` on the variable for explicit per-row masking
             or `.fillna(value)` if the NaN was a data error.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  planning_transport_power_capacity.sum("year_dec")
/pommes/pommes/model/transport.py:455: LinopySemanticsWarning: NaN in the constraint RHS was silently kept as 'no constraint at this row' by legacy auto-mask. Under v1 this raises ValueError.
  Resolve:   `mask=` on the variable for explicit per-row masking
             or `.fillna(value)` if the NaN was a data error.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  planning_transport_power_capacity.sum("year_dec")
/pommes/pommes/model/transport.py:466: LinopySemanticsWarning: NaN in the constraint RHS was silently kept as 'no constraint at this row' by legacy auto-mask. Under v1 this raises ValueError.
  Resolve:   `mask=` on the variable for explicit per-row masking
             or `.fillna(value)` if the NaN was a data error.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  planning_transport_power_capacity.sum("year_dec")
/pommes/pommes/model/transport.py:489: LinopySemanticsWarning: Variable 'operation_transport_power' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_transport_power.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_transport_power
/pommes/pommes/model/transport.py:520: LinopySemanticsWarning: NaN in the multiplicative factor was silently treated as 0 by legacy (so the variable was zeroed out at that slot). Under v1 this raises ValueError.
  Resolve:   `.fillna(value)` (data error)
             or `mask=` / `.where(cond)` / `.reindex(...)` on the variable (intended absence).
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  p.transport_annuity_cost * planning_transport_power_capacity
/pommes/pommes/model/transport.py:520: LinopySemanticsWarning: Variable 'planning_transport_power_capacity' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `planning_transport_power_capacity.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  p.transport_annuity_cost * planning_transport_power_capacity
/pommes/pommes/model/combined.py:623: LinopySemanticsWarning: NaN in the constraint RHS was silently kept as 'no constraint at this row' by legacy auto-mask. Under v1 this raises ValueError.
  Resolve:   `mask=` on the variable for explicit per-row masking
             or `.fillna(value)` if the NaN was a data error.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  planning_combined_power_capacity.sum("year_dec")
/pommes/pommes/model/combined.py:634: LinopySemanticsWarning: NaN in the constraint RHS was silently kept as 'no constraint at this row' by legacy auto-mask. Under v1 this raises ValueError.
  Resolve:   `mask=` on the variable for explicit per-row masking
             or `.fillna(value)` if the NaN was a data error.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  planning_combined_power_capacity.sum("year_dec")
/pommes/pommes/model/combined.py:645: LinopySemanticsWarning: NaN in the constraint RHS was silently kept as 'no constraint at this row' by legacy auto-mask. Under v1 this raises ValueError.
  Resolve:   `mask=` on the variable for explicit per-row masking
             or `.fillna(value)` if the NaN was a data error.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  planning_combined_power_capacity.sum("year_dec")
/pommes/pommes/model/combined.py:674: LinopySemanticsWarning: NaN in the multiplicative factor was silently treated as 0 by legacy (so the variable was zeroed out at that slot). Under v1 this raises ValueError.
  Resolve:   `.fillna(value)` (data error)
             or `mask=` / `.where(cond)` / `.reindex(...)` on the variable (intended absence).
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  (planning_combined_power_capacity * p.combined_annuity_cost)
/pommes/pommes/model/combined.py:674: LinopySemanticsWarning: Variable 'planning_combined_power_capacity' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `planning_combined_power_capacity.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  (planning_combined_power_capacity * p.combined_annuity_cost)
/pommes/pommes/model/turpe.py:165: LinopySemanticsWarning: Variable 'operation_net_import_abs' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_net_import_abs.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  v.operation_net_import_abs.sel(resource="electricity").where(
/pommes/pommes/model/turpe.py:165: LinopySemanticsWarning: Variable 'operation_net_import_abs' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_net_import_abs.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  v.operation_net_import_abs.sel(resource="electricity").where(
/pommes/pommes/model/turpe.py:165: LinopySemanticsWarning: Variable 'operation_net_import_abs' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_net_import_abs.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  v.operation_net_import_abs.sel(resource="electricity").where(
/pommes/pommes/model/turpe.py:165: LinopySemanticsWarning: Variable 'operation_net_import_abs' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_net_import_abs.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  v.operation_net_import_abs.sel(resource="electricity").where(
/pommes/pommes/model/turpe.py:165: LinopySemanticsWarning: Variable 'operation_net_import_abs' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_net_import_abs.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  v.operation_net_import_abs.sel(resource="electricity").where(
/pommes/pommes/model/turpe.py:163: LinopySemanticsWarning: Auxiliary coordinate 'hour_type' was conflicting across operands and silently dropped by legacy (xarray's default). Under v1 this raises ValueError.
  Values:    left='HCE', right='HPE'
  Resolve:   `.drop_vars('hour_type')`
             `.assign_coords(hour_type=...)` to relabel one side
             or `.isel(..., drop=True)` if a scalar isel introduced it.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  linopy.expressions.merge(
/pommes/pommes/model/turpe.py:180: LinopySemanticsWarning: Variable 'operation_turpe_contract_power' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_turpe_contract_power.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_turpe_contract_power
/pommes/pommes/model/turpe.py:199: LinopySemanticsWarning: Variable 'operation_net_import_abs' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_net_import_abs.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  v.operation_net_import_abs.sel(
/pommes/pommes/model/turpe.py:199: LinopySemanticsWarning: Variable 'operation_net_import_abs' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_net_import_abs.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  v.operation_net_import_abs.sel(
/pommes/pommes/model/turpe.py:199: LinopySemanticsWarning: Variable 'operation_net_import_abs' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_net_import_abs.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  v.operation_net_import_abs.sel(
/pommes/pommes/model/turpe.py:199: LinopySemanticsWarning: Variable 'operation_net_import_abs' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_net_import_abs.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  v.operation_net_import_abs.sel(
/pommes/pommes/model/turpe.py:199: LinopySemanticsWarning: Variable 'operation_net_import_abs' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_net_import_abs.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  v.operation_net_import_abs.sel(
/pommes/pommes/model/turpe.py:197: LinopySemanticsWarning: Auxiliary coordinate 'hour_type' was conflicting across operands and silently dropped by legacy (xarray's default). Under v1 this raises ValueError.
  Values:    left='HCE', right='HPE'
  Resolve:   `.drop_vars('hour_type')`
             `.assign_coords(hour_type=...)` to relabel one side
             or `.isel(..., drop=True)` if a scalar isel introduced it.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  linopy.expressions.merge(
/pommes/pommes/model/turpe.py:222: LinopySemanticsWarning: Variable 'operation_turpe_contract_power' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_turpe_contract_power.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_turpe_contract_power
/pommes/pommes/model/flexible_demand.py:184: LinopySemanticsWarning: Variable 'operation_flexibility_demand' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_flexibility_demand.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  m.add_terms(operation_adequacy_constraint, -operation_flexibility_demand)
/pommes/pommes/model/flexible_demand.py:200: LinopySemanticsWarning: Variable 'operation_flexibility_demand' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_flexibility_demand.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_flexibility_demand - flex_max <= 0,
/pommes/pommes/model/flexible_demand.py:215: LinopySemanticsWarning: Variable 'operation_flexibility_demand' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_flexibility_demand.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_flexibility_demand - flex_min >= 0,
/pommes/pommes/model/flexible_demand.py:374: LinopySemanticsWarning: Variable 'operation_flexibility_demand' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_flexibility_demand.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_flexibility_displaced_demand >= -operation_flexibility_demand + flexibility_demand,
/pommes/pommes/model/flexible_demand.py:374: LinopySemanticsWarning: Variable 'operation_flexibility_displaced_demand' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_flexibility_displaced_demand.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_flexibility_displaced_demand >= -operation_flexibility_demand + flexibility_demand,
/pommes/pommes/model/flexible_demand.py:401: LinopySemanticsWarning: Variable 'operation_flexibility_displaced_demand' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_flexibility_displaced_demand.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  flex_var_cost.fillna(0.0)
/pommes/pommes/model/flexible_demand.py:398: LinopySemanticsWarning: Variable 'operation_flexibility_costs' has absent slots (from `mask=` / `.where()` / `.shift()` / `.reindex()`). Under legacy each absent slot contributes 0 to the resulting expression's terms (so `x + y >= 10` reduces to `x >= 10` there). Under v1 the absence propagates through arithmetic instead (`x + y` becomes absent at the slot and the constraint drops).
  Resolve:   wrap with `operation_flexibility_costs.fillna(0)` for the legacy behaviour under v1.
  Opt in:    linopy.options['semantics'] = 'v1'
  Silence:   warnings.filterwarnings('ignore', category=LinopySemanticsWarning)
  operation_flexibility_costs
Model     4172 rows, 3790 columns                                          3.8 s
[5]:
model.solve(solver_name=solver)

save_solution(
    model=model,
    output_folder=output_folder,
    model_parameters=model_parameters,
)
Running HiGHS 1.16.0 (git hash: f3f113d): Copyright (c) 2026 under MIT licence terms
Includes third-party software components, see THIRD_PARTY_NOTICES.md for full details
LP linopy-problem-zw1ffy9b has 4172 rows; 3790 cols; 14736 nonzeros
Coefficient ranges:
  Matrix  [1e-01, 9e+05]
  Cost    [1e+00, 1e+00]
  Cost    [1e+00, 9e+05] (effective)
  Bound   [0e+00, 0e+00]
  RHS     [1e+00, 1e+03]
Presolving model
4172 rows, 3790 cols, 14736 nonzeros 0s
Initial sweep identifies 0 + 1128 + 0 = 1128 / 4172 empty + singleton + redundant rows
2244 rows, 2166 cols, 7792 nonzeros 0s
Considering dependency of 304 equations in 864 variables with 1152 nonzeros
Dependent equations search removed 0 equations and 0 nonzeros
2068 rows, 2014 cols, 7704 nonzeros 0s
Presolve reductions: rows 2068(-2104); columns 2014(-1776); nonzeros 7704(-7032)
Solving the presolved LP
Choosing to use dual simplex solver
Using dual simplex solver
  Iteration        Objective     Infeasibilities num(sum)
          0     5.6762407385e-02 Pr: 280(29008) 0.0s
        764     3.8396016000e+05 Pr: 0(0) 0.0s
Performed postsolve
Solving the original LP from the solution after postsolve
Model name          : linopy-problem-zw1ffy9b
Model status        : Optimal
Simplex   iterations: 764
Objective value     :  3.8396016000e+05
P-D objective error :  0.0000000000e+00
HiGHS run time      :          0.03
Results   written to /pommes/pommes/examples/test_case/output/ref_02161113    36.0 s
[6]:
solution = model.solution
print(model.solution)
<xarray.Dataset> Size: 82kB
Dimensions:                                 (area: 2, hour: 10, resource: 4,
                                             year_op: 4, conversion_tech: 5,
                                             year_dec: 6, year_inv: 5,
                                             storage_tech: 3, link: 2,
                                             transport_tech: 3,
                                             combined_tech: 1, mode: 2,
                                             hour_type: 5)
Coordinates: (12/13)
  * area                                    (area) <U6 48B 'area_1' 'area_2'
  * hour                                    (hour) int64 80B 0 1 2 3 4 5 6 7 8 9
  * resource                                (resource) <U11 176B 'electricity...
  * year_op                                 (year_op) int64 32B 2020 ... 2050
  * conversion_tech                         (conversion_tech) <U12 240B 'elec...
  * year_dec                                (year_dec) int64 48B 2020 ... 2070
    ...                                      ...
  * storage_tech                            (storage_tech) <U13 156B 'battery...
  * link                                    (link) object 16B 'link_1' 'link_2'
  * transport_tech                          (transport_tech) <U16 192B 'big_m...
  * combined_tech                           (combined_tech) <U15 60B 'electri...
  * mode                                    (mode) object 16B 'electric' 'fos...
  * hour_type                               (hour_type) object 40B 'HCE' ... 'P'
Data variables: (12/47)
    operation_load_shedding_power           (area, hour, resource, year_op) float64 3kB ...
    operation_spillage_power                (area, hour, resource, year_op) float64 3kB ...
    operation_load_shedding_costs           (area, year_op) float64 64B -0.0 ...
    operation_spillage_costs                (area, year_op) float64 64B -0.0 ...
    annualised_totex                        (area, year_op) float64 64B 4.831...
    operation_conversion_power_capacity     (area, conversion_tech, year_op) float64 320B ...
    ...                                      ...
    operation_storage_net_generation        (area, hour, storage_tech, resource, year_op) float64 8kB ...
    operation_transport_net_generation      (area, hour, transport_tech, resource, year_op) float64 8kB ...
    operation_combined_net_generation       (area, combined_tech, hour, resource, year_op) float64 3kB ...
    operation_net_import_net_generation     (area, hour, resource, year_op) float64 3kB ...
    operation_carbon_emissions              (area, hour, year_op) float64 640B ...
    operation_total_carbon_emissions        (area, hour, year_op) float64 640B ...
Attributes:
    pommes_catalogue:  {"variables":[{"name":"operation_load_shedding_power",...
[7]:
dual = model.dual
print(dual)
<xarray.Dataset> Size: 41kB
Dimensions:                                               (area: 2, hour: 10,
                                                           resource: 4,
                                                           year_op: 4,
                                                           conversion_tech: 5,
                                                           year_inv: 5,
                                                           storage_tech: 3,
                                                           link: 2,
                                                           transport_tech: 3,
                                                           combined_tech: 1,
                                                           hour_type: 5,
                                                           flexibility_window: 4)
Coordinates:
  * area                                                  (area) object 16B '...
  * hour                                                  (hour) int64 80B 0 ...
  * resource                                              (resource) object 32B ...
  * year_op                                               (year_op) int64 32B ...
  * conversion_tech                                       (conversion_tech) object 40B ...
  * year_inv                                              (year_inv) int64 40B ...
  * storage_tech                                          (storage_tech) object 24B ...
  * link                                                  (link) object 16B '...
  * transport_tech                                        (transport_tech) object 24B ...
  * combined_tech                                         (combined_tech) object 8B ...
  * hour_type                                             (hour_type) <U3 60B ...
  * flexibility_window                                    (flexibility_window) int64 32B ...
Data variables: (12/47)
    operation_adequacy_constraint                         (area, hour, resource, year_op) float64 3kB ...
    operation_load_shedding_costs_def                     (area, year_op) float64 64B ...
    operation_spillage_costs_def                          (area, year_op) float64 64B ...
    annualised_totex_def                                  (area, year_op) float64 64B ...
    operation_conversion_power_max_constraint             (area, conversion_tech, hour, year_op) float64 3kB ...
    operation_conversion_must_run_constraint_equality     (area, conversion_tech, hour, year_op) float64 3kB ...
    ...                                                    ...
    operation_flexibility_demand_max                      (area, resource, hour, year_op) float64 3kB ...
    operation_flexibility_demand_min                      (area, resource, hour, year_op) float64 3kB ...
    operation_flexibility_demand_conservation             (area, resource, year_op) float64 256B ...
    operation_flexibility_conservation_2h                 (area, resource, flexibility_window, year_op) float64 1kB ...
    operation_flexibility_displaced_demand_def            (area, resource, hour, year_op) float64 3kB ...
    operation_flexibility_costs_def                       (area, resource, year_op) float64 256B ...
[8]:
prices = dual.operation_adequacy_constraint
df = prices.to_dataframe(name="value").reset_index()
print(df)
       area  hour     resource  year_op  value
0    area_1     0  electricity     2020   -0.0
1    area_1     0  electricity     2030   -0.0
2    area_1     0  electricity     2040   -0.0
3    area_1     0  electricity     2050   -0.0
4    area_1     0         heat     2020  876.0
..      ...   ...          ...      ...    ...
315  area_2     9     hydrogen     2050   12.5
316  area_2     9      methane     2020   -0.0
317  area_2     9      methane     2030   -0.0
318  area_2     9      methane     2040   -0.0
319  area_2     9      methane     2050   -0.0

[320 rows x 5 columns]
[9]:
unique_resources = df["resource"].unique()
unique_years = df["year_op"].unique()
unique_areas = df["area"].unique()
colors = plt.cm.tab10(range(len(unique_areas)))
area_color_map = {area: colors[i] for i, area in enumerate(unique_areas)}

fig, axes = plt.subplots(
    len(unique_resources),
    len(unique_years),
    figsize=(15, 10),
    sharex=True,
    sharey="row",
)

for i, resource in enumerate(unique_resources):
    for j, year in enumerate(unique_years):
        ax = axes[i, j]
        subset = df[(df["resource"] == resource) & (df["year_op"] == year)]

        for area in unique_areas:
            area_data = subset[subset["area"] == area]
            if not area_data.empty:
                ax.plot(
                    area_data["hour"],
                    area_data["value"],
                    marker="o",
                    color=area_color_map[area],
                )
        if i == 0:
            ax.set_title(f"Year: {year}")
        if j == 0:
            ax.set_ylabel(f"Resource: {resource}")
        if i == len(unique_resources) - 1:
            ax.set_xlabel("Hour")

legend_elements = [
    plt.Line2D(
        [0],
        [0],
        marker="o",
        color=color,
        linestyle="",
        markersize=8,
        label=area,
    )
    for area, color in area_color_map.items()
]
fig.legend(
    handles=legend_elements,
    loc="upper center",
    ncol=len(unique_areas),
    title="Area",
)

plt.tight_layout(rect=(0, 0, 1, 0.95))
plt.show()
../_images/notebooks_example_notebook_9_0.png
[ ]: