commonpower.models.buses.EnergyCommunity

class EnergyCommunity(name: str, config: dict = {})[source]

Bases: StructureNode

Structure node representing an energy community.

Traceback (most recent call last):
  File "<input>", line 1, in <module>
ModuleNotFoundError: No module named 'commonpower.models.busses'
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'EnergyCommunity' is not defined

Structure nodes model abstract entities such as energy communities, P2P markets, etc. They do not implement any physical characteristcs and are ignored in the power flow constraints.

Parameters:
  • name (str) – Name of the StructureNode object.

  • config (dict, optional) – Configuration for defined model elements. Defaults to {}.

Methods

add_data_provider

Adds a data provider to the entity.

add_node

Adds a subordinate bus.

add_to_model

This method adds the calling entity to the given (global) pyomo model. To this end, we - declare and add a new pyomo block named by self.id (the entity's global id). - call _get_model_elements() to retrieve the entity's model elements (variables and parameters). - call _augment_model_elements() to add additional model elements (constraints etc.). - check the configuration dict for completeness based on the defined model elements. - add all model elements to the previously declared pyomo block.

clear_data_providers

compute_cost

Computes the cost based on the specified cost_fcn and stores the result in the node's cost parameter.

cost_fcn

detach_controller

Remove the current controller from the entity

empty_copy

Creates a fresh copy of the node.

fix_inputs

Set the variables corresponding to inputs to fixed

get_children

get_input_ids

Get identifiers of input elements of a given model instance or self :param model_instance: model to get the input element identifiers for

get_inputs

Extracts model elements of type INPUT from a given model instance or self :param model_instance: model to get the input elements for :type model_instance: ConcreteModel, Optional

get_pyomo_element

Gets a pyomo element referenced by name from the given model.

get_pyomo_element_id

Constructs the global element name from the local name.

get_self_as_pyomo_block

Retrieves the pyomo block of the calling entity from a global model (based on the entity's global id).

get_value

Gets the value of the specified model element.

has_pyomo_element

This is essentially an indicator wrapper around get_pyomo_element() which returns False if no corresponding model element could be found (instead of raising an error).

info

Prints some information about this entity.

input_space

Determines the input space of an entity from the bounds of all model elements with type INPUT within the tree :param normalize: Whether or not to normalize the input space to [-1,1] :type normalize: bool

n_inputs

Total number of model elements with type INPUT within the entire tree of this entity

observation_space

Determines the observation space of an entity based on the observation mask by retrieving the bounds of the model elements listed in the mask

observe

Get observations for one node within the system based on the model items within the observation mask.

register_controller

Register a controller with this node :param controller: controller to be registered :type controller: BaseController

reset

Stores the current global model instance and initializes parameters according to their configuration.

set_id

Generates and sets the node id.

set_value

Sets the value of the specified model element to the specified value.

unmodeled_update

System updates that are not modeled.

update

This reads data providers and executes the dynamics of self and all subordinate nodes.

update_data

Reads data providers for self and all subnodes.

validate_controller

Used to check whether all nodes which require a controller have one assigned.

validate_data_providers

Validates if data providers have compatible configurations.

Attributes

CLASS_INDEX

_get_additional_constraints() List[ModelElement][source]

Returns additional constraints on model variables. This is a utility to keep the _get_model_elements() method clean.

Returns:

List[ModelElement] – List of additional constraint elements.

classmethod _get_model_elements() List[ModelElement][source]

This is the central method which all subclasses must implement. Here, the model elements of the entity are defined. For clarity, specify main variables and parameters here and specify constraints and auxiliary variables in _augment_model_elements().

Returns:

list[ModelElement] – List of model elements which will represent the entity in the pyomo model.

add_node(node: Bus) Node[source]

Adds a subordinate bus. The added node’s id is set according to its position in the model hierarchy. The passed node is flagged as structure member.

Parameters:

node (Bus) – Bus istance to add.

Returns:

Node – Node instance.

cost_fcn(scenario: CostScenario, model: ConcreteModel, t: int) Expression[source]
\[cost = \sum_{j \in coalition} \sum_{i \in components} cost_ji + \sum_{j \in coalition} (p_j) * psi\]