Main Content

Examine prediction model and custom functions of `nlmpc`

or
`nlmpcMultistage`

objects for potential problems

`validateFunctions`

tests the prediction model, custom cost,
custom constraint, and Jacobian functions of a nonlinear MPC controller for potential problems
such as whether information is missing, whether input and output arguments of any user
supplied functions are incompatible with object settings or whether user supplied analytical
gradient/Jacobian functions are numerically accurate. When you first design your nonlinear MPC
controller, or when you make significant changes to an existing controller, it is best
practice to validate your controller functions.

`validateFcns(`

tests the functions of nonlinear MPC controller `nlmpcobj`

,`x`

,`mv`

)`nlmpcobj`

for
potential problems. The functions are tested using specified state and manipulated
variable values, `x`

and `mv`

, respectively. These
values can represent nominal conditions or an arbitrary operating point. Use this syntax
if your controller has no measured disturbances and no parameters.

`validateFcns(`

specifies parameter values. If your controller has parameters, you must specify
`nlmpcobj`

,`x`

,`mv`

,`md`

,`parameters`

)`parameters`

.

`validateFcns(`

tests the functions of multistage nonlinear MPC controller `nlmpcMSobj`

,`x`

,`mv`

)`nlmpcMSobj`

for potential problems. The functions are tested using the specified state and manipulated
variable values, `x`

and `mv`

, respectively. These
values can represent nominal conditions or an arbitrary operating point. Use this syntax
if your controller has no measured disturbances and no parameters.

`validateFcns(`

specifies the additional `nlmpcMSobj`

,`x`

,`mv`

,`simdata`

)`simdata`

structure. If parameters are needed
for the state and stage functions, you need to provide them in
`simdata`

.

When you provide your own analytical Jacobian functions, it is especially important that these functions return valid Jacobian values. If

`validateFunctions`

detects large differences between the values returned by your user-defined Jacobian functions and the finite-difference approximation, verify the code in your Jacobian implementations.

For each controller function, `validateFunctions`

checks whether the
function:

Exists on the MATLAB

^{®}pathHas the required number of input arguments

Can be executed successfully without errors

Returns the output arguments with the correct size and dimensions

Returns valid numerical data; that is, it does not return

`Inf`

or`NaN`

values

For Jacobian functions, `validateFunctions`

checks whether the returned
values are comparable to a finite-difference approximation of the Jacobian values. These
finite-difference values are computed using numerical perturbation.