agentlib_mpc.modules package

This package contains all modules for the distributed model predictive control using multi agent systems.

It contains classes for local optimization and global coordination.

class agentlib_mpc.modules.ModuleImport(module_path: str, class_name: str)[source]

Bases: object

import_class()[source]

Subpackages

Submodules

agentlib_mpc.modules.data_source module

class agentlib_mpc.modules.data_source.DataSource(config: dict, agent: Agent)[source]

Bases: BaseModule

process()[source]

Write the current data values into data_broker every t_sample

register_callbacks()[source]

Don’t do anything as this module is not event-triggered

transform_index(data: DataFrame) DataFrame[source]

Handles the index and ensures it is numeric, with correct offset

pydantic model agentlib_mpc.modules.data_source.DataSourceConfig[source]

Bases: BaseModuleConfig

Config:
  • arbitrary_types_allowed: bool = True

  • validate_assignment: bool = True

  • extra: str = forbid

  • frozen: bool = True

Fields:
Validators:
field columns: List[str] | None = None

Optional list of columns of data frame that should be sent.If ommited, all datapoint in frame are sent.

field data: DataFrame | Path = Empty DataFrame Columns: [] Index: []

Data that should be communicated during execution.Index should be either numeric or Datetime, numeric values are interpreted as seconds.

Validated by:
field data_offset: Timedelta | float | None = 0

Offset will be subtracted from index.

field interpolation_method: InterpolationMethods | None = InterpolationMethods.previous

Interpolation method used for resampling of data.Only ‘linear’ and ‘previous’ are allowed.

Validated by:
field shared: bool | None = True

Indicates if the variable is going to be shared with other agents.

field t_sample: float | int = 1

Sample time of data source. Default is 1 s.

validator check_data  »  data[source]

Makes sure data is a data frame, and loads it if required.

validator check_interpolation_method  »  interpolation_method[source]
model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

agentlib_mpc.modules.ml_model_simulator module

Module contains the MLModelSimulator, used to simulate with ML-Models. The class inherits from the Simulator class from the agentlib core.

class agentlib_mpc.modules.ml_model_simulator.MLModelSimulator(*, config: dict, agent: Agent)[source]

Bases: Simulator

register_callbacks()[source]
pydantic model agentlib_mpc.modules.ml_model_simulator.MLModelSimulatorConfig[source]

Bases: SimulatorConfig

Config:
  • arbitrary_types_allowed: bool = True

  • validate_assignment: bool = True

  • extra: str = forbid

  • frozen: bool = True

Fields:
Validators:
field serialized_ml_models: List[AgentVariable] = []
validator check_t_sample  »  t_sample[source]

Check if t_sample is smaller than stop-start time

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.