# PWAS APPROXIMATION

Performs a PWAS constrained approximation of an MPC controller

## Contents

Function of MOBY-DIC TOOLBOX.

## Description

This function is a wrapper for functions LeastSquaresApprox, L1Approx, L2Approx and LInfApprox. A more detailed description can be found in the documentation of these functions. This function checks that the inputs are correct, starts the matlabpool for multithreading computing (if requested) and, based on the requested norm, calls one of the above mentioned functions.

## Syntax

**[Cpwas, sigma] = pwasApproximation(Cpwa,linSys,constr,D,P,options)**

Cpwa is a pwag object defining the optimal MPC control function to approximate.

linSys is a linearSystem object defining the system to be controlled. constr is a constraints object defining the constraints that the pwas approximated controller must satisfy.

D is the domain in which you want to obtain the approximation. The domain is represented as a matrix in the form

P is the simplicial partition you want to use for the pwas function. If the partition is uniform P is simply a vector containing the number of partitions for each dimension. If the partition is non-uniform, P is a cell array whose j-th entry contains the j-th components of the points in which you want to partition the domain. If you want a bidimensional domain to have partition vertices in [0.1 0], [0.1 1], [0.1 3], [1.2 0], [1.2 1], [1.2 3] you have to set P{1} = [0.1 1.2] and P{2} = [0 1 3].

options (optional field) is a structure with the following fields:

- xref: reference state. The MPC control function is designed to bring the system state to xref

- norm: indicates the norm to be used for the approximation functional. Values 0, 1, 2 and inf are allowed. norm = 0 means that the approximation is found with a least square minimization (default norm = 2).

- nsamples: only for norm = 2. Number of samples along each dimension used to sample each simplex for the computation of the integrals necessary for the L2 approximation. See function L2Approx for further details. Default value is the maximum between 3 and 14-2*nx where nx is the number of dimensions.

- solver: indicates the solver to be used for the optimization problem. Available solvers are 'quadprog', 'cvx', 'cplex', 'yalmip' 'clp' (default) for L2 norm and least squares approximation; 'linprog', 'cvx', 'cplex', 'clp', 'cdd', 'glpk' (default) for L1 and Linf approximation.

- tau: weight for the slack variable sigma (default tau = 1.0e3). The slack variables are necessary because some of the constraints (tipically the state constraints) could not be satisfied by the pwas approximated function, due to the different partition structure. If tau < 0 only one slack variable is used to soften all constraints.

- rho: only for L-Inf norm. If rho = 0, the optimization problem is easier, the infinity norm is minimized but the shape of the function can be very dissimilar to the original one. If rho is too high, the infinity norm could not be minimized.

- equality: if equality is set to 1, local optimality constraints are considered. If it is set to 2, the approximated control is constrained to be 0 in the origin. Default equality = 1. TO BE CHECKED!

- verbose: if verbose is set to 1, messages are displayed indicating the status of the approximation process. Default verbose = 1.

- multithreading: if multithreading is set to 1, some parts of the code are performed in multithreading. The speed of the program is considerably increased with this option. Default multithreading = 1, if the Parallel Computing Toolbox is installed.

Cpwas is the pwas object defining the approximated control.

sigma is another pwas object defining the slack variable.

## Acknowledgements

Contributors:

- Alberto Oliveri (alberto.oliveri@unige.it)
- Tomaso Poggi (tpoggi@essbilbao.org)

Copyright is with:

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