Model Reduction and Alike
Empirical gramians can be computed for linear and nonlinear control systems for purposes of model order reduction (MOR), uncertainty quantification (UQ) or system identification (SYSID). Model reduction using empirical gramians can be applied to the state space, to the parameter space or to both through combined reduction. For state reduction the empirical controllability gramian and the empirical observability gramian, for balanced truncation, are available, or alternatively the empirical cross gramian for (balancingfree) direct truncation and the empirical approximate cross gramian for largescale models. For parameter reduction, parameter identification and sensitivity analysis the empirical sensitivity gramian (controllability of parameters) or the empirical identifiability gramian (observability of parameters) are provided. Combined state and parameter reduction is enabled by the empirical joint gramian, which computes controllability and observability of states (cross gramian) and parameters (crossidentifiability gramian) concurrently. The emgr framework is a compact opensource toolbox for (empirical) GRAMIANbased model reduction and compatible with OCTAVE and MATLAB.
Name
emgr  Empirical Gramian framework for model reduction and system identification.
Scope
 Model Order Reduction
 Combined State and Parameter Reduction
 System Identification
 Parameter Identification
 Parameter Reduction
 Sensitivity Analysis
 Robust Reduction
 Uncertainty Quantification
 Decentralized Control
 Linear + Nonlinear Control Systems
 First + Second Order Systems
 Parametrized  Parametric Systems
Download
Get emgr
here: emgr.m (Version: 2.0)
[mirror]
[source]
^{(emgr is written in the matlab programming language and requires Octave or Matlab)}
License
All source code is licensed under the open source BSD 2clause license:
Copyright (c) 20132014, Christian Himpe
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Usage
General Usage: W = emgr(f,g,q,t,w,pr,nf,ut,us,xs,um,xm,yd);
Minimal Usage: W = emgr(f,g,q,t,w);
Parameters
f
 Handle to a function with signaturex = f(x,u,p)
, the system function.g
 Handle to a function with signaturex = g(x,u,p)
, the output function.q
 Three component vectorq = [J N O]
holding number of inputs, states and outputs.t
 Three component vectort = [S h T]
holding time start, step and stop.w
 A character selecting the gramian type,'c', 'o', 'x', 'y', 's', 'i', 'j'
, for details see Gramians.
Optional Parameters
pr
 Columnvector holding parameters; (Default:0
for no parameters).nf
 Twelve component vectornf = [nf0 nf1 nf2 nf3 nf4 nf5 nf6 nf7 nf8 nf9 nf10 nf11]
holding options; (Default:0
), for details see Options.ut
 Matrix holding input (inputs x steps); if scalar, impulse input is generated; can also be handle to function u = U(t); (Default:1
).us
 Columnvector of input during nominal or steady state; if scalar, is extended to samerows vector; (Default:0
).xs
 Columnvector of nominal, average or steady state; if scalar, is extended to samerows vector; (Default:0
).um
 Matrix of input scales (input x scale); if columnvector, is extended to samecolumn matrix; if scalar, is extended to samerows vector; (Default:1
).xm
 Matrix of init state scales (state x scale); if columnvector, is extended to samecolumn matrix; if scalar, is extended to samerows vector; (Default:1
).yd
 Two dimensional cellarray of experimental data; first dim for states (WC, WX
), second dim for output (WO, WX
).
Gramians
'c'
 Empirical Controllability Gramian (WC
)'o'
 Empirical Observability Gramian (WO
)'x'
 Empirical Cross Gramian (WX
) or (WCO
)'y'
 Empirical Approximate Cross Gramian (WY
)'s'
 Empirical Sensitivity Gramian (WS
)'i'
 Empirical Identifiability Gramian (WI
)'j'
 Empirical Joint Gramian (WJ
)
Options
nf0
 Residualize against steadystate(0
), average(1
), median(2
), last(3
), POD(4
)nf1
 Input scale sequence: linear(0
), logarithmic(1
), geometric(2
), single(3
)nf2
 State scale sequence: linear(0
), logarithmic(1
), geometric(2
), single(3
)nf3
 Input transformations: unit(0
), inverse(1
), dyadic(2
), single(3
)nf4
 State transformations: unit(0
), inverse(1
), dyadic(2
), single(3
)nf5
 Single run(0
), double run(1
), scaled run(2
) to reduce numerical errornf6
 Generate(0
), use provided(1
) datanf7
 Default(0
), active(1
), passive(2
) robust parameters; only:WC, WS, WY
nf8
 Default(0
), adjust parameter(1
) scales; only:WS, WI, WJ
nf9
 Default(0
), use schurcomplement(1
); only:WI
nf10
 Default(0
), enforce symmetry(1
)nf11
 Explicit Euler(0
), AdamsBashforth(1
), Leapfrog(2
), Ralston(3
), Custom(1
) Solver
Example
 Setup:
