emgr - empirical gramian framework (software afternoon)

46
emgr - Empirical Gramian Framework Christian Himpe ([email protected]) Mario Ohlberger ([email protected]) WWU Münster Institute for Computational and Applied Mathematics ESCO2014 (Software Afternoon)

Upload: gramian

Post on 19-Jun-2015

84 views

Category:

Science


2 download

DESCRIPTION

held at ESCO 2014 - june 2014

TRANSCRIPT

Page 1: emgr - Empirical Gramian Framework (Software Afternoon)

emgr - Empirical Gramian Framework

Christian Himpe ([email protected])Mario Ohlberger ([email protected])

WWU MünsterInstitute for Computational and Applied Mathematics

ESCO2014(Software Afternoon)

Page 2: emgr - Empirical Gramian Framework (Software Afternoon)

About

General Topic:Model ReductionSystem IdentificationUncertainty Quantification

Outline:Mathematical BackgroundCapabilities and FeaturesExamples and Demos

source: clker.com

Page 3: emgr - Empirical Gramian Framework (Software Afternoon)

Why?

Tasks:fMRI / fNIRS, EEG / MEGConnectivity AnalysisHyperbolic NetworksDiscretized PDEs

Challenges:Large-Scale ODEsNonlinearites

source: clker.com

Page 4: emgr - Empirical Gramian Framework (Software Afternoon)

emgr (At A Glance)

emgr - EMpirical GRamian FrameworkVersion 2.2Open-Source (BSD 2-Clause-License)Compatible with

OctaveMatlab(FreeMat)

about 400 LoC

Page 5: emgr - Empirical Gramian Framework (Software Afternoon)

emgr (Areas of Application)

Model Order ReductionState ReductionParameter ReductionCombined Reduction

Parameter IdentificationSensitivity Analysis

source: clker.com

Page 6: emgr - Empirical Gramian Framework (Software Afternoon)

emgr Features

Implementation Details:Uniform InterfaceAdaptable Solver BackendOnly Matrix and Vector OperationsGeneralized Transpositions

Performance Details:VectorizedImplicit ParallelizationExplicitly ParallelizableProfiled & Benchmarked

source: clker.com

Page 7: emgr - Empirical Gramian Framework (Software Afternoon)

Control Systems

Attributes:Input(Internal) StateOutputDynamics (ODE / PDE)

Page 8: emgr - Empirical Gramian Framework (Software Afternoon)

General Control Systems

x(t) = f (x(t), u(t))y(t) = g(x(t), u(t))x(0) = x0

Input / Control: u ∈ RM

State: x ∈ RN

Output: y ∈ RO

Vector Field: f : RN ×RM ×R→ RN

Output Functional: g : RN ×RM → RO

Page 9: emgr - Empirical Gramian Framework (Software Afternoon)

Linear Control Systems1

x(t) = Ax(t) + Bu(t)y(t) = Cx(t)x(0) = x0

Input / Control: u ∈ RM

State: x ∈ RN

Output: y ∈ RO

System Matrix: A ∈ RN×N

Input Matrix: B ∈ RN×M

Output Matrix: C ∈ RO×N

1Adjoint System: ˙x = AT x + CT u; y = BT x

Page 10: emgr - Empirical Gramian Framework (Software Afternoon)

Large-Scale Systems

Large-Scale Control System:

x = f (x , u)y = g(x , u)

State: x � 1Input: u � xOutput: y � x

Large-Scale Parametrized Control System:

x = f (x , u, θ)y = g(x , u, θ)

Parameter: θ � 1

Page 11: emgr - Empirical Gramian Framework (Software Afternoon)

Controllability & Observability [Moore’81]

Controllability Operator:

C(u) :=∫ ∞

0eAtBu(t)dt

Observability Operator:

O(x0) := CeAtx0

Page 12: emgr - Empirical Gramian Framework (Software Afternoon)

Controllability Gramian

Controllability Gramian:

WC := CCT

=

∫ ∞0

eAtBBT eAT tdt

⇒ AWC + WCAT = −BBT WC

Page 13: emgr - Empirical Gramian Framework (Software Afternoon)

Observability Gramian

Observability Gramian:

WO := OTO

=

∫ ∞0

eAT tCTCeAtdt

⇒WOAT + AWO = −CTCWO

Page 14: emgr - Empirical Gramian Framework (Software Afternoon)

Cross Gramian [Fernando & Nicholson’83]

Cross Gramian2 :

WX := CO

=

∫ ∞0

eAtBCeAtdt

