Skip to content

Commit 9818b70

Browse files
committed
re-introduce unmet demand in spores objective; remove hardcoded spores parameter setting
1 parent 2ef3380 commit 9818b70

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/calliope/math/spores.yaml

+12-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,17 @@ global_expressions:
1919

2020
objectives:
2121
min_spores:
22-
description: >-
23-
SPORES score minimisation objective, activated for all iterations after the baseline optimisation.
24-
The SPORES scores are applied to flow capacity for each technology at each node.
2522
equations:
26-
- expression: sum(flow_cap * spores_score, over=[nodes, techs, carriers])
23+
- expression: sum(flow_cap * spores_score, over=[nodes, techs, carriers]) + $unmet_demand
24+
sub_expressions:
25+
unmet_demand:
26+
- where: "config.ensure_feasibility=True"
27+
expression: >-
28+
sum(
29+
sum(unmet_demand - unused_supply, over=[carriers, nodes])
30+
* timestep_weights,
31+
over=timesteps
32+
) * bigM
33+
- where: "NOT config.ensure_feasibility=True"
34+
expression: "0"
2735
sense: minimise

src/calliope/model.py

-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from pathlib import Path
99
from typing import TYPE_CHECKING
1010

11-
import numpy as np
1211
import pandas as pd
1312
import xarray as xr
1413

@@ -263,16 +262,6 @@ def build(
263262
"there exist non-uniform timesteps (e.g. from time clustering)"
264263
)
265264
backend_input = self._prepare_operate_mode_inputs(self.config.build.operate)
266-
elif mode == "spores":
267-
backend_input = self._model_data.copy()
268-
if "spores_score" not in backend_input:
269-
backend_input["spores_score"] = xr.DataArray(0).assign_attrs(
270-
is_result=0
271-
)
272-
if "spores_baseline_cost" not in backend_input:
273-
backend_input["spores_baseline_cost"] = xr.DataArray(
274-
np.inf
275-
).assign_attrs(is_result=0)
276265
else:
277266
backend_input = self._model_data
278267

0 commit comments

Comments
 (0)