# Simulator¶

class do_mpc.simulator.Simulator(model)[source]

A class for simulating systems. Discrete-time and continuous systems can be considered.

do-mpc uses the CasADi interface to popular state-of-the-art tools such as Sundials CVODES for the integration of ODE/DAE equations.

Configuration and setup:

Configuring and setting up the simulator involves the following steps:

1. Set parameters with set_param(), e.g. the sampling time.
2. Set parameter function with get_p_template() and set_p_fun().
3. Set time-varying parameter function with get_tvp_template() and set_tvp_fun().
4. Setup simulator with setup().

During runtime, call the simulator make_step() method with current input (u). This computes the next state of the system and the respective measurement. Optionally, pass (sampled) random variables for the process w and measurement noise v (if they were defined in :py:classdo_mpc.model.Model)

Attributes

 Simulator.t0 Current time marker of the class. Simulator.u0 Initial input and current iterate. Simulator.x0 Initial state and current iterate. Simulator.z0 Initial algebraic state and current iterate.

Methods

 Simulator.get_p_template Obtain output template for set_p_fun(). Simulator.get_tvp_template Obtain the output template for set_tvp_fun(). Simulator.make_step Main method of the simulator class during control runtime. Simulator.reset_history Reset the history of the simulator. Simulator.set_initial_guess Initial guess for DAE variables. Simulator.set_p_fun Method to set the function which gives the values of the parameters. Simulator.set_param Set the parameters for the simulator. Simulator.set_tvp_fun Method to set the function which returns the values of the time-varying parameters. Simulator.setup Sets up the simulator and finalizes the simulator configuration. Simulator.simulate Call the CasADi simulator.