Model Reduction Software
Name
emgr  EMpirical GRamian framework for (nonlinear) inputoutput systems.
Description
System gramians are matrices associated to linear inputoutput systems and quantify their controllability and observability.
Empirical gramian matrices (empirical gramians) are computable for linear but also nonlinear (statespace) systems and have, among others, application in model order reduction (MOR) or uncertainty quantification (UQ).
Model reduction using empirical gramians can be applied to the statespace, to the parameterspace or both through combined reduction.
For state reduction, empirical balanced truncation by the empirical controllability gramian and the empirical observability gramian, or alternatively, direct truncation (approximate balancing) by the empirical cross gramian (or the empirical linear cross gramian for largescale linear systems) is available.
For parameter reduction, parameter identification and sensitivity analysis by 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 observability of parameters (empirical crossidentifiability gramian) concurrently.
The empirical gramian framework  emgr
 is a compact opensource toolbox for (empirical) GRAMIANbased model reduction and compatible with OCTAVE and MATLAB.
This mathematical software provides a common interface for the computation of empirical gramians and empirical covariance matrices.
Scope
 Model Order Reduction (MOR)  Model Reduction
 Parametric Model Order Reduction (pMOR)  Robust Reduction
 Nonlinear Model Order Reduction (nMOR)
 Parameter Identification  Parameter Reduction
 Combined State and Parameter Reduction (Combined Reduction)
 Sensitivity Analysis
 Decentralized Control
 Optimal Sensor Placement  Optimal Actuator Placement
 Nonlinearity Quantification
 for InputOutput Systems  Control Systems:
 linear & nonlinear
 time invariant & time varying
 parametrized  parametric
 ODE  spatially discretized PDEs
 controlaffine systems
 Mathematical system (time t, state x, input u, parameter p)
 Vector Field f: ẋ(t) = f(x(t),u(t),p,t)
 Output Functional g: y(t) = g(x(t),u(t),p,t)
Download
Get emgr
here: emgr.m (Version: 5.3)
[mirror]
[source]
[meta]
[emgr_oct.m]
[emgr_lgc.m]
^{(emgr is written in the Matlab programming language and requires Octave or Matlab. emgr has no dependencies on toolboxes or packages.)}
License
All source code is licensed under the open source BSD2clause license:
Copyright (c) 20132018, 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.
Disclaimer
This is research software!
Usage
General Usage: W = emgr(f,g,s,t,w,pr,nf,ut,us,xs,um,xm,dp);
Minimal Usage: W = emgr(f,g,s,t,w);
About Info Usage: v = emgr('version');
Mandatory Arguments
f
 Handle to a function with signaturex = f(x,u,p,t)
, the system's vector field.g
 Handle to a function with signaturey = g(x,u,p,t)
, the output functional.g = 1
impliesy = x
.s
 Three component vectors = [M,N,Q]
holding number of inputs, states and outputs.t
 Two component vectort = [h,T]
holding time step width and time horizon.w
 A character selecting the gramian type, for details see Gramians.
Optional Arguments
pr
 System's parameters (Default:0
;'s'
,'i'
,'j'
require two columns for min and max parameter),vector
 Column vector holding the parameters,matrix
 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
),handle
 Handle to function with signatureu_t = ut(t)
,1
 Delta impulse input,∞
 Linear chirp input using the havercosine.
us
 Steadystate input (Default:0
),scalar
 Sets allM
input components to provided value,vector
 Steadystate input column vector of dimensionM
.
xs
 Steadystate, also used as nominal initial state (Default:0
),scalar
 Sets allN
steadystate components to provided value,vector
 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.
dp
 Custom inner product handlez = dp(x,y)
