diff --git a/README.md b/README.md index 8465b1d966272b23632183f7cc8d93f63697bf1f..b61fe366f67b89220280a96de82283e04d9d4bd4 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,11 @@ make test ./run_evaluation_double_integrator_switching.sh ``` +```sh +# Computes the stability coefficients for [1, Theorem 9] +./run_evaluation_double_integrator_mk_stability.sh +``` + ```sh # Cleans intermediate files make clean diff --git a/run_evaluation_double_integrator_mk_stability.sh b/run_evaluation_double_integrator_mk_stability.sh new file mode 100755 index 0000000000000000000000000000000000000000..501314bdc208a6b640cd670fe342eaa066a6dffb --- /dev/null +++ b/run_evaluation_double_integrator_mk_stability.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +## This file is part of the simulative evaluation for the qronos observer abstractions. +## Copyright (C) 2022-2023 Tim Rheinfels <tim.rheinfels@fau.de> +## See https://gitlab.cs.fau.de/qronos-state-abstractions/simulation +## +## 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. +## +## 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +## +## 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 HOLDER 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. + +make initialize + +source config.sh + +pipenv run python -m evaluation.double_integrator_mk_stability diff --git a/src/evaluation/double_integrator_mk_stability.py b/src/evaluation/double_integrator_mk_stability.py new file mode 100644 index 0000000000000000000000000000000000000000..3aa14f885c52d61c840a13020ea8dc3615d4920f --- /dev/null +++ b/src/evaluation/double_integrator_mk_stability.py @@ -0,0 +1,93 @@ +## This file is part of the simulative evaluation for the qronos observer abstractions. +## Copyright (C) 2022-2023 Tim Rheinfels <tim.rheinfels@fau.de> +## See https://gitlab.cs.fau.de/qronos-state-abstractions/simulation +## +## 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. +## +## 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +## +## 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 HOLDER 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. + +### +### @file evaluation/double_integrator_mk_stability.py +### +### @brief Script computing the stability coefficients stated in @cite ECRTS23-Rheinfels Theorem 9 +### +### @author Tim Rheinfels <tim.rheinfels@fau.de> +### + +## +## Additional material for ECRTS'23 submission #38 +## A New Perspective on Criticality: +## Efficient State Abstraction and Run-Time Monitoring +## of Mixed-Criticality Real-time Control Sytstems. +## +## This file provides the data for Theorem 9 thus +## verifying that the benchmark system is exponentially stable +## under (1, 5)-firm scheduling. +## + +import numpy as np +import scipy as sp +import scipy.linalg + +# === Dynamic matrices of both modes === + +# Control +A0 = np.array([ + [ 0.995000, 0.082050], + [-0.110000, 0.805000], +]) + +# Skip +A1 = np.array([ + [1.0000, 0.0909], + [0.0000, 1.0000], +]) + +# Compute matrix power A^n +def Mpow(A, n): + assert(A.ndim == 2 and A.shape[0] == A.shape[1]) + result = np.eye(A.shape[0]) + for i in range(n): + result = A @ result + return result + +# Compute the norm ||A||_{PP} with P = P_sqrt_T.T @ P_sqrt_T by eq. (1b) +def P_norm(A, P_sqrt_T): + return np.linalg.norm(P_sqrt_T @ A @ np.linalg.inv(P_sqrt_T), 2) + +# Heuristically choose P. Note the dlyap uses the transposed of our analysis. +P = sp.linalg.solve_discrete_lyapunov( (A0 @ Mpow(A1, 4)).T, np.eye(2) ) + +# Compute Cholesky factorization +P_sqrt_T = np.linalg.cholesky(P).T + +# Compute precursors to stability coefficients by finding the maximum +# over 0..4 controller skips. +C_tilde = 0.0 +l_tilde = 0.0 +for i in range(5): + A1_i = Mpow(A1, i) + + C_tilde_cand = P_norm(A1_i, P_sqrt_T) + l_tilde_cand = P_norm(A0 @ A1_i, P_sqrt_T) + if l_tilde_cand > l_tilde: + l_tilde = l_tilde_cand + if C_tilde_cand > C_tilde: + C_tilde = C_tilde_cand + +# Compute final stability coefficients +l = l_tilde**(1.0 / 5.0) +C = C_tilde / l_tilde + +# Output results +print('C = %f' % C) +print('lambda_tilde = %f' % l_tilde) +print('lambda = %f' % l) +print('P:') +print(P)