J = 4; % number of inputs N = J*J % number of states O = J; % number of outputs S = 0; % start time h = 0.01; % time step T = 1; % end time A = rand(N,N); % random system matrix A = 0.5*(A+A'); % symmetrize system matrix A(1:N+1:end) = N; % ensure stability B = rand(N,J); % random input matrix C = B'; % ensure symmetric system P = A(:); % parameter vector f = @(x,u,p) reshape(p,[N N])*x+B*u; % parametrized linear dynamic system F = @(x,u,p) reshape(p,[N N])'*x+C'*u; % adjoint dynamic system g = @(x,u,p) C*x; % linear output function
 Empirical Controllability Gramian:
WC = emgr(f,g,[J N O],[S h T],'c',P)
 Empirical Observability Gramian:
WO = emgr(f,g,[J N O],[S h T],'o',P)
 Empirical Cross Gramian:
WX = emgr(f,g,[J N O],[S h T],'x',P)
 Empirical Approximate Cross Gramian:
WY = emgr(f,F,[J N O],[S h T],'y',P)
 Empirical Sensitivity Gramian:
WS = emgr(f,g,[J N O],[S h T],'s',P);
 Empirical Identifiability Gramian:
WI = emgr(f,g,[J N O],[S h T],'i',P);
 Empirical Joint Gramian:
WJ = emgr(f,g,[J N O],[S h T],'j',P);
Get the source code here: testemgr.m
Utilities
 Benchmark: ilp.m (Inverse Lyapunov Procedure System Generator)
 Wrapper: egram.m (emgr Encapsulation for linear control systems)
 H2Norm: h2norm.m (H2Norm of Linear Control System)
 Solver: CUSTOM_ODE.m (Sample custom ODE solver)
Demos
State Reduction: Cross Gramian (
 
State Reduction: Approximate Cross Gramian (
 
State Reduction: Balanced Truncation (
 
State Reduction: Hierarchical System (
 
Parameter Reduction: Linear System with Source Term (
 
Parameter Reduction: Linear System with Scaled States (
 
Combined Reduction: Nonlinear System (
 
Benchmark: Inverse Lyapunov Procedure (
 
Benchmark: Linear Model Reduction (
 
Benchmark: Nonlinear Model Reduction (
 
Decentralized Control (
 
Nonlinearity Quantification (
 
PDE Reduction: Advection Equation (
 
Nonlinear Second Order Reduction: 5body Choreography (
 
Parameter Identification: Stable Orbits Inside Black Holes (

About
A gramian matrix is the result of all inner products of a set of vectors. The properties of linear control systems can be assessed by the system gramians quantifiying controllability and observability. Empirical gramians extend this approach to nonlinear control systems and thus enable nonlinear model reduction. For linear systems the empirical gramians are equal to the classic gramians. Yet empirical gramians contain more information about the underlying system; and the empirical cross gramian conveys even additional information. This makes empirical gramians a versatile tool for mathematical engineering!
The Discrete Empirical Cross Gramian encloses information on the inputoutput behavior of the associated control system as well as approximate Hankel Singular Values and can be computed very efficiently. For extremescale systems, the Approximate Cross Gramian, related to Balanced POD, can be utilized. And for parametrized systems, the Joint Gramian, derived from the cross gramian, is available for combined reduction. In case of custom input, an empirical covariance matrix can also be computed.
References
 C. Himpe, M. Ohlberger; "CrossGramian Based Combined State and Parameter Reduction for LargeScale Control Systems"; 2013; preprint, source, runmycode
 OneSentence Abstract: Introduction of the empirical cross gramian and the derived joint gramian as well as gramianbased combined reduction.
 C. Himpe, M. Ohlberger; "Model Reduction for Complex Hyperbolic Networks"; 2013; preprint, source
 OneSentence Abstract: Cross gramian based model reduction of a time varying nonsymmetric system with application in network cosmology.
 C. Himpe, M. Ohlberger; "A Unified Software Framework for Empirical Gramians"; Journal of Mathematics 2013:16, 2013; openaccess, source, gist, runmycode
 OneSentence Abstract: Implementation and mathematical background on empirical gramians under a common interface.
Contact
Send feedback to: ch@gramian.de
Cite
 Cite as: C. Himpe. "emgr  Empirical Gramian Framework". http://gramian.de
 BibTeX:
@MISC{emgr,author={Himpe, C.},title={{emgr  Empirical Gramian Framework}},howpublished={\url{http://gramian.de}}}
 Except where otherwise noted, content on this site is licensed under a CC BY 4.0 license.
 Last Change: 20140415
Links
 emgr_refs.md (Empirical Gramian References)
 emgr_info.pdf (emgr Datasheet)
 emgr_ttrl.pdf (emgr Tutorial)
 github.com/gramian/emgr (emgr git repository at github)
 orms.mfo.de/project?id=345 (emgr at Oberwolfach References on Mathematical Software)
 swmath.org/software/7554 (emgr at swMATH)
 sciencepad.web.cern.ch/node/143 (emgr at CERN SciencePAD)
 modelreduction.org (Model Order Reduction Wiki)
 morepas.org (Model Reduction for Parametrized Systems)
 en.wikibooks.org/wiki/Control_Systems (Control Systems Wikibook)
 gist.github.com/gramian/6027733 (Octave / Matlab Snippets)
Notes
 emgr is almost compatible with FREEMAT, additionally the files in bsxfun.tgz are required.
 emgr is not explicitly parallelized but multicore ready by vectorization and implicit parallelization of the matlab interpreter.
 emgr has less than 400 lines of code!
See Also
 Model Reduction Routines (Another Empirical Gramian Software; WC and WO only)
 gram (Control System Toolbox; WC and WO only)
Category
 MSC: 93Bxx
 Controllability, Observability
 Science/Math/Software/MATLAB