You are here

Routine olsapprox

Polynomial approximation of tabulated data using orthogonal least-squares.

Description

This routine uses Orthogonal Least-Squares to compute a multivariate polynomial approximation $f:\mathbb{R}^n\rightarrow\mathbb{R}^{n_1\times n_2}$ of a set of samples $\left\{y_k\in\mathbb{R}^{n_1\times n_2}, k\in [1, N]\right\}$ obtained for different values $\left\{x_k\in\mathbb{R}^n,k \in [1, N]\right\}$ of some explanatory variables $x\in\mathbb{R}^n$. The maximum degree of the polynomial function and the maximum admissible approximation error are set by the user. A sparse polynomial expression is usually obtained, which ensures that the global relative error or the root-mean-square error between $\left\{f(x_k), k\in [1, N]\right\}$ and $\left\{y_k, k\in [1, N]\right\}$ remains below the given threshold for each entry (see errapprox for precise definitions).

Syntax

[fdata,fdesc,fsym,flfr]=olsapprox(X,Y,names,maxerr{,options})

Input arguments

The first five input arguments are mandatory:

X Values $\left\{x_k\in\mathbb{R}^n,k \in [1, N]\right\}$ of the explanatory variables $x$ ($n\times N$ array, where X(:,k) corresponds to $x_k$).
Y Samples $\left\{y_k\in\mathbb{R}^{n_1\times n_2}, k\in [1, N]\right\}$ to be approximated ($n_1\times n_2\times N$ array where Y(:,:,k) corresponds to $y_k$ in the general case, or possibly $1\times N$ array where Y(k) corresponds to $y_k$ if $n_1=n_2=1$).
names Names of the explanatory variables $x$ ($1\times n$ cell array of strings).
maxdeg Maximum degree of the approximating polynomial function $f$.
maxerr Maximum admissible approximation error (if possible):

  • if maxerr is positive, the global relative error norm(Y(i1,i2,:)-fdata(i1,i2,:))/norm(Y(i1,i2,:)) remains below maxerr for each entry $i_1\in [1,n_1]$ and $i_2\in [1,n_2]$.
  • if maxerr is negative, the root-mean-square error norm(Y(i1,i2,:)-fdata(i1,i2,:))/sqrt(N) remains below abs(maxerr) for each entry $i_1\in [1,n_1]$ and $i_2\in [1,n_2]$.
  • if maxerr is empty, default tolerances are used and the error cannot be mastered, but the algorithm is faster.

The sixth input argument options is an optional structured variable with fields:

maxexp Maximum exponent of each explanatory variable in the approximating polynomial function $f$ ($1\times n$ array). The default value is options.maxexp=maxdeg*ones(1,n).
abserr Maximum admissible local absolute error abs(Y(i1,i2,k)-fdata(i1,i2,k)) over all samples $k\in [1,N]$ and all entries $i_1\in [1,n_1]$ and $i_2\in [1,n_2]$ (if possible). The default value is options.abserr=Inf.
pendeg Penalization of each monomial proportionally to its degree (0 = no penalty, 1 = medium penalty, >1 = large penalty). The default value is options.pendeg=1.
trace Trace of execution (0=no, 1=text, 2=text+figures). The default value is options.trace=1.
viewpoint This option is applicable only if 3-D graphs are to be displayed (options.trace=2 and $n=2$). It represents the deviation with respect to the default viewpoint (see plotapprox). The default value is options.viewpoint=[0 0].
warn Warnings display (0=no, 1=yes). The default value is options.warn=1.

Output arguments

fdata Values $\left\{f(x_k)\in\mathbb{R}^{n_1\times n_2},k \in [1, N]\right\}$ of the approximating function $f$ (same size as Y).
fdesc Description of the approximating function $f$ (fdesc{i1,i2}.coef(j) and fdesc{i1,i2}.exp(j,:) contain the coefficient and the exponents of the $j\,$th monomial used to approximate entry $(i_1\times i_2)$ of Y).
fsym Symbolic representation of the approximating function $f$ (symbolic object).
flfr Linear fractional representation of the approximating function $f$ (GSS object if the GSS library is installed, LFR object otherwise if the LFR toolbox is installed).

Note

Il is possible to define a structure for the appoximating polynomial function. Assume for example that an expression of the form $f(x)=x(1)x(3)^2g(x(1),x(2))+x(2)^3h(x(1),x(4))$ is searched, which depends on 4 explanatory variables $x(1),\dots,x(4)$ and is composed of two polynomials $g$ and $h$. Three additional fields are introduced in the input variable options as follows:

  • options.parin={[1 2] [1 4]}
  • options.parout={[1 3] [2]}
  • options.expout={[1 2] [3]}

By default, no structure is considered, so options.parin={1:n}, options.parout={[]} and options.expout={[]}.

Caution

If some values in X are much larger than 1, they must be scaled or normalized.

Example

Drag coefficient of a generic fighter aircraft model:
load data_cx
Approximation on a rough grid:
maxdeg=12;
maxerr=-0.000959;
options.trace=2;
options.viewpoint=[-100 0];
[fdata,fdesc,fsym,flfr]=olsapprox(X1,Y1,names,maxdeg,maxerr,options);

Validation on a fine grid:
plotapprox(Xv,Yv,names,flfr,options);

See also

lsapprox
qpapprox
tracker
koala
errapprox
plotapprox

References

[1] C. Poussot-Vassal and C. Roos, "Generation of a reduced-order LPV/LFT model from a set of large-scale MIMO LTI flexible aircraft models", Control Engineering Practice, vol. 20, no. 9, pp.919-930, 2012.
[2] C. Roos, "Generation of LFRs for a flexible aircraft model", Optimization based clearance of flight control laws, Lecture Notes in Control and Information Sciences, vol. 416, pp. 59–77, Springer Verlag, 2011.