# GENERATE MPC

Generates an MPC control law

## Contents

Function of MOBY-DIC TOOLBOX.

## Description

This function is essentially an interface to Hybrid Toolbox and Multi Parametric Toolbox. Given a linearSystem object (defining the linear system to control) and a constraints object (defining constraints on state, inputs and parameters), this function returns a pwag object which represents the MPC control law for the regulation to a reference value of the linear system given in input.

## Syntax

**[Cpwag ctrl] = generateMPC(linSys,constr,options)**

linSys is a linearSystem object, representing the linear system that must be regulated to the reference value. constr is a constraints object defining the constraints that inputs, states and parameters must fulfill. options is a structure with the following fields (all optional):

- toolbox: string indicating which toolbox to use for the computation of the MPC control law. It can be 'HybTbx' for Hybrid Toolbox or 'MPT' for Multi Parametric Toolbox.
- N: prediction horizon. States evolution is predicted from time k = 0 to time k = N (inputs are required from time k = 0 to time k = N-1).
- Nu: control moves are computed from time k = 0 to time k = Nu-1. From time Nu to time N-1, input is set proportional to state, with Hybrid Toolbox, or equal to u(Nu-1) with MPT.
- P, Q, R: weight matrices for the MPC optimization problem. P weights the final state, Q all other states and R the inputs.
- K (only for Hybrid Toolbox): feedback gain. For k >= Nu, u is set equal to K x.
- xref: reference value. The control will regulate the system to this state (only regulation to the origin is available with Hybrid Toolbox).
- rho (only for Hybrid Toolbox): weight for slack variables. If rho = inf, hard constraints are imposed on state variables; otherwise a slack variable is introduced, weighted with rho.
- norm (only for MPT): norm to minimize in the optimization problem. It can be either 1, 2 or Inf.
- D: domain of the pwag function.
- subopt_lev (only for MPT): level of optimality (see MPT manual).
- Tset (only for MPT): a polytope object describing the terminal set (see MPT manual).
- Tconstraint (only for MPT): an integer (0, 1, 2) denoting which stability constraint to apply. 0 – no terminal constraint, 1 – use LQR terminal set, 2 – use user-provided terminal set constraint

Cpwag is the pwag function representing the PWA MPT control law. ctrl is the object returned by Hybrid Toolbox or MPT.

## Acknowledgements

Contributors:

- Alberto Oliveri (alberto.oliveri@unige.it)

Copyright is with:

- Copyright (C) 2012 University of Genoa, Italy.