Power Systems Backend

The power system backend is an essential part of this library. It allows to rely on power system packages (such as pandapower and pypowsybl) for the loading of power grid files, the updating of power grid features, the power flow simulations, and the extraction of power grid features.

Backend interface

We have defined a common backend interface through the abstract base class ml4ps.backend.interface.AbstractBackend.

class ml4ps.backend.interface.AbstractBackend[source]

Abstract Power Systems backend.

Allows to load power grids, get and set features, and to interact with them through Power Flow simulations.

valid_extensions

List of valid file extensions that can be read by the backend. Should be overridden in a proper backend implementation.

Type:

list of str

valid_object_names

List of object names.

Type:

list of str

valid_address_names

Dictionary that contains all the valid object names as keys and valid address names for each of these keys. Should be overridden in a proper backend implementation.

Type:

dict of list of str

valid_feature_names

Dictionary that contains all the valid object names as keys and valid feature names for each of these keys. Should be overridden in a proper backend implementation.

Type:

dict of list of str

assert_names(feature_names=None, address_names=None)[source]

Asserts that object_names, feature_names and address_names are valid w.r.t. the backend.

get_data_batch(net_batch, **kwargs)[source]

Returns features from a batch of power grids.

abstract get_data_network(net, feature_names=None, address_names=None, address_to_int=True)[source]

Returns feature values from a single power grid instance.

Should be overridden in a proper backend implementation. Should be consistent with valid_data_structure.

get_valid_files(path, shuffle=False, n_samples=None)[source]

Gets file that have a valid extension w.r.t. the backend, from path.

abstract load_network(file_path)[source]

Loads a single power grid instance.

Should be overridden in a proper backend implementation. Should be consistent with valid_extensions.

run_batch(network_batch, **kwargs)[source]

Performs power flow computations for a batch of power grids.

abstract run_network(net, **kwargs)[source]

Performs a single power flow computation.

Should be overridden in a proper backend implementation.

save_batch(network_batch, path)[source]

Saves a batch of power grid instances in path.

abstract save_network(net, path)[source]

Saves a single power grid instance in path.

Should be overridden in a proper backend implementation.

set_data_batch(network_batch, y_batch)[source]

Modifies a batch of power grids with a batch of features.

abstract set_data_network(net, y)[source]

Modifies a power grid with the feature values contained in y.

Should be overridden in a proper backend implementation. Should be consistent with valid_feature_names.

Discrepancies between backends

Every power grid backend has its own naming conventions and electro-technical models. To give a concrete example, transformers are not modelled identically in pandapower and pypowsybl. As a consequence, they are not defined by the same features from one package to the other. Moreover, certain advanced features are only available in certain power grid packages.

Current implementations

For now, only pandapower and pypowsybl have compatible backend implementations in ml4ps. They can be accessed as follows :

import ml4ps as mp
pandapowerbackend = mp.PandaPowerBackend()
pypowsyblbackend = mp.PyPowSyblBackend()