energia.represent.model#

A Model

Functions

aspect_aliases(m)

Define aspect aliases for the model.

capacity_sizing(model)

Sets capacity sizing decisions

costing_commodity(model)

Sets costing parameters for resources

costing_operation(model)

Sets costing parameters for operations

dataclass([cls, init, repr, eq, order, ...])

Add dunder methods based on the fields defined in the class.

dump(obj, file[, protocol, byref, fmode, ...])

Pickle an object to a file.

economic(model)

Economic decisions

environmental(model)

Environmental impact decisions

free_movement(model)

Free movement entails consumption or release of resources This is an interaction with the system exterior

inventory_sizing(model)

Inventory management decisions

operating(model)

Operating/Scheduling decisions

social(model)

Social impact decisions

trade(model)

Trade decisions

usage(model)

Resource usage decisions

Classes

Callable()

Consequence(primary_type[, nn, ispos, neg, ...])

Consequence of an action

Control(primary_type[, nn, ispos, neg, ...])

Some action to be performed by a component that adjusts a state variable can have a consequence (Impact) or elicit a motion (Stream) that has a consequence (Impact)

Currency(*locs[, label, citations])

Same as Economic Impact (Eco)

Economic([label, citations])

Economic impact

Emission([basis, label, citations])

Environ([label, citations])

Environmental Impact

Game(model)

System representation as a Resource Task Network (RTN) All resources and tasks are attached to this object

Graph(model)

Graph representation

Impact(model)

A representation of the Consequence of the system dimensions based on the impact determined as the product of activity and indicators.

Instruction(name, kind, deciding, depending, ...)

Pre-set instructions to deal with parameter calculations

Interact()

Interaction between Players

Lag([of, periods])

A number of temporal Periods.

Land([basis, label, citations])

Land used by Operations

Linkage(source, sink[, dist, bi, auto, ...])

Linkage between two Locations.

Location(*has[, label, citations])

A discretization of Space.

Material([basis, label, citations])

Materials are Resources, that are used to set up Operations

Model([name, init, default, capacitate])

An abstract representation of an energy system.

Modes([size, sample, parent, n])

Represents a discrete choice to be taken within a spatiotemporal disposition.

Periods([size, of, n, label, citations])

A discretization of Time.

Player([label, citations])

Player or Actor, the one taking the decisions based on information provided

Problem(model)

Aspect (Decision) Tree.

Process(*args[, label, citations])

Process converts one Resource to another Resource at some Location

Program([name, tol, canonical, tag, model])

The mathematical program of the model

Recipe(name, kind, primary_type[, label, ...])

Recipe to create Aspects

Resource([basis, label, citations])

A resource, can be a material, chemical, energy, etc.

Scenario(model)

Scenario representation

Social([label, citations])

Social Impact

Space(model)

Spatial representation of the system.

State(primary_type[, nn, ispos, neg, latex, ...])

State Variable Operational capacity or set point (utilization)

Storage(*args[, label, citations])

Storage is a container for three main elements: 1.

Stream(primary_type[, nn, ispos, neg, ...])

Stream of Resource, also a state variable

System(model)

System representation as a Resource Task Network (RTN) All resources and tasks are attached to this object

TemporalScales(discretizations[, names])

A temporal scale for a model.

Time(model)

Temporal representation of a system.

Transport(*args[, label, citations])

Exports Resource through Link basically, moves Resources between Locations

Unit([basis, times, label])

Unit of measure for a quantity provided as input to a component

defaultdict

defaultdict(default_factory=None, /, [...]) --> dict with default factory

class Model(name: str = 'm', init: list[Callable[[Self]]] | None = None, default: bool = True, capacitate: bool = False)[source]#

Bases: object

An abstract representation of an energy system.

Parameters:
  • name (str) – Name of the Model. Defaults to m.

  • init (list[Callable], optional) – List of functions to initialize the Model. Defaults to None.

  • default (bool) – True if some default objects should be declared.

  • capacitate (bool) – True if process capacities should be determined to bound operations.