(Default:@mtimes
).
Empirical Gramian Types
'c'
 Empirical Controllability Gramian (Wc
),'o'
 Empirical Observability Gramian (Wo
),'x'
 Empirical Cross Gramian (Wx
akaWco
orXcg
),'y'
 Empirical Linear Cross Gramian (Wy
),'s'
 Empirical Sensitivity Gramian (Ws
),'i'
 Empirical Identifiability Gramian (Wi
),'j'
 Empirical Joint Gramian (Wj
).
Wz
can be selected by setting option flag nf(7) = 1
and is compatible with the empirical cross gramian Wx
, the empirical linear cross gramian Wy
and the empirical joint gramian Wj
.
Option Flags
nf(1)
 Center timer series around (Default:0
),= 0
 Zero,= 1
 Steadystate,= 2
 Final state,= 3
 Arithmetic average over time,= 4
 Rootmeansquare over time,= 5
 Midrange over time,
nf(2)
 Input scale sequence (Default:0
),= 0
 Singleum = um
;= 1
 Linearum = um * [0.25, 0.50, 0.75, 1.0]
;= 2
 Geometricum = um * [0.125, 0.25, 0.5, 1.0]
;= 3
 Logarithmicum = um * [0.001, 0.01, 0.1, 1.0]
;= 4
 Sparseum = um * [0.01, 0.5, 0.99, 1.0]
;
nf(3)
 State scale sequence (Default:0
),= 0
 Singlexm = xm
;= 1
 Linearxm = xm * [0.25, 0.50, 0.75, 1.0]
;= 2
 Geometricxm = xm * [0.125, 0.25, 0.5, 1.0]
;= 3
 Logarithmicxm = xm * [0.001, 0.01, 0.1, 1.0]
;= 4
 Sparsexm = xm * [0.01, 0.5, 0.99, 1.0]
;
nf(4)
 Input transformations (Default:0
),= 0
 Unitum = [um, um]
;= 1
 Singleum = um
;
nf(5)
 State transformations (Default:0
),= 0
 Unitxm = [xm, xm]
;= 1
 Singlexm = xm
;
nf(6)
 Normalizing (Default:0
),= 0
 no normalization,= 1
 normalize with Jacobi,= 2
 normalize with steadystate (input).
nf(7)
 NonSymmetric cross gramian, onlyWx, Wy, Wj
(Default:0
),= 0
 Regular cross gramian,= 1
 Nonsymmetric cross gramian (cross operatorWz
) for nonsquare, nonsymmetric or nongradient systems.
nf(8)
 Enable nominal input during parameter and state perturbations, onlyWo, Wx, Ws, Wi, Wj
(Default:0
),= 0
 No extra input,= 1
 Extra input for state or parameter perturbations.
nf(9)
 Center parameter scales, onlyWs, Wi, Wj
(Default:0
),= 0
 No centering,= 1
 Center around arithmetic mean,= 2
 Center around geometric mean.
nf(10)
 Approximate or detailed Schurcomplement, onlyWi, Wj
(Default:0
),= 0
 detailed Schurcomplement,= 1
 approximate Schurcomplement.
nf(11)
 Cross gramian partition width, onlyWx, Wj
(Default:0
),= 0
 full cross Gramian, no partitioning,< N
 maximum partition width.
nf(12)
 Partitioned cross gramian running index, onlyWx, Wj
(Default:0
),= 0
 no partitioning,> 0
 index of cross gramian partition to be computed.
Return Values
 Statespace empirical gramian matrix (for:
Wc, Wo, Wx, Wy
)  Cell array of statespace and parameterspace empirical gramian matrix (for:
Ws, Wi, Wj
)
Configuration
Custom solver (via handle in global variable:ODE
)
 Function signature:
y = solver(f,g,t,x0,u,p)
f
 Handle to a function with signaturex = f(x,u,p,t)
, the system's vector field,g
 Handle to a function with signaturey = g(x,u,p,t)
, the output functional.t
 Two component vectort = [h,T]
holding time step width and time horizon,x0
 Column vector of dimensionN
holding initial state,u
 handle to function with signatureu_t = u(t)
,p
 Column vector holding parameters.
 Included default solver: SSPx2
 Explicit Second Order RungeKutta (RK2)
 Strong Stability Preserving (SSP)
 Configurable number of stages (Default: 3)
