import:
  - plan.yaml

constraints:
  total_system_cost_max:
    description: >
      Limit total system _monetary_ cost in SPORES mode.
      Applies a maximum relaxation to the system cost compared to the least-cost feasible option.
    foreach: [costs]
    where: "[monetary] in costs"
    equations:
      - expression: sum(cost, over=[nodes, techs]) <= spores_baseline_cost * (1 + spores_slack)

global_expressions:
  spores_score_cumulative:
    description: Track SPORES score to include in the model results
    foreach: [nodes, techs, carriers]
    equations:
      - expression: spores_score

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"
    sense: minimise
