Model Reduction Software
Model Reduction and Alike
Empirical gramians can be computed for linear and nonlinear statespace control systems for purposes of model order reduction (MOR), system identification (SYSID) and uncertainty quantification (UQ). 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 direct truncation (approximate balancing) and the empirical linear cross gramian for largescale linear systems. 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 and provides a common interface for the computation of empirical gramians and empirical covariance matrices.
Name
emgr  Empirical Gramian framework for model reduction and system identification of inputoutput systems.
Scope
 Model Reduction
 Robust Reduction
 Parametric Model Order Reduction
 Sensitivity Analysis
 Parameter Identification
 Parameter Reduction
 Combined State and Parameter Reduction
 Decentralized Control
 Uncertainty Quantification
 Optimal Sensor Placement
 Linear + Nonlinear Control Systems
 First + Second Order Systems
 Parametrized  Parametric Systems
 Discretized PDEs
 Systems with:
 Vector Field f: ẋ(t) = f(x(t),u(t),p)
 Output Functional g: y(t) = g(x(t),u(t),p)
Download
Get emgr
here: emgr.m (Version: 3.1)
[mirror]
[source]
[metameta]
^{(emgr is written in the matlab programming language and requires Octave or Matlab. emgr has no dependencies on other toolboxes or packages.)}
License
All source code is licensed under the open source BSD 2clause license:
Copyright (c) 20132015, 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,s,t,w,pr,nf,ut,us,xs,um,xm);
Minimal Usage: W = emgr(f,g,s,t,w);
About Info Usage: v = emgr('version');
Arguments
f
 Handle to a function with signaturex = f(x,u,p)
, the system's vector field.g
 Handle to a function with signaturex = g(x,u,p)