Variables:
  • added (list[str]) – List of added objects to the Model.

  • update_map (dict) – maps component type to representation and collection.

  • time (Time) – time representation of the Model.

  • space (Space) – spatial representation of the Model.

  • impact (Impact) – impact representation of the Model.

  • tree (Tree) – feasible region (Decision-Making) of the Model.

  • graph (Graph) – Graph (Network) of the Model.

  • system (System) – System (Resource Task Network) of the Model.

  • program (Program) – Mathematical (mixed integer) program of the Model.

  • conversions (list[Conversion]) – List of Balances in the Model.

  • convmatrix (dict[Process, dict[Resource, int | float | list]]) – Conversion matrix of the Model.

  • modes_dict (dict[Bind, Modes]) – Dictionary mapping Bind objects to Modes.

  • cookbook (dict[str, Recipe]) – Recipes to create Aspects.

  • directory (dict[str, dict[str, Recipe]]) – Map of attribute names to recipes for creating them.

  • classifiers (list[Enum]) – List of classifiers for the Model.

  • grb (DefaultDict[Commodity,DefaultDict[Location | Linkage, DefaultDict[Periods, list[Aspect]]]]) – Dictionary which tells you what aspects of resource have GRB {loc: time: []} and {time: loc: []}.

  • dispositions (dict[Aspect, dict[Commodity | Process | Storage | Transport, dict[Location | Linkage, dict[Periods, list[Aspect]]]]]) – Dictionary which tells you what aspects of what component have been bound at what location and time.

  • maps (dict[Aspect, dict[Domain, dict[str, list[Domain]]]]) – Maps of aspects to domains.

  • maps_report (dict[Aspect, dict[Domain, dict[str, list[Domain]]]]) – Maps of aspects to domains for reporting variables.

Siunits_set:

True if SI units have been set.

Raises:

ValueError – If an attribute name already exists in the Model.

name: str = 'm'#
init: list[Callable[[Self]]] | None = None#
default: bool = True#
capacitate: bool = False#
property problem: Problem#

The active problem

property graph: Graph#

The active graph

property program: Program#

The active program

property scenario: Scenario#

The active scenario

property game: Game#

The active game

property horizon: Periods#

Time horizon

property network: Location#

Encompassing Location

property indicators: list[Environ | Social | Economic]#

Impact indicators

property operations: list[Process | Storage | Transport]#

System operations

property aspects: list[Consequence | Stream | Control | State]#

Problem aspects

property domains: list[Domain]#

Problem domains

update(name: str, value: _X, represent: str, collection: str, aspects: list[str] | None = None)[source]#

Update the Model with a new value

Parameters:
  • name (str) – Name of the value to be added

  • value (X) – Value to be added

  • represent (str) – Representation to which the value belongs

  • collection (str) – Collection within the representation to which the value belongs

  • aspects (list[str], optional) – Aspects to be added to the value, defaults to None

Recipe(name: str, kind: Type[Aspect], primary_type: tuple[Type[_Component]] | Type[_Component], label: str = '', latex: str = '', add: str = '', add_latex: str = '', add_kind: Type[Aspect] | None = None, sub: str = '', sub_latex: str = '', sub_kind: Type[Aspect] | None = None, neg: str = '', neg_latex: str = '', neg_label: str = '', bound: str = '', ispos: bool = True, nn: bool = True, use_multiplier: bool = False)[source]#

Creates a Recipe and updates recipes

Parameters:
  • name (str) – Name of the aspect

  • kind (Type[Aspect]) – type of the aspect

  • primary_type (tuple[Type[_Component]] | Type[_Component]) – type of primary component

  • label (str, optional) – label for the aspect. Defaults to ‘’.

  • latex (str, optional) – LaTeX representation for the aspect. Defaults to None.

  • add (str, optional) – add control variable. Defaults to ‘’.

  • add_latex (str, optional) – LaTeX representation for the add aspect. Defaults to ‘’.

  • add_kind (Type[Aspect], optional) – type of the add aspect. Defaults to None.

  • sub (str, optional) – sub control variable. Defaults to ‘’.

  • sub_latex (str, optional) – LaTeX representation for the sub aspect. Defaults to ‘’.

  • sub_kind (Type[Aspect], optional) – type of the sub aspect. Defaults to None.

  • neg (str, optional) – name of the negative aspect. Defaults to ‘’.

  • neg_latex (str, optional) – LaTeX representation for the negative aspect. Defaults to ‘’.

  • neg_label (str, optional) – label for the negative aspect. Defaults to ‘’.

  • bound (str, optional) – name of the bound aspect. Defaults to ‘’.

  • ispos (bool, optional) – whether the aspect is positive. Defaults to True.

  • nn (bool, optional) – whether the aspect is non-negative. Defaults to True.

  • use_multiplier (bool) – Use a scaler (such as distance) for calculations

