Basics of the model structure

In SpineOpt.jl, the model structure is generated based on the input data, allowing it to be used for a multitude of different problems. Here, we aim to provide you with a basic understanding of the SpineOpt.jl model and data structure, while the Entity Classes, Parameters, and Parameter Value Lists sections provide more in-depth explanations of each concept.

All the building blocks of a model are entities, and each entity belongs to one of the Entity Classes. Zero-dimensional entity classes, such as unit or node, hold the individual things in the model. Multidimensional entity classes, such as unit__to_node, combine two or more entity classes and define how their entities are related to each other. The dimensions of a multidimensional entity class are separated by a double underscore in its name. In the Spine DB editor, both kinds are shown in the Entity tree and created with Add entities....

Note

Older versions of Spine Toolbox and SpineOpt called zero-dimensional entity classes object classes and multidimensional entity classes relationship classes. You may still come across these terms in older material.

Introduction to zero-dimensional entity classes

Essentially, zero-dimensional Entity Classes represent different types of entities that make up the model. For example, every power plant in the model is represented as an entity of the class unit, every power line as an entity of the class connection, and so forth. In order to add anything new to a model, a new entity has to be added to the desired entity class in the input data.

Each entity class has a very specific purpose in SpineOpt.jl, so understanding their differences is key. These can be roughly divided into three distinctive groups, namely Systemic entity classes, Structural entity classes, and Meta entity classes.

Systemic entity classes

As the name implies, systemic entity classes are used to describe the system to be modelled. Essentially, they define what you want to model. These include:

  • connection handles the transfer of commodities between nodes.
  • grid represents different networks where different commodities can be generated, consumed, transported, etc.
  • node ensures the balance of the commodity flows, and can be used to store commodities as well.
  • unit handles the generation and consumption of commodities.

Structural entity classes

Structural entity classes are used to define the temporal and stochastic structure of the modelled problem, as well as custom User Constraints and groups of investments. Unlike the above Systemic entity classes, the structural entity classes are more about how you want to model, instead of strictly what you want to model. These include:

Meta entity classes

Meta entity classes are used for defining things on the level of models or above, like output and even other models for problem decompositions. These include:

Introduction to multidimensional entity classes

While zero-dimensional entity classes define all the entities that make up a model, multidimensional Entity Classes define how those entities are related to each other. Thus, they hold no meaning on their own, and always include at least one zero-dimensional entity class.

Similar to zero-dimensional entity classes, each multidimensional entity class has a very specific purpose in SpineOpt.jl, and understanding the purpose of each one is paramount. The multidimensional entity classes can be roughly divided into Systemic multidimensional entity classes, Structural multidimensional entity classes, and Meta multidimensional entity classes, again similar to the zero-dimensional ones.

Systemic multidimensional entity classes

Systemic multidimensional entity classes define how Systemic entity classes are related to each other, thus helping define the system to be modelled. Most of these deal with which units and connections interact with which nodes, and how those interactions work. This essentially defines the possible commodity flows to be modelled. Systemic multidimensional entity classes include:

Structural multidimensional entity classes

Structural multidimensional entity classes primarily relate Structural entity classes to Systemic entity classes, defining what structures the individual parts of the system use. These are mostly used to determine the temporal and stochastic structures to be used in different parts of the modelled system, or custom User Constraints.

SpineOpt.jl has a very flexible temporal and stochastic structure, explained in detail in the Temporal Framework and Stochastic Framework sections of the documentation. Unfortunately, this flexibility requires quite a few different structural multidimensional entity classes, the most important of which are the following:

Furthermore, there are also a number of advanced structural multidimensional entity classes, which are only necessary when using some of the optional features of SpineOpt.jl. For Investment Optimization, the following control the stochastic and temporal structures of the investment variables:

The following define which investments belong to an investment_group:

For User Constraints, which are essentially generic data-driven custom constraints, the following are used to control which variables are included and with what coefficients:

Meta multidimensional entity classes

Meta multidimensional entity classes are used for defining model-level settings, like which temporal_blocks or stochastic_structures are active, and what the model output is. These include:

For the experimental multi-stage optimisation (see the Multi-Stage Optimisation Tutorial):

Introduction to parameters

While the primary function of Entity Classes is to define the system to be modelled and its structure, Parameters exist to constrain them. Every parameter is attributed to at least one entity class, but some appear in many classes whenever they serve a similar purpose.

Parameters accept different types of values depending on their purpose, e.g. whether they act as a flag for some specific functionality or appear as a coefficient in Constraints, so understanding each parameter is key. Most coefficient-type Parameters accept constant, time series, and even stochastic time series form input, but there are some exceptions. Most flag-type Parameters, on the other hand, have a restricted list of acceptable values defined by their Parameter Value Lists.

The existence of some Constraints is controlled based on if the relevant Parameters are defined. As a rule-of-thumb, a constraint only gets generated if at least one of the Parameters appearing in it is defined, but one should refer to the appropriate Constraints and Parameters sections when in doubt.

Introduction to groups of entities

Groups of entities are used within SpineOpt for different purposes. To create a group of entities, simply right-click the corresponding entity class in the Entity tree of the Spine DB editor and select Add entity group.... Groups are essentially special entities, that act as a single handle for all of their members.

On the one hand, groups can be used in order to impose constraints on the aggregation of a variable, e.g. on the sum of multiple unit_flow variables. Constraints based on parameters associated with the unit_flow__unit_flow, unit__to_node, node__to_unit, connection__node__node, connection__to_node, connection__from_node can generally be used for this kind of flow aggregation by defining the parameters on groups of entities, typically node groups. (with the exception of variable fixing parameters, e.g. flow_limits_fix etc.). See for instance constraint_unit_flow_capacity.

On the other hand, a node group can be used for PTDF based powerflows. Here a node group is used to enforce a nodal balance on system level, while suppressing the node balances at individual nodes. See also balance_type and the node balance constraint.