Extra Utilities
 Solver: mysolver.m (Sample generic ODE solver)
 Balancer: balance_co.m (SVDbased balancing method)
 Gauss Kernel: gauss_kernel.m (Gauss kernel)
 Polynomial Kernel: polynomial_kernel.m (Polynomial kernel)
 Sigmoid Kernel: sigmoid_kernel.m (Sigmoid kernel)
Mini Code Example
A = 0.5*eye(4) % System matrix
B = [0;1;0;1] % Input matrix
C = [0,0,1,1] % Output matrix
WX = emgr(@(x,u,p,t) A*x + B*u, @(x,u,p,t) C*x,[1,4,1],[0.5,10.0],'x') % Compute empirical cross Gramian
% WX ≈ [0,0,0,0;0,1,0,1;0,0,0,0;0,1,0,1]
Tests
A minimal example code can be found in RUNME.m. A basic sanity test is conducted in emgrtest.m. Further tests are performed on a timeinvariant, linear, statespace symmetric MIMO system, with a negative Lehmer matrixA
as a system matrix and optional linear parametrization:
ẋ = A*x + B*u + p
y = C*x
Demos
Combined Reduction: Nonlinear System (
 
State Reduction: Balanced Gains (
 
Benchmark: Inverse Lyapunov Procedure (
 
Benchmark: Flexible Space Structures (
 
Benchmark: Linear Model Reduction (
 
Benchmark: Nonlinear Model Reduction (
 
State Reduction: NonSquare and Nonlinear (
 
Nonlinearity Quantification (
 
Decentralized Control (
 
PDE Reduction: Advection Equation (
 
Nonlinear Second Order Reduction: 5body Choreography (
 
Parameter Identification: Stable Orbits Inside Black Holes (
 
System Indices: Cross Gramian (

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^{T} V
.
Properties of (linear) control systems can be assessed by the system gramians, which are based on the controllability and observability operators.
Classically, the controllability gramian and observability gramian are utilized in balancing model reduction methods.
The cross gramian encodes controllability and observability information into a single matrix and thus does not require explicit 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. Also, the Koopman controllability gramian and Koopman observability gramian are equivalent to their empirical gramian counterparts. 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 empirical cross gramian, related to Balanced POD, can be utilized. And for parametrized systems, the (empirical) 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.
Model reduction or model order reduction is a research field in applied mathematics, which investigates the algorithmic construction of loworder surrogate models for highdimensional differential equation models. The resulting reduced order models allow a substantially more economical evaluation in terms of computational or memory resources compared to the original largescale full order model. Model reduction is essential as developments in computing technology are constantly outpaced by the requirements for model simulation in dimensionality or complexity.
References
 C. Himpe; "emgr  the Empirical Gramian Framework"; Submitted, 2016.
 C. Himpe, M. Ohlberger; "CrossGramianBased Model Reduction: A Comparison"; In: Model Reduction of Parametrized Systems, MS&A, vol. 17: 271283, 2017.
 Synopsis: Summary and tests for Sylvesterequationbased cross gramian, empirical linear cross gramian and empirical cross gramian.
 Links: preprint, sourcecode, runmycode
 C. Himpe; "Combined State and Parameter Reduction for Nonlinear Systems with an Application in Neuroscience"; Westfälische Wilhelms Universität, Sierke Verlag Göttingen, 2017.
 Synopsis: Combined state and parameter reduction via empirical Gramians.
 Links: sourcecode, runmycode
 C. Himpe, M. Ohlberger; "A note on the cross gramian for nonsymmetric systems"; System Science and Control Engineering, 4(1): 199208, 2016.
 Synopsis: A new cross gramian matrix for nonsymmetric, nongradient and nonsquare system.
 Links: selfarchived, sourcecode, runmycode
 C. Himpe, M. Ohlberger; "Accelerating the Computation of Empirical Gramians and Related Methods"; 5th IWMRRF, 2015.
 Synopsis: Numerical performance enhancements for empirical gramians.
 Links: selfarchived, sourcecode
 C. Himpe, M. Ohlberger; "The Empirical Cross Gramian for Parametrized Nonlinear Systems"; Mathematical Modelling, 8(1): 727728, 2015.
 Synopsis: Use of the empirical cross gramian for parametric model order reduction by averaging.
 Links: sourcecode, runmycode
 C. Himpe, M. Ohlberger; "CrossGramianBased Combined State and Parameter Reduction for LargeScale Control Systems"; Mathematical Problems in Engineering, 2014: 113, 2014.
 Synopsis: Introduction of the empirical cross gramian and the derived joint gramian as well as gramianbased combined reduction.
 Links: selfarchived, sourcecode, runmycode
 C. Himpe, M. Ohlberger; "Model Reduction for Complex Hyperbolic Networks"; Proceedings of the European Control Conference: 27392743, 2014.
 Synopsis: Cross gramian based model reduction of a timevarying nonsymmetric system with application in network cosmology.
 Links: preprint, sourcecode, runmycode
 C. Himpe, M. Ohlberger; "A Unified Software Framework for Empirical Gramians"; Journal of Mathematics, 2013: 16, 2013.
 Synopsis: Mathematical background on and implementation of empirical gramians under a common interface.
 Links: selfarchived, sourcecode, runmycode
Contact
Send feedback to: ch@gramian.de
Cite
 Cite as: C. Himpe (2018). emgr  EMpirical GRamian Framework (Version 5.3) [Software]. http://gramian.de doi:10.5281/zenodo.1134429
 BibTeX:
@MISC{emgr, author={C.~Himpe}, title={{emgr  EMpirical GRamian Framework (Version~5.3)}},
howpublished={\url{http://gramian.de}}, year={2018}, doi={10.5281/zenodo.1134429}}
 DOI: 10.5281/zenodo.1134429 (Version 5.3)
 Except where otherwise noted, content on this site is licensed under a CC BY 4.0 license.
 Last Change: 20180101
Links
 emgr_ref.pdf (emgr reference card)
 emgr_flyer.pdf (emgr flyer)
 emgr_poster_2015.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)
 researchgate.net/project/emgrEMpiricalGRamianFramework (emgr at researchgate)
 mathworks.com/matlabcentral/fileexchange/40169emgrempiricalgramianframework (emgr at fileexchange)
 swmath.org/software/7554 (emgr at swMATH)
 freshcode.club/projects/emgr (emgr at freshcode)
 openhub.net/p/emgr (emgr at openhub)
 modelreduction.org (Model Order Reduction Wiki)
 morepas.org (Model Reduction for Parametrized Systems)
 en.wikibooks.org/wiki/Control_Systems (Control Systems Wikibook)
 git.io/hapod (Hierarchical Approximate Proper Orthogonal Decomposition)
 git.io/mtips (Octave / Matlab Snippets)
Notes
 emgr has a README.
 emgr has a special version emgr_oct.m using Octave's advanced syntax.
 emgr can compute the empirical cross gramian columnwise, and thus in parallel on distributed memory systems.
 emgr is not explicitly parallelized but multicore ready by extensive vectorization and implicit parallelization.
 emgr has highlighted loops that qualify for explicit parallelization using
parfor
.  emgr's custom dotproduct can be used for GPGPU based matrix multiplication.
 emgr consists of a single file and has less than 500 lines of code!
 emgr can only handle realvalued trajectory data.
 emgr's empirical gramian quality depends heavily on the specification of the operating region and the solver.
Troubleshooting
 Issue: An empirical gramian contains very large or infinity values.
 Fix: Likely an unstable trajectory, ensure the perturbations (scales) or parameters do not destabilize the system and a suitable ODE solver is used.
 Issue: The linear cross gramian
Wy
is zero. Fix: The second argument for the empirical inear cross gramian has to be the system's adjoint vector field, NOT the output functional.
 Issue: The identifiability gramian
Wi{2}
or crossidentifiability gramianWj{2}
are zero. Fix: The parameter steady state (initial state) does not excite the system; usually this means setting
xs
≠ 0 ornf(8) = 1
.
 Fix: The parameter steady state (initial state) does not excite the system; usually this means setting
See Also
 Model Reduction Routines (Another Empirical Gramian Software; empirical Wc and Wo only)
 gram (Octave Control Package; linear Wc and Wo only)
 empirical gramian reference list