agentlib_mpc.utils package
Subpackages
Submodules
agentlib_mpc.utils.analysis module
- agentlib_mpc.utils.analysis.admm_at_time_step(data: DataFrame | Series, time_step: float = None, variable=None, iteration: float = -1, index_offset: float | Literal['auto'] | bool = True, convert_to: Literal['seconds', 'minutes', 'hours', 'days'] = 'seconds') DataFrame [source]
Gets the results of an optimization at a time step. :param index_offset: Determines how the index will be updated when loading the data. :param The offset will be subtracted from the time-index. This is useful for results: :param of realtime systems: to cut the number down to something understandable. For example, if the time
index (level 0 of the input Dataframe) is [105, 115, 125] and we give an index_offset of 100, the data will be handled as if the index was [5, 15, 25].
- If “auto” or True is provided as an argument, the index will be modified to
start at 0. If 0 or False are provided, no modifications will be made.
- Parameters:
want (where the time value with be a unix time stamp and we) –
to cut the number down to something understandable. For example, if the time index (level 0 of the input Dataframe) is [105, 115, 125] and we give an index_offset of 100, the data will be handled as if the index was [5, 15, 25].
- If “auto” or True is provided as an argument, the index will be modified to
start at 0. If 0 or False are provided, no modifications will be made.
data – The multi-indexed results data frame from the mpc
time_step – The time step from which results should be shown. If no exact match, shows closest.
variable – If specified, only returns results with regard to a certain variable.
iteration – Specifies, from which inner ADMM iteration data should be from. If negative, counts from last iteration. Default -1.
convert_to – Whether the data should be converted to datetime, minutes etc.
- Returns:
A single-indexed Dataframe of the optimization results at the specified time step. If variable is not specified, returns all variables with a double column index, if it is specified returns only values and/or bounds with single indexed columns.
- agentlib_mpc.utils.analysis.convert_index(convert_to: Literal['seconds', 'minutes', 'hours', 'days'] | Literal['datetime'], index: Index)[source]
Converts an index from seconds to datetime or another unit :param convert_to: unit, e.g. minutes, hours, datetime :param index: pandas index object
Returns:
- agentlib_mpc.utils.analysis.convert_multi_index(data: DataFrame, convert_to: Literal['seconds', 'minutes', 'hours', 'days'] | Literal['datetime'])[source]
Converts an index of an MPC or ADMM results Dataframe to a different unit, assuming it is passed in seconds.
- agentlib_mpc.utils.analysis.first_vals_at_trajectory_index(data: DataFrame | Series)[source]
Gets the first values at each time step of a results trajectory.
- agentlib_mpc.utils.analysis.get_number_of_iterations(data: DataFrame) dict[agentlib_mpc.utils.analysis.SimulationTime, int] [source]
Returns the number of iterations at each time instance of the ADMM simulation.
- agentlib_mpc.utils.analysis.get_time_steps(data: DataFrame) Iterable[float] [source]
Returns the time steps at which an MPC step was performed.
- agentlib_mpc.utils.analysis.last_vals_at_trajectory_index(data: DataFrame | Series)[source]
Gets the last values at each time step of a results trajectory.
- agentlib_mpc.utils.analysis.mpc_at_time_step(data: DataFrame, time_step: float, variable=None, variable_type='variable', index_offset: float | Literal['auto'] | bool = True) DataFrame [source]
Gets the results of an optimization at a time step.
- Parameters:
data – The multi-indexed results data frame from the mpc
time_step – The time step from which results should be shown. If no exact match, shows closest.
variable – If specified, only returns results with regard to a certain variable.
variable_type – The type of the variable provided (parameter, variable, lower, …)
index_offset – Determines how the index will be updated when loading the data.
results (The offset will be subtracted from the time-index. This is useful for) –
systems (of realtime) –
to cut the number down to something understandable. For example, if the time index (level 0 of the input Dataframe) is [105, 115, 125] and we give an index_offset of 100, the data will be handled as if the index was [5, 15, 25].
- If “auto” or True is provided as an argument, the index will be modified to
start at 0. If 0 or False are provided, no modifications will be made.
want (where the time value with be a unix time stamp and we) –
to cut the number down to something understandable. For example, if the time index (level 0 of the input Dataframe) is [105, 115, 125] and we give an index_offset of 100, the data will be handled as if the index was [5, 15, 25].
- If “auto” or True is provided as an argument, the index will be modified to
start at 0. If 0 or False are provided, no modifications will be made.
- Returns:
- A single-indexed Dataframe of the optimization results
at the specified time step. If variable is not specified, returns all variables with a double column index, if it is specified returns only values and/or bounds with single indexed columns.
- Return type:
pd.DataFrame
agentlib_mpc.utils.debug module
Module contents
Package containing utils for agentlib_mpc.