Skip to content

Commit

Permalink
Update SPORES objective; update math docs
Browse files Browse the repository at this point in the history
  • Loading branch information
brynpickering committed Feb 25, 2025
1 parent 86af532 commit 3611d75
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
11 changes: 9 additions & 2 deletions docs/hooks/dummy_model/model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ overrides:
time_cluster: cluster_days.csv
config.build:
add_math: ["storage_inter_cluster"]
spores:
config:
init.name: SPORES solve mode
build.mode: spores
solve.spores.number: 2
parameters:
spores_slack: 0.1

config.init.name: base

nodes:
A.techs: {demand_tech, conversion_tech, supply_tech, storage_tech}
B.techs: {demand_tech, conversion_tech, supply_tech, storage_tech}
A.techs: { demand_tech, conversion_tech, supply_tech, storage_tech }
B.techs: { demand_tech, conversion_tech, supply_tech, storage_tech }

techs:
tech_transmission:
Expand Down
8 changes: 6 additions & 2 deletions src/calliope/backend/latex_backend_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,7 @@ def generate_math_doc(
"yaml_snippet": da.attrs.get("yaml_snippet", None),
}
for name, da in sorted(getattr(self, objtype).data_vars.items())
if (objtype == "objectives" and name == self.objective)
or (objtype != "objectives" and "math_string" in da.attrs)
if ("math_string" in da.attrs)
or (objtype == "parameters" and da.attrs["references"])
]
for objtype in [
Expand All @@ -557,6 +556,11 @@ def generate_math_doc(
}
if "parameters" in components and not components["parameters"]:
del components["parameters"]
for objective in components.get("objectives", []):
if objective["name"] == self.objective:
objective["name"] += " (active)"
else:
objective["name"] += " (inactive)"
return self._render(
doc_template, mkdocs_features=mkdocs_features, components=components
)
Expand Down
16 changes: 4 additions & 12 deletions src/calliope/math/spores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,9 @@ global_expressions:

objectives:
min_spores:
description: >-
SPORES score minimisation objective, activated for all iterations after the baseline optimisation.
The SPORES scores are applied to flow capacity for each technology at each node.
equations:
- expression: sum(flow_cap * spores_score, over=[nodes, techs, carriers]) + $unmet_demand
sub_expressions:
unmet_demand:
- where: "config.ensure_feasibility=True"
expression: >-
sum(
sum(unmet_demand - unused_supply, over=[carriers, nodes])
* timestep_weights,
over=timesteps
) * bigM
- where: "NOT config.ensure_feasibility=True"
expression: "0"
- expression: sum(flow_cap * spores_score, over=[nodes, techs, carriers])
sense: minimise

0 comments on commit 3611d75

Please sign in to comment.