, the output functional.g = 1
impliesy = x
.s
 Three component vectors = [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, for details see Gramians.
Optional Arguments
pr
 System parameters (Default:0
):vector
 Column vector holding the parametersmatrix
 Set of column vectors holding different sets of parameters
nf
 Twelve component vector holding options; (Default:0
), for details see Option Flags.ut
 Input time series (Default:1
):scalar
 Impulse input scaled by provided valuevector
 Impulse input seperately scaled by vector componentsmatrix
 Discrete input time series of dimensionsJ x (T/h)
handle
 Function Handle with signatureu = U(t)
; discretized internally∞
 Chirp Input
us
 Steadystate input (Default:0
):scalar
 Sets allJ
input components to provided valuevector
 SteadyState input column vector of dimensionJ
xs
 Steadystate, also used as nominal initial state (Default:0
).scalar
 Sets allN
steadystate components to provided valuevector
 Steadystate column vector of dimensionN
um
 Input perturbation scales (Default:1
),scalar
 set all maximum scales to argument,vector
 set maximum to scale to argument,matrix
 set scales to argument, used as is.
xm
 Initial state perturbation scales (Default:1
),scalar
 set all maximum scales to argument,vector
 set maximum to scale to argument,matrix
 set scales to argument, used as is.
Gramians
'c'
 Empirical Controllability Gramian (WC
)'o'
 Empirical Observability Gramian (WO
)'x'
 Empirical Cross Gramian (WX
) aka (WCO
)'y'
 Empirical Linear Cross Gramian (WY
)'s'
 Empirical Sensitivity Gramian (WS
)'i'
 Empirical Identifiability Gramian (WI
)'j'
 Empirical Joint Gramian (WJ
)
Option Flags
nf(1)
 Center timer series around:=0
 zero,=1
 arithmetic average over time,=2
 steady state (assumed to be reached at final time),=3
 median over time,=4
 midrange over time,=5
 rootmeansquare over time.
nf(2)
 Input scale sequence:=0
 linearum = um*[0.25,0.50,0.75,1.0]
;=1
 logarithmicum = um*[0.001,0.01,0.1,1.0]
;=2
 geometricum = um*[0.125,0.25,0.5,1.0]
;=3
 singleum = um
;=4
 sparseum = um*[0.17,0.5,0.77,0.94]
;
nf(3)
 State scale sequence:=0
 linearxm = xm*[0.25,0.50,0.75,1.0]
;=1
 logarithmicxm = xm*[0.001,0.01,0.1,1.0]
;=2
 geometricxm = xm*[0.125,0.25,0.5,1.0]
;=3
 singlexm = xm
;=4
 sparsexm = xm*[0.17,0.5,0.77,0.94]
;
nf(4)
 Input transformations:=0
 unitum = [um,um]
;=1
 inverseum = [um,1.0./um]
;=2
 dyadicum = um*um'
;=3
 singleum = um
;
nf(5)
 State transformations:=0
 unitxm = [xm,xm]
;=1
 inversexm = [xm,1.0./xm]
;=2
 dyadicxm = xm*xm'
;=3
 singlexm = xm
;
nf(6)
 Preconditioning (Default:0
):=1
 double run, scale with gramian diagonal,=2
 scaled run, scale with steady state (input).
nf(7)
 DataDriven Gramians (Default:0
),=1
 set all scales to one.
nf(8)
 Robust parameters (Default:0
),=1
 onlyWC, WX, WY, WJ
: treat parameters as additional inputs.
nf(9)
 Center parameter scales (Default:0
),=1
 center by arithemtic mean.
nf(10)
 Exclusive options (Default:0
),=1
 onlyWS
: use meancentered parameter sensitivity,=1
 onlyWI
: Schurcomplement of parameter identifiability,=1
 onlyWX, WJ
: nonsymmetric cross operator aka (WZ
).
nf(11)
 Enforce gramian symmetry (Default:0
),=1
 return symmetric part of resulting emprirical gramian.
nf(12)
 Solver type (Default:0
),= 0
 (accelerated) Improved RungeKutta3 with midpoint rule starting values,=1
 custom solver via global handle with signaturey = solver(f,g,h,T,x,u,p)
;
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 statespace symmetric system P = ones(N,1); % parameter vector f = @(x,u,p) A*x+B*u; % linear dynamic system vector field g = @(x,u,p) C*x; % linear output functional G = @(x,u,p) A'*x+C'*u; % adjoint dynamic system vector field F = @(x,u,p) A*x+Bu+p % linear parametrized vector field
 Empirical Controllability Gramian:
WC = emgr(f,g,[J,N,O],[S,h,T],'c');
 Empirical Observability Gramian:
WO = emgr(f,g,[J,N,O],[S,h,T],'o');
 Empirical Cross Gramian:
WX = emgr(f,g,[J,N,O],[S,h,T],'x');
 Empirical Linear Cross Gramian:
WY = emgr(f,G,[J,N,O],[S,h,T],'y');
 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: vernval.m
Extra
 Benchmark: ilp.m (Inverse Lyapunov Procedure System Generator)
 H2Norm: h2norm.m (H2Norm of Linear Control System)
 Solver: mysolver.m (Sample custom ODE solver)
 Lanczos SVD: lsvd.m (sparse / truncated SVD (POD) for largescale matrices)
 Balance: balance_co.m (SquarerootSVD Balancing for WC and WO)
Demos
State Reduction: Cross Gramian (
 
State Reduction: Linear Cross Gramian (
 
State Reduction: Nonsymmetric Cross Gramian (
 
State Reduction: Balanced Truncation (
 
State Reduction: Balanced Gains (
 
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 (
 
State Reduction: NonSymmetric and Nonlinear (
 
Nonlinearity Quantification (
 
Decentralized Control (
 
PDE Reduction: Advection Equation (
 
Nonlinear Second Order Reduction: 5body Choreography (
 
Parameter Identification: Stable Orbits Inside Black Holes (

About
A gramian matrix W
is the result of all inner products of a set of vectors V = (v1 ... vn)
, in other words: W = V' V
.
The properties of linear control systems can be assessed by the systems controllability and observability gramian matrices.
The cross gramian combines controllability and observability information into a single matrix and thus does not require balancing.
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 Linear 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; "A Note on the Cross Gramian for NonSymmetric Systems"; Submitted, 2015; preprint, source, runmycode
 OneSentence Abstract: A cross gramian matrix for nonsymmetric and nongradient systems.
 C. Himpe, M. Ohlberger; "The Empirical Cross Gramian for Parametrized Nonlinear Systems"; Mathematical Modelling , 8(1): 727728, 2015; selfarchived, source
 OneSentence Abstract: Use of the empirical cross gramian for parametric model order reduction by averaging.
 C. Himpe, M. Ohlberger; "CrossGramianBased Combined State and Parameter Reduction for LargeScale Control Systems"; Mathematical Problems in Engineering 2014: 113, 2014; openaccess, 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"; Proceedings of the European Control Conference: 27392743, 2014; preprint, source, runmycode
 OneSentence Abstract: Cross gramian based model reduction of a timevarying 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, runmycode
 OneSentence Abstract: Implementation and mathematical background on empirical gramians under a common interface.
 Further References for empirical gramians are in the empirical gramian reference list.
Contact
Send feedback to: ch@gramian.de
Cite
 Cite as: C. Himpe (2015). emgr  Empirical Gramian Framework (Version 3.1) [Computer Software]. http://gramian.de
 BibTeX:
@MISC{emgr,author={C. Himpe},title={{emgr  Empirical Gramian Framework (Version 3.1)}},howpublished={\url{http://gramian.de}},year={2015}}
 DOI: 10.5281/zenodo.17360 (Version 3.1)
 Except where otherwise noted, content on this site is licensed under a CC BY 4.0 license.
 Last Change: 20150703
Links
 emgr_ref.pdf (emgr Reference Card)
 emgr_poster.pdf (emgr Poster)
 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)
 freshcode.club/projects/emgr (emgr at freshcode)
 sciencetoolbox.org/tools/1784 (emgr at sciencetoolbox)
 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 fmcompat.tgz are required.
 emgr has a special version emgr_oct.m using octave's advanced syntax.
 emgr is not explicitly parallelized but multicore ready by vectorization and implicit parallelization.
 emgr can use GPGPU / Accelerator based heterogeneous computing by automatic offloading through the BLAS backend including hUMA.
 emgr has only about 450 lines of code!
 emgr is designed like an app with the unix philosophy "Do One Thing and Do It Well" in mind.
Troubleshooting
 Issue: The identifiability gramian
WI{2}
or crossidentifiability gramianWJ{2}
are zero.
Fix: The steady state (initial state) needs to introduce energy into the system; usually this meansxs
≠ 0.  Issue: An empirical gramian contains very large or infinity values.
Fix: Most likely, one of the sampled trajectory is not stable, make sure the perturbations (scales) or parameters destabilize the system and a suitable ODE solver is used.
See Also
 Model Reduction Routines (Another Empirical Gramian Software; WC and WO only)
 gram (Octave Control Package; linear WC and linear WO only)