mpcsolve

Solve the MPC Control Law for the optimal control input.

Syntax

[delu,iter,t] = mpcsolve(jMPCobj,del_xm,u,old_u,setp,mdist,k,tstart)

Description

[delu,iter,t] = mpcsolve(jMPCobj,del_xm,u,old_u,setp,mdist,k,tstart) uses current and previous model states and plant inputs, together with the Quadratic Program stored within the jMPC object, to solve for the next optimal control input increment, delu. This function requires the jMPC object, jMPCobj, the current state increment, del_xm, previous plant input, u, previous solution vector, old_u, the current setpoint, setp, the current measured disturbance, mdist, the current simulation time step, k, and the CPU time at which the function starts. The function returns a solution vector, del_u, the number of iterations required by the QP Solver, and a vector of the times taken by the various components of the function.

Note this function is not intended to be called directly by the user.

Functional Overview

The function performs 4 steps at every sample of the simulation:

StepOperationDescription
1Update QP Right Hand SideIn the current toolbox implementation, both H & A remain constant, while f & b have constant and dynamic parts. The dynamic parts are a function of the current state, setpoint, and previous input, and thus must be updated at every sample.
2Check Global MinimumIt is possible the global minimum (H\f) is also the constrained minimum, thus to save computation time and increase efficiency, the global minimum is checked against each constraint, and if it passes, will skip the QP solver.
3Shift previous solution vectorIf the global minimum is not also the constrained minimum, then the previous solution vector, old_u, is shifted one step toward the future and used to warm start the QP Solver.
4Solve QP for new solutionThe QP Solver selected is then used to solve for a new solution vector.