Labeling Concept
Tessif persues a quite unique approach when it comes to naming or labeling its system model components. Following sections provide details on how component labeling is implemented in tessif and how it’s features allow both, simple and comprehensive identification as well as aggregation of auxilliary information.
Bases
Each component that is part of an energy system modeled with the help of tessif must be uniquely identifiable. This is archieved by using unique identifiers (uids).
Apart from a name attribute which is mandatory, a uid incorporates several other optional parameters storing for example geographical infromation like latitude or longitude as well as simulative meta data like node_type.
Following statement serves as baseline for a component to qualify as unique:
Warning
For a component to be unique the overall combination of it’s internally used parameters must be unique.
Internal Representation
Each of tessif component has a uid with a complete set of parameters. This however does not mean every single one of those parameters is used internally for identification. In fact by default, only the name is used.
The configuration parameters node_uid_style and node_uid_seperator determine which parts of the uid are used for internal representation. And can be modified as in the example shown below
Example
Import the configurations module for modifying its attributes:
>>> import tessif.frused.configurations as configurationsImport and create a minimum working example using tessif-examples:
>>> from tessif_examples.basic import create_mwe >>> example_sys_mod = create_mwe()Check the current label settings:
>>> print(configurations.node_uid_style) name >>> print(configurations.node_uid_seperator) _Print the busses’
uids:>>> for bus in example_sys_mod.busses: ... print(bus.uid) Pipeline PowerlineCheck the
available settingsfor modifying thenode_uid_style:>>> from tessif.frused.namedtuples import node_uid_styles >>> for option in node_uid_styles: ... print(option) name qualname coords region sector carrier component node_typeModify the label settings to use geospatial coordinates for the internal representation as well:
>>> configurations.node_uid_style = 'coords'Print the busses’
uidsagain:>>> for bus in example_sys_mod.busses: ... print(bus.uid) Pipeline_0.0_0.0 Powerline_0.0_0.0Modify the seperator to modify the displayed representation:
>>> configurations.node_uid_seperator = '_(^0_0^)_'Print the busses’
uidsagain:>>> for bus in example_sys_mod.busses: ... print(bus.uid) Pipeline_(^0_0^)_0.0_(^0_0^)_0.0 Powerline_(^0_0^)_0.0_(^0_0^)_0.0Reset everything back to default:
>>> configurations.node_uid_style = 'name' >>> configurations.node_uid_seperator = '_'
Expansion
To expand tessif's labeling concept following 3 stept are recommonded:
Add your parameter to the class body of
tessif.frused.namedtuples.UidBaseas in:my_parameter: strAdd your parameter to the
__new__andsuper()call oftessif.frused.namedtuples.Uidas in:
__new__:def __new__(cls, ..., my_parameter=default_value)
super():self = super(cls,..., my_parameter)Modify
tessif.frused.namedtuples.node_uid_stylesto respect the new parameter as for example in:node_uid_styles = { 'name': ['name'], 'qualname': [i for i in Uid.__new__.__code__.co_varnames if i not in ['self', 'cls']], ... 'my_parameter: ['name', 'my_parameter'],}
Valuation
Realising a dynamic labeling concept involves several advantages and disadvantages of which the most predominant are listed in the following section. The comparisons drawn are to be interpreted as relative to a static labeling concept in which it’s up to the user to enforce unique hashable ids for each of the components.
Disadvantages
Using a
NamedTupleinstead of a plain string can involve overhead in computational ressources and memory usedIt is more complex for beginners to understand
Potentially not all of the supported plugins will be able to use such an approach
Advantages
Utilized label information can adapt to the complexity and size of the modelling task
Relatively simple expansion / modification
Individual information can be attached to the components without impacting the system model or the solver