calliope-project / calliope

A multi-scale energy systems modelling framework

Home Page:https://www.callio.pe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Restructuring of constraint internals

FraSanvit opened this issue · comments

Structure of constraints

Discussion about which structure is best suited. @brynpickering @jnnr

Option A (list of dicts):

constraints:
  - name: asynchronous_con_milp
    foreach: [nodes, techs, timesteps]
    where: "force_asynchronous_prod_con=True"
    equation: -1 * squeeze_carriers(carrier_con, carrier_tier=in) <= (1 - prod_con_switch) * bigM
variables:
  - name: storage
    foreach: [nodes, techs, timesteps]
    where: "(inheritance(storage) OR inheritance(supply_plus)) AND include_storage=True AND NOT model.time.function_options.storage_inter_cluster=True"
    bounds:
      min: 0
      max: .inf

Option B (dict of dicts):

constraints:
  asynchronous_con_milp:
    foreach: [nodes, techs, timesteps]
    where: "force_asynchronous_prod_con=True"
    equation: -1 * squeeze_carriers(carrier_con, carrier_tier=in) <= (1 - prod_con_switch) * bigM
    
variables:
  storage:
    foreach: [nodes, techs, timesteps]
    where: "(inheritance(storage) OR inheritance(supply_plus)) AND include_storage=True AND NOT model.time.function_options.storage_inter_cluster=True"
    bounds:
      min: 0
      max: .inf

Option A vs Option B
A wins:

  • matches standardised databse structure with its list of dicts
  • can pass a dict to a function and it has all the relevant info (i.e., it includes the component name by default)
  • easier to visually scan the YAML (probably)

B wins:

  • can use inbuilt AttrDict to override nested key:value pairs
  • on debugging, finding a specific constraint is easier, e.g., m.inputs.component_config["constraints"]["asynchronous_con_milp"] vs [i for i in m.inputs.component_config["constraints"] if i.name == "asynchronous_con_milp"]

Considering pros and cons of the two options, we go for Option B (for now) since it might be better suited in overriding structure pieces.

Follow-up discussion related to flattening technology configuration #362

Calliope version

Calliope v0.7.0

We agreed offline on option B, and the structure corresponding to option B is already in place in the main branch as of now, so this issue can be closed.