agentlib.models package

Submodules

agentlib.models.fmu_model module

This module contains the FMUModel class.

class agentlib.models.fmu_model.FmuModel(**kwargs)[source]

Bases: Model

Class to wrap any FMU Model into the Model-Standard of the agentlib.

do_step(*, t_start, t_sample=None)[source]

Performing one simulation step :param t_start: start time for integration :param t_sample: increment of solver integration

Returns:

property extract_fmu

Get whether the fmu shall be extracted to a new directory or if the temp folder is used.

initialize(**kwargs)[source]

Initializes FMU model

Required kwargs:

t_start (float): Start time of simulation t_stop (float): Stop time of simulation

set_input_values(names: List[str], values: List[float | int | bool])[source]

Sets input values in the model and in the FMU.

set_parameter_values(names: List[str], values: List[float | int | bool])[source]

Sets parameter values in the model and in the FMU.

terminate()[source]

Overwrite base method

property tolerance

Get the tolerance of FMU simulation

pydantic model agentlib.models.fmu_model.FmuModelConfig[source]

Bases: ModelConfig

The Config of FMUModels overwrite the default ModelConfig to redefine the system and add relevant fields like path and tolerance of the simulation.

Config:
  • validate_assignment: bool = True

  • arbitrary_types_allowed: bool = True

  • extra: str = forbid

Fields:
Validators:
field extract_fmu: bool = False
field log_fmu: bool = True
field only_config_variables: bool = True

If True, only the variables passed to this model by a simulator will be read and written at each simulation step (specified by dt).

field path: Path [Required]
Constraints:
  • path_type = file

Validated by:
field tolerance: float = 0.001
validator check_path  »  path[source]

Check if the path has the correct extension

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.models.scipy_model module

This module contains the ScipyStateSpaceModel class.

class agentlib.models.scipy_model.ScipyStateSpaceModel(**kwargs)[source]

Bases: Model

This class holds a scipy StateSpace model. It uses scipy.signal.lti as a system and the odeint as integrator.

do_step(*, t_start, t_sample=None)[source]

Performing one simulation step :param t_start: start time for integration :param t_sample: increment of solver integration

Returns:

initialize(**kwargs)[source]

Abstract method to define what to do in order to initialize the model in use.

pydantic model agentlib.models.scipy_model.ScipyStateSpaceModelConfig[source]

Bases: ModelConfig

Customize config of Model.

Config:
  • validate_assignment: bool = True

  • arbitrary_types_allowed: bool = True

  • extra: str = forbid

Fields:
Validators:
field system: dict | list | tuple | StateSpace [Required]
Validated by:
validator check_system  »  all fields[source]

Root validator to check if the given system is valid.

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.

Module contents

Package with available models for the agentlib

agentlib.models.get_model_type(model_type) type[source]

Return and load the given module type

Parameters:

str (model_type) – The string identifier to load the module.

Return type:

module BaseModelType