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(`

specifies nominal 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 specified nominal state values,
`x`

, and manipulated variable values, `mv`

. Use
this syntax if your controller has no measured disturbances and no parameters.

`validateFcns(`

if parameters are needed for state and stage functions, you need to provide them in the
`nlmpcMSobj`

,`x`

,`mv`

,`simdata`

)`simdata`

structure.

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.