⇒ AWX + WXA = −BCWX

2The control system has to be square, better: symmetric!

Page 15: emgr - Empirical Gramian Framework (Software Afternoon)

Model Reduction for Linear Control Systems

Balanced Truncation:

WOCholesky

= LOLTO

WCCholesky

= LCLTC

LCLTO

SVD= UDV T

σ1 > . . . > σN

→ U =

(U1U2

), V =

(V1V2

)T

A = V1AU1

B = V1B

C = CU1

x0 = V1x0

Direct Truncation:

WXSVD= UDV T

σ1 > . . . > σN

→ U =

(U1U2

)

A = UT1 AU1

B = UT1 B

C = CU1

x0 = UT1 x0

Page 16: emgr - Empirical Gramian Framework (Software Afternoon)

Model Reduction for Nonlinear Control Systems

Balanced Truncation:

WOCholesky

= LOLTO

WCCholesky

= LCLTC

LCLTO

SVD= UDV T

σ1 > . . . > σN

→ U =

(U1U2

), V =

(V1V2

)T

f = V1f (U1x , u, θ)g = g(U1x , u, θ)x0 = V1x0

Direct Truncation:

WXSVD= UDV T

σ1 > . . . > σN

→ U =

(U1U2

)

f = UT1 f (U1x , u, θ)

g = g(U1x , u, θ)

x0 = UT1 x0

Page 17: emgr - Empirical Gramian Framework (Software Afternoon)

Empirical Gramians (About)

System Gramians:

WC =

∫ ∞0

(eAtB) (eAtB)Tdt

WO =

∫ ∞0

(eAT tCT ) (eAT tCT )Tdt

WX =

∫ ∞0

(eAtB) (eAT tCT )Tdt

Integrands are just impulse responses!

→ Compute gramians empirically.

Page 18: emgr - Empirical Gramian Framework (Software Afternoon)

emgr (Capabilities)

Empirical Gramians:1 Empirical Controllability Gramian ( WC )2 Empirical Observability Gramian ( WO )3 Empirical Linear Cross Gramian ( WY )4 Empirical Cross Gramians ( WX )

5 Empirical Sensitivity Gramian ( WS )6 Empirical Identifiability Gramian ( WI )7 Empirical Joint Gramian ( WJ )

Page 19: emgr - Empirical Gramian Framework (Software Afternoon)

emgr (Signature)

Minimal Signature:W = emgr(f, g, q, t, w);

Full Signature:W = emgr(f, g, q, t, w, pr, nf, ut, us, xs, um, xm, yd);

f - System Function Handleg - Output Function Handleq - System Dimension(Inputs, States, Outputs)t - Time(Start, Step, Stop)w - Gramian Type(’c’, ’o’, ’x’, ’y’, ’s’, ’i’, ’j’)

pr - Parametersnf - Configurationut - Inputus - Steady State Inputxs - Steady Stateum - Input Scalesxm - State Scalesyd - Data

Page 20: emgr - Empirical Gramian Framework (Software Afternoon)

Empirical Gramians (Perturbations)

Impulse Input Perturbations: uhij(t) = chSiejδ(t)

Eu = {ei ∈ Rm; ‖ei‖ = 1; eiej 6=i = 0; i = 1, . . . ,m},Ru = {Si ∈ Rm×m; ST

i Si = 1; i = 1, . . . , s},Qu = {ci ∈ R; ci > 0; i = 1, . . . , q},

Initial State Perturbation: xkla0 = dkTl fa

Ex = {fi ∈ Rn; ‖fi‖ = 1; fi fj 6=i = 0; i = 1, . . . , n},Rx = {Ti ∈ Rn×n;TT

i Ti = 1; i = 1, . . . , t},Qx = {di ∈ R; di > 0; i = 1, . . . , r}.

Page 21: emgr - Empirical Gramian Framework (Software Afternoon)

emgr (Perturbations)

Impulse Input Perturbations: uhij(t) = chSiejδ(t)

Eu = {eRm

i=1...m},Ru = {−1,1},Qu = {ci ∈ R; ci > 0; i = 1, . . . , q},

Initial State Perturbation: xkla0 = dkTl fa

Ex = {eRn

i=1...n},Rx = {−1,1},Qx = {di ∈ R; di > 0; i = 1, . . . , r}.

Page 22: emgr - Empirical Gramian Framework (Software Afternoon)

Example System3

Linear MIMO Control System:

u(t) = δ(t)x(t) = Ax(t) + Bu(t)y(t) = Cx(t)