alias(*names: str, of: str)[source]#

Set aspect aliases

Parameters:
  • names (str) – Names of the aliases

  • to (str) – Name of the aspect to which the aliases point

Instruction(name: str, kind: Type[_Component], deciding: str, depending: str, default: str, label: str = '', latex: str = '')[source]#

Creates an Instruction and updates the manual

Parameters:
  • deciding (str) – Name of the deciding aspect

  • depending (str) – Name of the depending aspect

  • default (str) – Name of the default component

  • label (str, optional) – Label for the parameter. Defaults to ‘’.

  • latex (str, optional) – LaTeX representation for the parameter. Defaults to ‘’.

declare(what: Type[_X], names: list[str])[source]#

Declares objects conveniently

Parameters:
  • what (Type[X]) – Type of object to be created

  • names (list[str]) – Names of the objects to be created

Link two Locations

Parameters:
  • source (Location) – Source Location

  • sink (Location) – Sink Location

  • dist (float | Unit, optional) – Distance between the Locations. Defaults to None.

  • bi (bool, optional) – Whether the linkage is bidirectional. Defaults to False.

TemporalScales(discretizations: list[int], names: list[str])[source]#

This is an easy way to define multiple time periods (scales)

Parameters:
  • discretizations (list[int]) – List of discretizations for the temporal scale.

  • names (list[str], optional) – Names of the discretizations. Defaults to [t<i>] for each discretization.

Modes(size: int, sample: Sample)[source]#

This is an easy way to define modes within a period

Parameters:
  • size (int) – Number of modes to create

  • name (str, optional) – Name of the modes. Defaults to “modes”.

show(descriptive: bool = False, categorical: bool = True, category: str = '')[source]#

Pretty print the Model

Parameters:
  • descriptive (bool, optional) – Whether to show descriptive information. Defaults to False.

  • categorical (bool, optional) – Whether to group by category. Defaults to True.

  • category (str, optional) – If provided, shows only this category. Defaults to None.

draw(variable: Aspect | Sample | None = None, n_sol: int = 0)[source]#

Draw the solution for a variable

Parameters:
  • variable (Aspect | Sample | None, optional) – Variable to draw. Defaults to None.

  • n_sol (int, optional) – Solution number to draw. Defaults to 0.

output(n_sol: int = 0, slack: bool = True, compare: bool = False)[source]#

Solution

locate(*operations: Process | Storage)[source]#

Locate operations in the network

Parameters:

operations (Process | Storage) – Operations to locate

solve(using: Literal['combinatorial', 'combinatorial_parallel', 'combinatorial_parallel_exp', 'graph', 'graph_exp', 'graph_parallel', 'graph_parallel_exp', 'combinatorial_graph', 'geometric', 'geometric_parallel', 'geometric_parallel_exp'] = 'combinatorial')[source]#

Solve the multiparametric program

Parameters:

using (Literal) – The solving method to use. Defaults to “combinatorial”.

eval(*theta_vals: float, n_sol: int = 0, roundoff: int = 4) list[float][source]#

Evaluate the objective function at given theta values

Parameters:
  • theta_vals (float) – values for the parametric variables

  • n_sol (int, optional) – solution number to evaluate, defaults to 0

  • roundoff (int, optional) – number of decimal places to round off to, defaults to 4

Returns:

list of objective function values

Return type:

list[float]

save(as_type: str = 'dill')[source]#

Save the Model to a file