result

class result(x0, t0, h, N, K)[source]

Class used to store the simulation results of the MPC simulation.

To obtain the individual components of the simulation, such as closed loop and open loop results, the individual attributes need to be called.

Also the result object contains information about errors and other solver statistics, which can be used for further investigation of the simulation progress.

Additionally, this class provides a way to visualize the results in a suitable way with the plot() method.

Parameters:
  • x0 (array) – Initial state.

  • t0 (float) – Initial time.

  • h (float) – Sampling rate.

  • N (int) – MPC horizon.

  • K (int) – Number of MPC Interations.

Attributes

result.N

MPC horizon

result.ellapsed_time

Total ellapsed time for the closed loop simulation.

result.ellapsed_time_per_itertaion

List containing the ellapsed time of every single itertaion of the closed loop simulation.

result.error

Error message with which the solver failed.

result.l_cl

Stage costs evaluated at the closed loop trajectory and feedback.

result.l_ol

List containing the stage costs evaluated at the open loop trajectories and controls of all MPC itertaions.

result.sampling_rate

Sampling rate.

result.solver

Name of the choosen optimization method.

result.succes

True if the solver converged sucessfully in all MPC itertaions, false if the MPC loop abort prematurely.

result.sucessfull_itertaions

Number of succesfull MPC iterations.

result.t0

Initial time

result.t_cl

Time sequence at which the closed loop states and controls are evaluated.

result.t_ol

List containing the time sequences at which the closed loop states and controls are evaluated in the open loop simulations.

result.u_cl

Closed loop feedback.

result.u_ol

List containing the open loop optimal control values of all MPC itertaions.

result.x0

Initial state.

result.x_cl

Closed loop trajectory.

result.x_ol

List containing the open loop trajectories of all MPC itertaions.

Methods

result.load

Loads a nMPyC result object from a file.

result.plot

Plot the results of the MPC simulation.

result.save

Saving the result to a given file with dill.

result.show_errors

Shows the errors that occurred during the simualtion.