x0 = 0

Dimensions:Input: u(t) ∈ R16

State: x(t) ∈ R256

Output: y(t) ∈ R16

Attributes:State-Space Symmetric:A = AT , B = CT

⇒ WC = WO = WX

3Random System via Inverse Lypunov Procedure (see [Smith’03])

Page 23: emgr - Empirical Gramian Framework (Software Afternoon)

Empirical Controllability Gramian [Lall et al’99]

Analytic Controllability Gramian

WC =

∫ ∞0

eAtBBT eAT tdt

Linear Empirical Controllability Gramian

W ′C =

∫ ∞0

x(t) xT (t)dt

Empirical Controllability Gramian

W ′′C =

1|Qu||Ru|

|Qu |∑h=1

|Ru |∑i=1

m∑j=1

1c2h

∫ ∞0

Ψhij (t)dt,

Ψhij (t) = (xhij (t)− x)(xhij (t)− x)T ∈ Rn×n

Discrete Empirical Controllability Gramian

W ′′′C =

1|Qu||Ru|

|Qu |∑h=1

|Ru |∑i=1

m∑j=1

∆tc2h

T∑t=0

Ψhijt ,

Ψhijt = (xhij

t − x)(xhijt − x)T ∈ Rn×n

Page 24: emgr - Empirical Gramian Framework (Software Afternoon)

Example: POD

System:

x = Ax + Bu

Dimensions:

Input: u(t) ∈ R16

State: x(t) ∈ R256

Relative L2-Error:

Code:f = @(x,u,p) A*x+B*u;g = 1;q = [16,256,16];t = [0,0.01,1.0];WC = emgr(f,g,q,t,’c’);[U, D, V] = svd(WC);

Page 25: emgr - Empirical Gramian Framework (Software Afternoon)

Empirical Observability Gramian [Lall et al’99]

Analytic Observability Gramian

WO =

∫ ∞0

eAT tCTCeAtdt

Linear Empirical Observability Gramian

W ′O =

∫ ∞0

x(t) xT (t)dt

Empirical Observability Gramian

W ′′O =

1|Qx ||Rx |

|Qx |∑k=1

|Rx |∑l=1

1d2

k

∫ ∞0

TlΨkl (t)TT

l dt,

Ψklab = (ykla(t)− y)T (yklb(t)− y) ∈ R

Discrete Empirical Observability Gramian

W ′′′O =

1|Qx ||Rx |

|Qx |∑k=1

|Rx |∑l=1

∆td2

k

T∑t=0

TlΨtklTTl ,

Ψklt,ab = (ykla

t − y)T (yklbt − y) ∈ R

Page 26: emgr - Empirical Gramian Framework (Software Afternoon)

Example: Balanced Truncation

System:

x = Ax + Bu

y = Cx

Dimensions:

Input: u(t) ∈ R16

State: x(t) ∈ R256

Output: y(t) ∈ R16

Relative L2-Error:

Code:f = @(x,u,p) A*x+B*u;g = @(x,u,p) C*x;q = [16,256,16];t = [0,0.01,1.0];WC = emgr(f,g,q,t,’c’);WO = emgr(f,g,q,t,’o’);[U, D, V] = balance(WC,WO);

Page 27: emgr - Empirical Gramian Framework (Software Afternoon)

Example: Balanced Truncation

System:

x = Ax + Bu

y = Cx

Dimensions:

Input: u(t) ∈ R16

State: x(t) ∈ R256

Output: y(t) ∈ R16

Relative L2-Error:

Code:f = @(x,u,p) A*x+B*u;F = @(x,u,p) A’*x+C’*u;q = [16,256,16];t = [0,0.01,1.0];WC = emgr(f,1,q,t,’c’);WO = emgr(F,1,q,t,’c’);[U, D, V] = balance(WC,WO);

Page 28: emgr - Empirical Gramian Framework (Software Afternoon)

Empirical Cross Gramian [Streif’06, H.’14]

Analytic Cross Gramian

WX =

∫ ∞0

eAtBCeAtdt

Linear Empirical Cross Gramian

W ′X =

∫ T

0x(t)xT (t)dt

Page 29: emgr - Empirical Gramian Framework (Software Afternoon)

Example: (Linear) Direct Truncation

System:

x = Ax + Bu

y = Cx

Dimensions:

Input: u(t) ∈ R16

State: x(t) ∈ R256

Output: y(t) ∈ R16

Relative L2-Error:

Code:f = @(x,u,p) A*x+B*u;g = @(x,u,p) A’*x+C’*u;q = [16,256,16];t = [0,0.01,1.0];WY = emgr(f,g,q,t,’y’);[U, D, V] = svd(WY);

Page 30: emgr - Empirical Gramian Framework (Software Afternoon)

Empirical Cross Gramian [Streif’06, H.’14]

Analytic Cross Gramian

WX =

∫ ∞0

eAtBCeAtdt

Linear Empirical Cross Gramian

W ′X =

∫ T

0x(t)xT (t)dt

Empirical Cross Gramian

W ′′X =

1|Qu||Ru|m|Qx ||Rx |

|Qu |∑h=1

|Ru |∑i=1

m∑j=1

|Qx |∑k=1

|Rx |∑l=1

1chdk

∫ ∞0

TlΨhijkl (t)TT

l dt,

Ψhijklab (t) = f T

b TTk (xhij (t)− x)eT

i STh (ykla(t)− y)

Discrete Empirical Cross Gramian

W ′′′X =

1|Qu||Ru|m|Qx ||Rx |

|Qu |∑h=1

|Ru |∑i=1

m∑j=1

|Qx |∑k=1

|Rx |∑l=1

∆tchdk

T∑t=0

TlΨhijklt TT

l ,

Ψhijklt,ab = f T

b TTk (xhij

t − x)eTi ST

h (yklat − y)

Page 31: emgr - Empirical Gramian Framework (Software Afternoon)

Example: Direct Truncation

System:

x = Ax + Bu

y = Cx

Dimensions:

Input: u(t) ∈ R16

State: x(t) ∈ R256

Output: y(t) ∈ R16

Relative L2-Error:

Code:f = @(x,u,p) A*x+B*u;g = @(x,u,p) C*x;q = [16,256,16];t = [0,0.01,1.0];WX = emgr(f,g,q,t,’x’);[U, D, V] = svd(WX);

Page 32: emgr - Empirical Gramian Framework (Software Afternoon)

Parametrized Example Systems4

Parametrized General Control System:

x(t) = f (x(t), u(t), θ)y(t) = g(x(t), u(t), θ)

Parametrized Linear Control System:

x(t) = A(θ)x(t) + B(θ)u(t)y(t) = C (θ)x(t)

4Diagonal Entries of System Matrix A are considered parameters here.

Page 33: emgr - Empirical Gramian Framework (Software Afternoon)

Empirical Sensitivity Gramian [Sun’06, H.’13]

Parameter Decomposed System:

x = f (x , u) +P∑

k=1

f (x , θk)

⇒WC = WC ,0 +P∑

k=1

WC ,k

Sensitivity Gramian:

WS ,ii = tr(WC ,i )

Page 34: emgr - Empirical Gramian Framework (Software Afternoon)

Example: Sensitivity Analysis

System:

x = A(θ)x + Bu

y = Cx

Dimensions:

Input: u(t) ∈ R16

State: x(t) ∈ R256

Output: y(t) ∈ R16

Parameter: θ ∈ R256

Parameter Sensitivity:

Code:f = @(x,u,p) (A+diag(p))*x+B*u;g = @(x,u,p) C*x;q = [16,256,16];t = [0,0.01,1.0];WS = emgr(f,g,q,t,’s’,p,0,1,1);

Page 35: emgr - Empirical Gramian Framework (Software Afternoon)

Empirical Identifiability Gramian [Geffen’08]

Parameter Augmented System:(xθ

)=

(A 00 0

)(xθ

)+

(B0

)u

y =(C 0

)(xθ

)(

x(0)θ(0)

)=

(x0θ0

)Observability Gramian of Parameter Augmented System:

WO =

(WO WMW T

M WP

)Identifiability Gramian:(Schur Complement of Augmented Observability Gramian)

WI := WP −WMW−1O W T

M ≈WP

Page 36: emgr - Empirical Gramian Framework (Software Afternoon)

Example: Parameter Reduction

System:

x = A(θ)x + Bu

y = Cx

Dimensions:

Input: u(t) ∈ R16

State: x(t) ∈ R256

Output: y(t) ∈ R16

Parameter: θ ∈ R256

Relative L2-Error:

Code:f = @(x,u,p) (A+diag(p))*x+B*u;g = @(x,u,p) C*x;q = [16,256,16];t = [0,0.01,1.0];WI = emgr(f,g,q,t,’i’,p,0,1,0,1);[P, S, Q] = svd(WI{2});

Page 37: emgr - Empirical Gramian Framework (Software Afternoon)

