Main Content

# explicitMPC

Explicit model predictive controller

## Description

Explicit model predictive control uses offline computations to determine all operating regions in which the optimal control moves are determined by evaluating a linear function. Explicit MPC controllers require fewer run-time computations than traditional (implicit) model predictive controllers and are therefore useful for applications that require small sample times.

To implement explicit MPC, first design a traditional (implicit) model predictive controller for your application, and then use this controller to generate an explicit MPC controller for use in real-time control. For more information, see Design Workflow for Explicit MPC.

## Creation

To create an `explicitMPC` object:

1. Create an implicit MPC controller using an `mpc` object.

2. Define the operating range for the explicit MPC controller by creating a range structure using the `generateExplicitRange` function and specifying the bounds using dot notation.

3. Define the optimization options for converting the implicit controller into an explicit controller using the `generateExplicitOptions` function.

4. Create the explicit MPC controller based on the implicit controller, operating range, and optimization options using the `generateExplicitMPC` function.

## Properties

expand all

Implicit MPC controller, specified as an `mpc` object.

Parameter bounds that define the controller operating range, specified as a structure with the following fields.

FieldDescription
`State`Bounds on controller state values
`Reference`Bounds on controller reference signal values
`MeasuredDisturbance`Bounds on measured disturbance values
`ManipulatedVariable`Bounds on manipulated variable values

Define this property using the `range` input argument to the `generateExplicitMPC` function, which you create using the `generateExplicitRange` function and modify using dot notation. For detailed descriptions of the range parameters, see `generateExplicitRange`.

Optimization options for the conversion computation, specified as a structure with the following fields.

FieldDescription
`zerotol`Zero-detection tolerance
`removetol`Redundant-inequality-constraint detection tolerance
`flattol`Flat region detection tolerance
`normalizetol`Constraint normalization tolerance
`maxiterNNLS`Maximum number of NNLS solver iterations
`maxiterQP`Maximum number of QP solver iterations
`maxiterBS`Maximum number of bisection method iterations
`polyreduction`Method for removing redundant inequalities

Define this property using the `opt` input argument to the `generateExplicitMPC` function, which you create using the `generateExplicitOptions` function. For detailed descriptions of these options, see `generateExplicitOptions`.

Piecewise affine solution for the different operating regions, specified as a structure array with Nr elements, where Nr is the number of operating regions.

Each structure element contains fields defining the inequality constraints and control law for each region. For more information on the control law and constraints, see Design Workflow for Explicit MPC.

FieldDimensions
`F`Row vector of length Nx-by-Nmv.
`G`Column vector of length Nmv
`H`Nc-by-Nx array
`K`Column vector of length Nc

Here:

• Nx is the number of independent variables.

• Nmv is the number of manipulated variables.

• Nc is the number of inequality constraints for the region.

Flag indicating whether the explicit control law has been simplified using the `simplify` command. If the control law is simplified, it approximates the implicit MPC controller behavior. If the control law is not simplified, it should reproduce the implicit controller behavior exactly, provided both operate within the bounds described by the `Range` property.

## Object Functions

 `simplify` Reduce explicit MPC controller complexity and memory requirements `plotSection` Visualize explicit MPC control law as 2-D sectional plot `mpcmoveExplicit` Compute optimal control using explicit MPC `sim` Simulate an MPC controller in closed loop with a linear plant `mpcstate` MPC controller state `getCodeGenerationData` Create data structures for `mpcmoveCodeGeneration`

## Examples

collapse all

Generate an explicit MPC controller based upon a traditional MPC controller for a double-integrator plant.

Define the double-integrator plant.

`plant = tf(1,[1 0 0]);`

Create a traditional (implicit) MPC controller for this plant, with sample time 0.1, a prediction horizon of 10, and a control horizon of 3.

```Ts = 0.1; p = 10; m = 3; MPCobj = mpc(plant,Ts,p,m);```
```-->The "Weights.ManipulatedVariables" property of "mpc" object is empty. Assuming default 0.00000. -->The "Weights.ManipulatedVariablesRate" property of "mpc" object is empty. Assuming default 0.10000. -->The "Weights.OutputVariables" property of "mpc" object is empty. Assuming default 1.00000. ```

To generate an explicit MPC controller, you must specify the ranges of parameters such as state values and manipulated variables. To do so, generate a range structure. Then, modify values within the structure to the desired parameter ranges.

`range = generateExplicitRange(MPCobj);`
```-->Converting the "Model.Plant" property of "mpc" object to state-space. -->Converting model to discrete time. Assuming no disturbance added to measured output channel #1. -->The "Model.Noise" property of the "mpc" object is empty. Assuming white noise on each measured output channel. ```
```range.State.Min(:) = [-10;-10]; range.State.Max(:) = [10;10]; range.Reference.Min = -2; range.Reference.Max = 2; range.ManipulatedVariable.Min = -1.1; range.ManipulatedVariable.Max = 1.1;```

Use the more robust reduction method for the computation. Use `generateExplicitOptions` to create a default options set, and then modify the `polyreduction` option.

```opt = generateExplicitOptions(MPCobj); opt.polyreduction = 1;```

Generate the explicit MPC controller.

`EMPCobj = generateExplicitMPC(MPCobj,range,opt)`
``` Explicit MPC Controller --------------------------------------------- Controller sample time: 0.1 (seconds) Polyhedral regions: 1 Number of parameters: 4 Is solution simplified: No State Estimation: Default Kalman gain --------------------------------------------- Type 'EMPCobj.MPC' for the original implicit MPC design. Type 'EMPCobj.Range' for the valid range of parameters. Type 'EMPCobj.OptimizationOptions' for the options used in multi-parametric QP computation. Type 'EMPCobj.PiecewiseAffineSolution' for regions and gain in each solution. ```
Introduced in R2014b

## Support

#### Implementing an Adaptive Cruise Controller with Simulink

Download technical paper
{"ft_lang_label":"__label__en","ft_lang_prob":0.69549304,"math_prob":0.8919595,"size":1615,"snap":"2021-04-2021-17","text_gpt3_token_len":286,"char_repetition_ratio":0.22284296,"word_repetition_ratio":0.0,"special_character_ratio":0.15108359,"punctuation_ratio":0.060085837,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97041684,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-14T16:05:27Z\",\"WARC-Record-ID\":\"<urn:uuid:b58e5901-4b49-4722-b973-3f7e58a5acd6>\",\"Content-Length\":\"91789\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b8e56c0c-70bf-4bff-92a5-8f8c6466c33f>\",\"WARC-Concurrent-To\":\"<urn:uuid:32c1950a-bc53-41dd-ba5f-30bea69d88e0>\",\"WARC-IP-Address\":\"23.5.129.95\",\"WARC-Target-URI\":\"https://la.mathworks.com/help/mpc/ref/explicitmpc.html\",\"WARC-Payload-Digest\":\"sha1:RF7C3ZOBMBKN4XVCWEYOCNZHPSJVLHYC\",\"WARC-Block-Digest\":\"sha1:XCVYTUIEZZQXXWMNA6MG5EPJXMTJIIZT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618038077843.17_warc_CC-MAIN-20210414155517-20210414185517-00603.warc.gz\"}"}