Stability Analysis of Rule-Based Affine Systems Using Model Checking 2014 S5 Jonathan Hoffman, Kuldip S. Rattan, and Matthew Clark AFRL Aerospace Systems Directorate Verification and Validation of Complex Systems 14 June 2014 Integrity Service Excellence DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) Rule-Based Systems • Natural language is a convenient way of describing the if-then natural rules for controlling a dynamic system. • Fuzzy Logic is a method to represent If-then rules • Fuzzy systems can be used to approximate the behavior of a non-linear system and then be converted into a piecewise linear representation. • But how do we convert Fuzzy systems into a form that is analyzable for verification and validation? • Specifically, how do we analyze the stability of a Piecewise Affine Fuzzy System • How scalable is this stability analysis approach to large piecewise linear systems? DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 2 Two State Rule Base Controller Classic Controller Fuzzy Controller X1 NB X1 NM X1 NS X1 Z X1 PS X1 PM X1 PB X2 NB NB NB NB NB NM NS Z RULE BASE X2 X2 X2 X2 X2 NM NS Z PS PM NB NB NB NM NS NB NB NM NS Z NB NM NS Z PS NM NS Z PS PM NS Z PS PM PB Z PS PM PB PB PS PM PB PB PB DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) X2 PB Z PS PM PB PB PB PB 3 Two State Inference System DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 4 Piecewise Hybrid System Derivation Sandhu, G. S., Brehm, T., & Rattan, K. S. (1996, May). Analysis and design of a proportional plus derivative fuzzy logic controller. In Proceedings of Aerospace and Electronics Conference, 1996. (Vol. 1, pp. 397-404). IEEE. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 5 Equivalent Piecewise Hybrid Controller Mode 𝑒𝑒 Classic Linear Controller ∆𝑒𝑒 Piecewise Linear Controller 𝑒𝑒 ∆𝑒𝑒 Kp𝒆𝒆𝒆𝒆𝒆𝒆 K𝒅𝒅𝒆𝒆𝒆𝒆𝒆𝒆 𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪 u =Kp𝒆𝒆𝒆𝒆𝒆𝒆 ∗e + K𝒅𝒅𝒆𝒆𝒆𝒆𝒆𝒆 ∗ 𝚫𝚫𝚫𝚫 + 𝒄𝒄𝒄𝒄𝒄𝒄𝒄𝒄 DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 6 Equivalent Piecewise Hybrid Controller Mode DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 7 Hybrid Model DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 8 Lyapnuov Function • For linear systems , assume a quadratic function • System is stable if we can find a P such that the Lyapnuov equation 𝑃𝑃 ∗ 𝐴𝐴 + 𝐴𝐴𝑇𝑇 ∗ 𝑃𝑃 + 𝑄𝑄 ≤ 0, 𝑄𝑄 > 0 • For a nonlinear system, there is no generic method. However, a polynomial Lyapnuov function can be searched using semidefinite programming or S-procedure. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 9 Lyapnuov Function for Hybrid Systems • For a hybrid system where i indicates the mode the mode selection, the stability of the switched systems cannot be inferred from the stability of the individual mode. • For examples for two modes (m=2) , if both modes are stable (we can find positive definite ), switching can result in the hybrid system unstable for some initial conditions. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 10 Hybrid System • 𝑥𝑥̇ = 𝐴𝐴𝑖𝑖 𝑥𝑥 + 𝐵𝐵𝐵𝐵 • 𝑦𝑦 = 𝐶𝐶𝐶𝐶 + 𝐷𝐷𝐷𝐷 −1 10 • 𝐴𝐴1 = −100 −1 −1 100 • 𝐴𝐴2 = −10 −1 1 • 𝑥𝑥 0 = 0 0 𝐵𝐵 = 1 1 𝐶𝐶 = 0 0 𝐷𝐷 = 0 0 1 DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 11 Zero-Input Response A1 Zero-Input Response A2 Zero-Input Response Stable Marginally Stable DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 12 Hybrid System Switching State 1 𝐴𝐴1 −1 10 −100 −1 𝑥𝑥1 𝑥𝑥2 < 0 State 2 𝐴𝐴2 𝑥𝑥1 𝑥𝑥2 > 0 −1 −10 DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 100 1 13 Effects of Switching System 1 State 1 𝐴𝐴1 −1 10 −100 −1 System 2 State 1 𝑥𝑥1 𝑥𝑥2 < 0 𝐴𝐴2 𝑥𝑥1 𝑥𝑥2 > 0 𝑥𝑥1 𝑥𝑥2 < 0 𝐴𝐴2 −1 100 −10 1 State 2 𝑥𝑥1 𝑥𝑥2 > 0 −1 100 −10 1 State 2 𝐴𝐴1 −1 10 −100 −1 DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 14 Effects of Switching System 1 State 1 𝐴𝐴1 −1 10 −100 −1 System 2 State 1 𝑥𝑥1 𝑥𝑥2 < 0 𝐴𝐴2 𝑥𝑥1 𝑥𝑥2 > 0 𝑥𝑥1 𝑥𝑥2 < 0 𝐴𝐴2 −1 100 −10 1 State 2 𝑥𝑥1 𝑥𝑥2 > 0 −1 100 −10 1 Stable State 2 𝐴𝐴1 −1 10 −100 −1 Unstable DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 15 Lyapnuov Function for Hybrid Systems (Cont’d) • If the switching results in a stable systems, there should exists a common (global) P matrix. However, finding this P matrix is difficult. • On the other hand, if both modes are unstable, switching can make the overall system stable. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) Lyapunov Stability for Hybrid Systems • Lyapunov Stability Equations: • 𝑃𝑃 ∗ 𝐴𝐴 + 𝐴𝐴𝑇𝑇 ∗ 𝑃𝑃 + 𝐼𝐼 ≤ 0 • 𝑉𝑉 𝑥𝑥 = 𝑥𝑥 𝑇𝑇 𝑃𝑃𝑃𝑃 • Objective is to determine a positive definite matrix P to satisfy the Lyapunov equations for a hybrid system. • Want to find a single P matrix for whole system. • Difficulties • The A matrices change due to switching • Switching itself can cause instability DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 17 Possible Approaches • Two possible Approaches 1. Find a P matrix common to each hybrid mode 2. Use simulation data to calculate a ‘Global’ P • First approach could be very difficult for hybrid systems with many modes. • Also, as shown in the previous example, a system can be stable or unstable depending on the switching mechanism, regardless of the individual mode dynamics. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 18 Finding a Global P • Hypothesis: – A global P matrix that solves Lyapunov equations can be found by running zero-input simulations of a hybrid system and calculating a positive definite P matrix to fit a decreasing energy function, V(x). – The P matrix can be verified for all initial conditions (in a specified range) by using a model checker. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 19 Lyapunov Stability for Hybrid Systems • It has been shown that Lyapunov stability can be extended to hybrid systems. • The switching of the hybrid system separates V(x) into distinct intervals. • 𝑉𝑉 𝑥𝑥 = 𝑥𝑥 𝑇𝑇 𝑃𝑃𝑃𝑃 • 𝑉𝑉̇ (𝑥𝑥) ≤ 0 Branicky, Michael S. "Multiple Lyapunov functions and other analysis tools for switched and hybrid systems." Automatic Control, IEEE Transactions on 43.4 (1998): 475-482. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 20 Lyapunov Stability for Hybrid Systems • Two conditions must be met for stability: – The Lyapunov functions in each interval are decreasing – The maximum value of the Lyapunov function in the interval of 𝑉𝑉𝑖𝑖 is less than the maximum value in the previous interval of 𝑉𝑉𝑖𝑖 DeCarlo, Raymond A., et al. "Perspectives and results on the stability and stabilizability of hybrid systems." Proceedings of the IEEE 88.7 (2000): 1069-1082. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 21 Constraints on Energy Equation • Constraints may be placed on the Energy Equation. • 𝑉𝑉 𝑥𝑥 = 𝑥𝑥 𝑇𝑇 𝑃𝑃𝑃𝑃 ≤ 𝑊𝑊(𝑡𝑡) • 𝑊𝑊(𝑡𝑡) bounds 𝑉𝑉 𝑥𝑥 to be non-increasing W(t) = constant W(t) = exponential DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 22 Approach • Using the previous hybrid system a simulation is run. • Knowing the state data over time the energy equation can be written as a system of equations: • 𝑉𝑉 𝑥𝑥 0 = 𝑥𝑥 𝑇𝑇 0 𝑃𝑃𝑃𝑃 0 ≤ 𝑊𝑊 0 • 𝑉𝑉 𝑥𝑥 𝑛𝑛 = 𝑥𝑥 𝑇𝑇 𝑛𝑛 𝑃𝑃𝑃𝑃 𝑛𝑛 ≤ 𝑊𝑊 𝑛𝑛 • 𝑉𝑉 𝑥𝑥 1 • ⋮ = 𝑥𝑥 𝑇𝑇 1 𝑃𝑃𝑃𝑃 1 ≤ 𝑊𝑊 1 DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 23 Solving for P • The systems of equations can now be solved for P. • For the t=0 case where W is a constant: • 𝑥𝑥 𝑇𝑇 0 𝑃𝑃𝑃𝑃 0 ≤ 𝑊𝑊 𝑃𝑃1 𝑃𝑃2 𝑥𝑥1 0 • 𝑥𝑥1 0 𝑥𝑥2 0 ≤ 𝑊𝑊 𝑃𝑃3 𝑃𝑃4 𝑥𝑥2 0 • 𝑥𝑥1,0 𝑃𝑃1 𝑥𝑥1,0 +𝑥𝑥1,0 𝑃𝑃2 𝑥𝑥2,0 +𝑥𝑥2,0 𝑃𝑃3 𝑥𝑥1,0 +𝑥𝑥2,0 𝑃𝑃4 𝑥𝑥2,0 ≤ 𝑊𝑊 • One inequality is produced for each time step of the simulation. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 24 Solving for P • The system of inequalities becomes: • 𝑥𝑥1,0 𝑃𝑃1 𝑥𝑥1,0 +𝑥𝑥1,0 𝑃𝑃2 𝑥𝑥2,0 +𝑥𝑥2,0 𝑃𝑃3 𝑥𝑥1,0 +𝑥𝑥2,0 𝑃𝑃4 𝑥𝑥2,0 ≤ 𝑊𝑊 • 𝑥𝑥1,1 𝑃𝑃1 𝑥𝑥1,1 +𝑥𝑥1,1 𝑃𝑃2 𝑥𝑥2,1 +𝑥𝑥2,1 𝑃𝑃3 𝑥𝑥1,1 +𝑥𝑥2,1 𝑃𝑃4 𝑥𝑥2,1 ≤ 𝑊𝑊 • ⋮ • 𝑥𝑥1,𝑛𝑛 𝑃𝑃1 𝑥𝑥1,𝑛𝑛 +𝑥𝑥1,𝑛𝑛 𝑃𝑃2 𝑥𝑥2,𝑛𝑛 +𝑥𝑥2,𝑛𝑛 𝑃𝑃3 𝑥𝑥1,𝑛𝑛 +𝑥𝑥2,𝑛𝑛 𝑃𝑃4 𝑥𝑥2,𝑛𝑛 ≤ 𝑊𝑊 • Solving for P is a non trivial problem when there are many equations. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 25 Solving for P • A model checker is a good option to find a P to satisfy the system of equations. • Because model checkers are good at finding counterexamples to logical equations the statement is asserted: – There does not exist a P matrix to satisfy the system of equations. • If a solution to the system of equations exists, the model checker will return with one P matrix that refutes the assertion. This P will satisfy the system of equations for the simulated state data. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 26 Stable/Marginally Stable Switching State 1 𝐴𝐴1 −1 10 −100 −1 𝑥𝑥1 𝑥𝑥2 < 0 State 2 𝐴𝐴2 𝑥𝑥1 𝑥𝑥2 > 0 −1 −10 DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 100 1 27 Stable/Marginally Stable Results Simulation Stable/Marginally Stable Modes Hybrid System • Stable Zero-Input response of the system • Global P matrix found Energy Global P Matrix 𝑃𝑃 = 1.0018 −0.0010 DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) −0.0010 0.1002 28 Two Unstable Modes with Switching State 1 𝐴𝐴1 1 −100 10 1 𝑥𝑥1 𝑥𝑥2 < 0 State 2 𝐴𝐴2 𝑥𝑥1 𝑥𝑥2 > 0 1 −10 DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 100 1 29 Two Unstable Mode Switching Results Simulation 2 Unstable Modes Hybrid System • Stable Zero-Input response of the system • Global P matrix found Energy Global P Matrix 𝑃𝑃 = 1.0000 0.0100 DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 0.0100 0.1000 30 How Scalable? • So how scalable is this stability analysis approach to large piecewise linear systems? DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 31 8 State Proportional Controller S1 S2 S3 S4 S5 S6 S7 S8 • 8 State Proportional Controller built from fuzzy type ruleset. • Problem: Need to guarantee that each state is active at some point in the simulation. • Solution: Run one Zero-Input Response starting in each state and feed all of that data to the model checker. • Potential for optimization later on to minimize the number of simulations needed and resulting in less data for the model checker to analyze. DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 32 8 State Proportional Controller Results Simulations 8 State Hybrid System • Stable Zero-Input response of the system beginning from each of the 8 states • Global P matrix found Energy Global P Matrix 𝑃𝑃 = 1.0254 −0.0010 DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) −0.0010 0.0001 33 36 State Proportional Plus Derivative Controller 1 7 13 19 25 31 2 8 14 20 26 32 Two State Fuzzy statistics - 36 Discrete states - 2 Continous Dynamic Modes 3 9 15 21 27 33 4 10 16 22 28 34 5 11 17 23 29 35 X1 NB X1 NM X1 NS X1 Z X1 PS X1 PM X1 PB X2 NB NB NB NB NB NM NS Z DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 6 12 18 24 30 36 RULE BASE X2 X2 X2 X2 X2 NM NS Z PS PM NB NB NB NM NS NB NB NM NS Z NB NM NS Z PS NM NS Z PS PM NS Z PS PM PB Z PS PM PB PB PS PM PB PB PB X2 PB Z PS PM PB PB PB PB 34 36 State Proportional Plus Derivative Results Simulations 36 State Hybrid System • Stable Zero-Input response of the system beginning from each of the 36 states • Global P matrix found Energy Global P Matrix 𝑃𝑃 = 1.0018 −0.0010 DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) −0.0010 0.1002 35 Future Work • • • • 3+ Continuous Dimensions Unstable / Marginally Stable systems Cascading / Multistage Rule Bases Verification of Learned Behaviors DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 36 Questions? DISTRIBUTION STATEMENT A: Approved for Public Release; Distribution Unlimited (Case Number: 88ABW-2014-2758) 37