Empirical Joint Gramian [H.’14]

Parameter Augmented System:(xθ

)=

(A 00 0

)(xθ

)+

(B0

)u

y =(C 0

)(xθ

)(

x(0)θ(0)

)=

(x0θ0

)Joint Gramian:(Cross Gramian of Parameter Augmented System)

WJ =

(WX WM0 0

)Cross-Identifiability Gramian:(Schur Complement of Symmetric Part of Joint Gramian)

WI := −12WM(WX + W T

X )−1W TM

Page 38: emgr - Empirical Gramian Framework (Software Afternoon)

Example: Combined Reduction

System:

x = A(θ)x + Bu

y = Cx

Dimensions:

Input: u(t) ∈ R16

State: x(t) ∈ R256

Output: y(t) ∈ R16

Parameter: θ ∈ R256

Relative L2-Error:

Code:f = @(x,u,p) (A+diag(p))*x+B*u;g = @(x,u,p) C*x;q = [16,256,16];t = [0,0.01,1.0];WJ = emgr(f,g,q,t,’j’,p,0,1,0,1);[U, D, V] = svd(WJ{1});[P, S, Q] = svd(WJ{2});

Page 39: emgr - Empirical Gramian Framework (Software Afternoon)

More emgr Use Cases

Sensitivity Analysis via System GainNonlinearity QuantificationDecentralized ControlSolve Lyapunov Equations and Sylvester Equations

Page 40: emgr - Empirical Gramian Framework (Software Afternoon)

emgr (Signature)

Minimal Signature:W = emgr(f, g, q, t, w);

Full Signature:W = emgr(f, g, q, t, w, pr, nf, ut, us, xs, um, xm, yd);

f - System Function Handleg - Output Function Handleq - System Dimension(Inputs, States, Outputs)t - Time(Start, Step, Stop)w - Gramian Type(’c’, ’o’, ’x’, ’y’, ’s’, ’i’, ’j’)

pr - Parametersnf - Configurationut - Inputus - Steady State Inputxs - Steady Stateum - Input Scalesxm - State Scalesyd - Data

Page 41: emgr - Empirical Gramian Framework (Software Afternoon)

emgr (Configuration Options)

1 Center: Steady-State, Mean, Median, Last, Principal, Zero2 Input Scale Sequence: Linear, Log, Geometric, Single3 State Scale Sequence: Linear, Log, Geometric, Single4 Input Rotations: Unit, Reciproce, Dyadic, Single5 State Rotations: Unit, Reciproce, Dyadic, Single6 Double Run?7 Use Measured Data?8 Robust Parameters: None, Active or Passive?9 Adjust Parameter Scales?10 Schur Complement on WI ?11 Enforce Gramian Symmetry?12 Solver/Integrator: RK1,AB2,RRK2,ARK3,Leapfrog,CUSTOM

Solver signature: x = CUSTOM_ODE(f,h,T,z,u,p)

Page 42: emgr - Empirical Gramian Framework (Software Afternoon)

Public Service Announcement

DownloadDocumentationDemos

source: clker.com

at:

http://gramian.de

Page 43: emgr - Empirical Gramian Framework (Software Afternoon)

Outlook

Technical:SymmetrizersNon-Symmetric Cross GramiansParametrized Linear Cross Gramian

Implementation:Accelerator Offloading (Xeon Phi)Python Version(into pyMOR: http://pymor.org)(Julia Version)(asm.js Version)

Page 44: emgr - Empirical Gramian Framework (Software Afternoon)

Listings

ORMS (Oberwolfach References on Mathematical Software)

swMATH (Information Service for Mathematical Software)

MoRePas (Model Reduction for Parametrized Systems)

MORwiki (Model Order Reduction Wiki)

GitHub

Page 45: emgr - Empirical Gramian Framework (Software Afternoon)

tl;dl

emgr - Empirical Gramian Framework

http://gramian.de

Thanks!

Page 46: emgr - Empirical Gramian Framework (Software Afternoon)

Code & References

Companion Source Code: http://j.mp/esco2014

C. Himpe, M. Ohlberger; “A Unified Software Frameworkfor Empirical Gramians”; Journal of Mathematics 2013:1-6,2013

C. Himpe, M. Ohlberger; “Cross-Gramian Based CombinedState and Parameter Reduction for Large-Scale ControlSystems”; Mathematical Problems in Engineering (Accepted),2014

C. Himpe, M. Ohlberger; “Model Reduction for ComplexHyperbolic Networks” Proceedings of the ECC’14(Accepted), 2014