direct_data_driven_mpc.utilities.controller.initial_data_generation

direct_data_driven_mpc.utilities.controller.initial_data_generation#

Functions for generating initial input-output data from a system.

This module provides functions for generating input-output data from both LTI and nonlinear systems, and randomizing the initial state of LTI systems.

Functions

generate_initial_input_output_data(...)

Generate input-output trajectory data from a system using Data-Driven MPC controller parameters.

randomize_initial_system_state(system_model, ...)

Randomly generate a plausible initial state for a Linear Time-Invariant (LTI) system model.

simulate_n_input_output_measurements(...)

Simulate a control input setpoint applied to a system over n (the estimated system order) time steps and return the resulting input-output data sequences.

randomize_initial_system_state(system_model: LTIModel, controller_config: LTIDataDrivenMPCParams, np_random: Generator) ndarray[source]#

Randomly generate a plausible initial state for a Linear Time-Invariant (LTI) system model.

This function initializes the system state with random values within the [-1, 1] range. Afterward, it simulates the system using random input and noise sequences to generate an input-output trajectory, which is then used to estimate the initial system state.

Note

The random input sequence is generated based on the u_range parameter from the controller configuration (controller_config). The noise sequence is generated considering the defined noise bounds from the system.

Parameters:
  • system_model (LTIModel) – An LTIModel instance representing a Linear Time-Invariant (LTI) system.

  • controller_config (LTIDataDrivenMPCParams) – A dictionary containing parameters for a Data-Driven MPC controller designed for Linear Time-Invariant (LTI) systems, including the range of the persistently exciting input (u_range).

  • np_random (Generator) – A Numpy random number generator for generating the random initial system state, persistently exciting input, and system output noise.

Returns:

np.ndarray – A vector of shape (n, ) representing the estimated initial state of the system, where n is the system’s order.

generate_initial_input_output_data(system_model: LTIModel | NonlinearSystem, controller_config: LTIDataDrivenMPCParams | NonlinearDataDrivenMPCParams, np_random: Generator) tuple[ndarray, ndarray][source]#

Generate input-output trajectory data from a system using Data-Driven MPC controller parameters.

This function generates a persistently exciting input u_d and random noise based on the specified controller and system parameters. Then, it simulates the system using these input and noise sequences to generate the output response y_d. The resulting u_d and y_d arrays represent the input-output trajectory data measured from the system, which is necessary for system characterization in a Data-Driven MPC formulation.

Parameters:
  • system_model (LTIModel | NonlinearSystem) – An instance of LTIModel, representing a Linear Time-Invariant (LTI) system, or NonlinearSystem, representing a nonlinear system.

  • controller_config (DataDrivenMPCParams) – A dictionary containing parameters for a Data-Driven MPC controller designed for Linear Time-Invariant (LTI) or nonlinear systems. Includes the initial input-output trajectory length (N) and the range of the persistently exciting input (u_range).

  • np_random (Generator) – A Numpy random number generator for generating the persistently exciting input and random noise for the system’s output.

Returns:

tuple[np.ndarray, np.ndarray] – A tuple containing two arrays: a persistently exciting input (u_d) and the system’s output response (y_d). The input array has shape (N, m) and the output array has shape (N, p), where N is the trajectory length, m is the number of control inputs, and p is the number of system outputs.

simulate_n_input_output_measurements(system_model: LTIModel, controller_config: LTIDataDrivenMPCParams, np_random: Generator) tuple[ndarray, ndarray][source]#

Simulate a control input setpoint applied to a system over n (the estimated system order) time steps and return the resulting input-output data sequences.

This function retrieves the control input setpoint (u_s) and the estimated system order (n) from a Data-Driven MPC controller configuration. Then, it simulates the system using a constant input u_s and random output noise over n time steps. The resulting input-output trajectory can be used to update the past n input-output measurements of a previously initialized Data-Driven MPC controller, allowing it to operate on a system with a different state.

Note

This function is used for scenarios where a Data-Driven MPC controller has been initialized but needs to be adjusted to match different system states.

Parameters:
  • system_model (LTIModel) – An LTIModel instance representing a Linear Time-Invariant (LTI) system.

  • controller_config (LTIDataDrivenMPCParams) – A dictionary containing parameters for a Data-Driven MPC controller designed for Linear Time-Invariant (LTI) systems, including the estimated system order (n) and the control input setpoint (u_s).

  • np_random (Generator) – A Numpy random number generator for generating random noise for the system’s output.

Returns:

tuple[np.ndarray, np.ndarray] – A tuple containing two arrays:

  • An array of shape (n, m) representing the constant input setpoint applied to the system over n time steps, where n is the system order and m is the number of control inputs.

  • An array of shape (n, p) representing the output response of the system, where n is the system order and p is the number of system outputs.