Scots (0.2) - User Manual
Scots (0.2) - User Manual
2) – USER MANUAL
MATTHIAS RUNGGER
MARCH 29, 2017
CONTENTS
1. About SCOTS v0.2 2
2. Quickstart 2
2.1. Invariance and Reachability 2
2.2. Customized Synthesis 2
2.3. A Priori Enclosure and Growth Bound 2
3. Installation Notes 3
3.1. Additional software 3
Part 2. USAGE 11
7. Computation of Symbolic Models 11
8. Controller Synthesis 13
9. Controller Implementation 15
10. Binary Decision Diagrams 16
1
2 MATTHIAS RUNGGER MARCH 29, 2017
2. QUICKSTART
The best way to try SCOTS is to clone the source code from https://gitlab.lrz.de/matthias/
SCOTSv0.2 and run one of the examples. Each of the example directories contains a readme file that
provides some background information on the example itself and explains the compilation process.
Optionally, some examples contain an m-file for the simulation of the closed loop in MATLAB. See
http://www.mathworks.com for installation instructions.
2.1. Invariance and Reachability. The three most easy-to-compile examples are found in
./examples/dcdc /* invariance problem for a DCDC boost converter */
./examples/vehicle /* reach-avoid problem for a vehicle */
./examples/aircraft /* landing maneuver of an aircraft (requires 32GB memory) */
The examples can be run without any additional software and require only a C++ compiler with C++
11 support. See also the case studies in PART 3
2.2. Customized Synthesis. In the examples in
./examples/dcdc_bdd /* reach-and-stay spec for a DCDC boost converter */
./examples/vehicle_bdd /* currently reachability only (more complex spec is planned) */
we use customized controller synthesis algorithms to enforce more complex specifications. Customized
synthesis algorithms are supported only using binary decision diagrams (BDDs) as underlying data
structure. In order to run the examples, an installation of the CUDD library is required, see Section 3.1.
2.3. A Priori Enclosure and Growth Bound. The directory
./examples/aircraft/helper
contains various programs that use the interval-arithmetic based ODE solver vnode-lp to obtain: a)
an a priori enclosure and b) a growth bound.
SCOTS (0.2) – USER MANUAL 3
3. INSTALLATION NOTES
SCOTS is implemented in “header-only” style and only a working C++ developer environment with
C++ 11 support is needed. In the basic variant it is possible to
(1) compute abstractions
(2) synthesize controllers with respect to invariance and reachability specifications
(3) simulate the closed loop in C++
For various reasons, one might consider to use additional software in combination with SCOTS.
4.1. Control Problems. SCOTS supports the computation of controllers for nonlinear control systems
of the form
ξ̇(t) ∈ f (ξ(t), u) + J−w, wK (1)
where f is given by f : R × U → R and U ⊆ R . The vector w = [w1 , . . . , w n ] ∈
n n m
R+n
is a perturbation
bound and J−w, wK denotes the hyper-interval [−w1 , w1 ]×. . .×[−w n , w n ]. Given a time horizon τ > 0,
we define a solution of (1) on [0, τ] under (constant) input u ∈ U as an absolutely continuous function
ξ: [0, τ] → Rn that satisfies (1) for almost every (a.e.) t ∈ [0, τ].
The desired behavior of the closed loop is defined with respect to the τ-sampled behavior of the
continuous-time systems (1). To this end, the sampled behavior of (1) is casted as simple system (with
initial states)
S1 := (X 1 , X 1,0 , U1 , F1 ) (2)
n
with the state alphabet X 1 := R , the set of initial states, the input alphabet U1 := U and the transition
function F1 : X 1 × U1 ⇒ X 1 defined by
F1 (x, u) := {x 0 | ∃ξ is a solution of (1) on [0, τ] under u : ξ(0) = x ∧ ξ(τ) = x 0 }. (3)
A specification Σ1 for a simple system (2) is simply a set
(U1 × X 1 )[0;T [
[
Σ1 ⊆ (U1 × X 1 )∞ := (4)
T ∈Z≥0 ∪{∞}
of possibly finite and infinite input-state sequences. A simple system S1 together with a specification
Σ1 constitute an control problem (S1 , Σ1 ).
The solution of a control problem (S1 , Σ1 ) is a system C = (X c , X c,0 , Uc , Vc , Yc , Fc , H c ) which is feedback
composable with S1 , see [1, Def. III.3], and satisfies
B(C × S1 ) ⊆ Σ1 .
In this context C and C × S1 are usually referred to as controller, respectively, closed loop. The symbol
B(C × S1 ) denotes the behavior of the closed loop C × S1 , see [1, Def. V.1]. We say that a control
problem (S1 , Σ1 ) is solvable iff there exists a system C that solves (S1 , Σ1 ).
A block diagram of the feedback composition of a controller synthesized with SCOTS and the system
S1 is illustrated in Fig. 1.
In the context of Linear Temporal Logic, the sets A1 and Z1 are often identified with atomic propositions.
In this sense, SCOTS allows to define arbitrary sets as atomic propositions.
6 MATTHIAS RUNGGER MARCH 29, 2017
4.3. Auxiliary Control Problems. Given a simple system (2) representing the τ-sampled behavior
of (1) and a specification Σ1 for (2), the control problem (S1 , Σ1 ) is not solved directly, but an auxiliary,
finite control problem (S2 , Σ2 ) is used in the synthesis process. Here,
S2 = (X 2 , X 2,0 , U2 , F2 ) (5)
is referred to as symbolic model or (discrete) abstraction of S1 and Σ2 is an abstract specification.
The state alphabet of X 2 is a cover of X 1 and the input alphabet U2 is a subset of U1 . The set X 2
contains a subset X̄ 2 , representing the “real” quantizer symbols, while the remaining symbols X 2 r X̄ 2
are interpreted as “overflow” symbols. The set of real quantizer symbols X̄ 2 are given by congruent
hyper-rectangles aligned on a uniform grid
ηZn = {c ∈ Rn | ∃k∈Zn ∀i∈[1;n] ci = ki ηi } (6)
with grid parameter η ∈ (R+ r {0}) . The elements of ηZ are called grid points. The real quantizer
n n
symbols are further parameterized by two vectors a, b ∈ Rn representing the lower-left and upper-right
corners of the hyper-interval Ja, bK confining the set X̄ 2 :
X̄ 2 := {x 2 | ∃c∈(ηZn ∩Ja,bK) x 2 = c + J−η/2, η/2K}. (7)
The elements of the real quantizer symbols are also referred to as cells. Each cell x 2 = c + J−η/2, η/2K
is associated with a center c ∈ Rn (which is also a grid point c ∈ ηZn ) and a radius r ∈ R≥0
n
. The initial
state alphabet X 2,0 is defined by the cells that are needed to cover X 1,0 , i.e.,
X 2,0 := {x 2 ∈ X 2 | x 2 ∩ X 1,0 6= ∅}. (8)
SCOTS computes symbolic models that are related via feedback refinement relations with the plant.
A feedback refinement relation from S1 to S2 is a strict relation Q ⊆ X 1 × X 2 that satisfies for all (x 1 , x 2 ) ∈
Q and u ∈ U2 the conditions
(1) x 1 ∈ X 1,0 implies x 2 ∈ X 2,0
(2) F2 (x 2 , u) 6= ∅ implies F1 (x 1 , u) 6= ∅ and Q(F1 (x 1 , u)) ⊆ F2 (x 2 , u).
In SCOTS, the feedback refinement relation Q is given by the set-membership relation
Q := {(x 1 , x 2 ) | x 1 ∈ x 2 }. (9)
Given an invariance (reachability) specification Σ1 for (2) associated with Z1 , then an abstract spec-
ification associated with S1 , S2 and Q is given by the invariance (reachability) specification for S2 =
(X 2 , X 2,0 , U2 , F2 ) associated with
Z2 = {x 2 ∈ X 2 | x 2 ⊆ Z1 }. (10)
An abstract reach-avoid specification from A1 , Z1 for S2 follows by
A2 = {x 2 ∈ X 2 | x 2 ∩ A1 6= ∅} (11)
and Z2 as defined in (10). The algorithms to solve the control problems (S2 , Σ2 ) implemented in SCOTS
are outlined in Section 6.
4.4. Closed Loop. The main statement facilitating the use of an auxiliary control problem reads as
follows [1, Thm. VI.3]:
Consider two control problems (Si , Σi ), i ∈ {1, 2}. Suppose that Q is a feedback refinement relation
from S1 to S2 and Σ2 is an abstract specification of Σ1 . If C solves the control problem (S2 , Σ2 ), then C ◦Q
solves the control problem (S1 , Σ1 ).
The controller C ◦ Q for S1 is given by the serial composition of the quantizer Q : X 1 ⇒ X 2 with
the controller C. The closed loop resulting from a simple system Σ1 which represents the τ-sampled
behavior of (1) and a controller C ◦ Q is illustrated in Fig. 1. At each k ∈ Z≥0 sampling time τ > 0,
the plant state x 1 = ξ(kτ) is measured and fed to the quantizer Q, which is used to determine a cell
x 2 ∈ X 2 that contains x 1 ∈ x 2 . Then x 2 is fed to the controller C to pick the input u ∈ U2 ⊆ U1 which
is applied to (1).
Additionally to the perturbations on the right-hand-side of (1), it is possible to account for measure-
ment errors modeled by a set-valued map P : Rn ⇒ Rn given by
P(x) := x + J−z, z K with z ∈ R+n . (12)
SCOTS (0.2) – USER MANUAL 7
τ
ξ̇(t) ∈ f (ξ(t), u) + J−w, wK x1
ZOH Q
u x1 ∈ x2
C
Please see [1, Sec. VI.B] and [3] for some background theory. The closed loop with measurement errors
is illustrated in Fig. 2.
τ x1
ξ̇ ∈ f (ξ, u) + J−w, wK P
x 10
ZOH
Q
u x 10 ∈ x 2
C
FIGURE 2. Closed loop with measurement errors modeled by the set-valued map x 10 ∈ P(x 1 ).
5.2. The Transition Function. Recall that the state alphabet X 2 of the symbolic model (5) is composed
of the real quantizer symbols X̄ 2 , which are cells aligned on a uniform grid, and the overflow symbols
X 2 r X̄ 2 . For x 2 ∈ X 2 r X̄ 2 the transition function is defined for all u ∈ U2 by
F2 (x 2 , u) := ∅. (16)
which is an over-approximation of the attainable set of (1) with respect to the set c + J−η/2, η/2K and
input u. If P is not covered by the real quantizer symbols, i.e., R 6⊆ ∪ x 2 ∈X̄ 2 x 2 , then we define
F2 (x 2 , u) := ∅. (18)
x 20 ∈ F2 (x 2 , u) : ⇐⇒ x 20 ∩ R 6= ∅. (19)
Using similar arguments as in [1, Thm. VIII.4], it is straightforward to show that Q is a feedback
refinement relation from S1 to S2 . Note that F2 satisfies
F2 (x 2 , u) ⊆ X̄ 2 . (20)
If we need to be robust against measurement errors P(x) = x + J−z, z K, we slightly modify the
computation of R to
x 20 ∈ F2 (x 2 , u) : ⇐⇒ (x 20 + J−z, z K) ∩ R 6= ∅. (22)
As a result we obtain that Q ◦ P is a feedback refinement relation from S1 to S2 , see [4, Thm. III.5],
which enables the correct controller refinement under measurement errors [1, Sec. VI.B]. The use of
n
the perturbation parameter z ∈ R>0 in SCOTS is explained in detail in Section 7.
In the implementation of the computation of F2 in Abstraction.hh, we use a numerical ODE
solver to compute an approximation of ϕ(τ, c, u) as well as β(η/2, u).
6. CONTROLLER SYNTHESIS
In this section, we discuss the algorithms that are implemented in SCOTS to solve synthesis problems
for the finite symbolic model (5). Usually, synthesis algorithms are developed in the context of two-
player games on graphs. The player associated with the controller tries to enforce the specification
while the player associated with disturbances tries to violate the specification, e.g. [5].
Given a control problem (S2 , Σ2 ) with S2 given in (5), the construction of a controller to enforce a
specification Σ2 proceeds in two steps. First, a subset Y∞ of the state alphabet X 2 is computed, which
characterizes the largest set of initial states so that the control problem is solvable, i.e., (S2 , Σ2 ) is
solvable if and only if X 2,0 ⊆ Y∞ . The set Y∞ is referred to as winning domain (or set of winning states)
associated with (S2 , Σ2 ). In a second step, the controller C is derived form the set Y∞ and some other
information available in synthesis algorithm.
We use the following notation. The set of admissible inputs at x 2 ∈ X 2 is denoted by
We use the Weierstrass symbol ℘ to denote the power set and define pre : ℘(X 2 ) → ℘(X 2 ) by
6.1. Invariance. Let Σ2 be an invariance specification associated with Z2 . We use Alg. 1, which is
implemented in the function solve_invariance_game in the file GameSolver.hh, to synthesize a
controller that solves the control problem (S2 , Σ2 ). Alg. 1 runs in O(m) time, where m is the number
of transitions, i.e., the number of triples (x 2 , u, x 20 ) with x 20 ∈ F2 (x 2 , u), since each state is added to the
queue of bad states Q at most once.
Let D ⊆ X 2 × U2 be the set of state-input pairs computed in Alg. 1. One can show that D−1 (U2 ) is
the maximal fixed point of the map G : ℘(X 2 ) → ℘(X 2 ) defined by
G(Y ) := Z2 ∩ pre(Y ). (25)
The maximal fixed point of (25) corresponds to the winning domain of (S2 , Σ2 ) and it follows that the
synthesis problem (S2 , Σ2 ) is solvable if and only if X 2,0 ⊆ D−1 (U2 ).
Suppose that X 2,0 ⊆ D−1 (U2 ) holds, then we obtain a controller C = ({q}, {q}, X 2 , X 2 , U2 , Fc , H c ) that
solves (S2 , Σ2 ) by
¨
D(x 2 ) × {x 2 } if x 2 ∈ D−1 (U2 )
H c (q, x 2 ) =
U2 × {x 2 } otherwise
¨ (26)
{q} if x 2 ∈ D (U2 )
−1
Fc (q, x 2 ) =
∅ otherwise.
The refined controller that solves (S1 , Σ1 ) is given by C ◦ Q. Note that the definition of the initial state
alphabet X 2,0 in (8) and the condition X 2,0 ⊆ D−1 (U2 ) imply that the initial state alphabet of S1 satisfies
X 1,0 ⊆ ∪ x 2 ∈D−1 (U2 ) x 2 . (27)
The controller C ◦ Q is implemented in SCOTS in the StaticController class. The details are
explained in Section 9.
Let D be the output of Alg. 2. The set D−1 (U2 ) is the minimal fixed point of the map G : ℘(X 2 ) →
℘(X 2 ) defined by
G(Y ) := Z2 ∪ pre(Y ). (28)
The minimal fixed point of (28) corresponds to the winning domain of (S2 , Σ2 ) and it follows that the
synthesis problem (S2 , Σ2 ) is solvable if and only if X 2,0 ⊆ D−1 (U2 ).
Given that X 2,0 ⊆ D−1 (U2 ) holds, a controller C = ({q}, {q}, X 2 , X 2 , U2 , Fc , H c ) that solves (S2 , Σ2 ) is
identical to the controller that solves the invariance problem, i.e., Fc and H c are given by (26).
Again, the refined controller C ◦ Q that is feedback composed with S1 is implemented in SCOTS in
the StaticController class. The details are explained in Section 9.
6.3. Reach-Avoid. Let Σ2 be a reach-avoid specification associated with A2 , Z2 ⊆ X̄ 2 . SCOTS provides
two alternatives to synthesize controllers to enforce reach-avoid specifications. In the first method, the
avoid set A2 is accounted for in the transition function, i.e.,
∀ x 2 ∈A2 : F2 (x 2 , u) := ∅. (29)
In this way we can reduce a reach-avoid problem to a reachability problem. Given that the transition
function satisfies (29), any controller that solves the control problem (S2 , Σ02 ), where Σ02 is the reach-
ability specification associated with Z2 , also solves the control problem (S2 , Σ2 ). In order to enforce
the equation (29) in the computation of the transition function F2 the user can optionally supply the
avoid set to the function Abstraction::compute_gb, see Section 7.
For the second method, the computation of the transition function is left unchanged, but Alg. 2 is
modified to account for the avoid set. To this end the condition in line 16 in Alg. 2 is modified to
F2 (x 2 , u) ⊆ E and V (x 2 ) > 1 + M (x 2 , u) and x 2 6∈ A2 . (30)
Again the user can optionally supply the avoid set to the function solve_reachability_game, see
Section 8.
SCOTS (0.2) – USER MANUAL 11
Part 2. USAGE
7. COMPUTATION OF SYMBOLIC MODELS
Let S1 be a simple system that represents the τ-sampled behavior of the continuous-time system (1)
as defined in (2). In order to compute the transition function F2 of a symbolic model (5) of S1 in
SCOTS, the following ingredients are needed.
(1) The solution ϕ(τ, x, u) of the IVP ξ̇ = f (ξ, u), ξ(0) = x at time τ, which is provided in terms
of a lambda expression of the form
[](state_type& x, const input_type& u) -> void {}
The state solution of the IVP at time τ, i.e., ϕ(τ, x, u) is expected to be stored in the vari-
able x. The state_type and input_type are aliases for std::array<double,dim> in the
appropriate dimension.
(2) A growth bound β(r, u), which is provided by a lambda expression of the form
[](state_type& r, const state_type& c, const input_type& u) -> void {}
Again, the value of the growth bound r 0 = β(r, u) is assumed to be stored in the variable r. In
the implementation, the growth bound is allowed to depend the center of the cell c. See [4]
for details.
(3) The set of real quantizer symbols X̄ 2 as defined in (7), which is defined as instantiation of the
class with constructor
template<class grid_point_t>
scots::UniformGrid(const int dim,
const grid_point_t& lb,
const grid_point_t& ub,
const grid_point_t& eta)
where the variables dim, lb, ub and eta represent the state space dimension, the lower and
upper bound of the hyper-interval confining the set X̄ 2 , and the grid parameter, respectively.
Internally, each cell x 2 = c + J−η/2, η/2K ∈ X̄ 2 is represented as an unsigned integer of
type abs_type. In the default setting, abs_type is an alias set in UniformGrid.hh to
using abs_type=std::uint32_t;
are useful in mapping an abstract state c + J−η/2, η/2K ∈ X̄ 2 , represented by its unsinged
integer ID id, to its center c ∈ Rn aligned on the uniform grid (6). Similarly, xtoi can be
used to map a state x ∈ Rn to the id of the cell x 2 ∈ X̄ 2 containing it, i.e., x ∈ x 2 .
(4) The input alphabet U2 , which is again represented by an instance of a UniformGrid.
(5) Optionally, it is possible to provide a measurement error bound to account for measurement
errors as defined in (12) using the member function
scots::Abstraction::set_measurement_error_bound(const state_type& z)
We demonstrate the usage of SCOTS to compute a symbolic model of the sampled dynamics of
an aircraft used in [1, Sec. IX.B]. The system consists of three states x 1 , x 2 , x 3 , which respectively
correspond to the velocity, the flight path angle and the altitude of the aircraft. The input alphabet
is given by U = 0, 160 · 10 × [0 , 10◦ ] and represents the thrust of the engines (in Newton) and
3 ◦
the angle of attack. Additionally, we use the disturbance vectors w = (0.108, 0.002, 0)> in (1) and
z = (0.0125, 0.0025◦ , 0.05)> in (12) to model possible input disturbances, respectively, measurement
errors.
12 MATTHIAS RUNGGER MARCH 29, 2017
For the computation of the transition function, we begin with the aliases for the state_type and
input_type by
const int state_dim=3; /* state space dim */
const int input_dim=2; /* input space dim */
using state_type = std::array<double,state_dim>;
using input_type = std::array<double,input_dim>;
Afterwards, we define the lambda for the solution of the IVP for a sampling time of τ = 0.25 by
auto aircraft_post = [](state_type &x, const input_type &u) {
/* the ode describing the aircraft */
auto rhs = [](state_type& xx, const state_type &x, const input_type &u) {
double mg = 60000.0*9.81;
double mi = 1.0/60000;
double c=(1.25+4.2*u[1]);
xx[0] = mi*(u[0]*std::cos(u[1])-(2.7+3.08*c*c)*x[0]*x[0]-mg*std::sin(x[1]));
xx[1] = (mi/x[0])*(u[0]*std::sin(u[1])+68.6*c*x[0]*x[0]-mg*std::cos(x[1]));
xx[2] = x[0]*std::sin(x[1]);
};
/* use 10 intermediate steps */
scots::runge_kutta_fixed4(rhs,x,u,state_dim,tau,10);
};
where we use the fixed step-size ODE solver scots::runge_kutta_fixed4 that ships with SCOTS.
An implementation that uses a more advanced ODE solver like the adaptive step-size solvers with error
control implemented in boost can be found in ./examples/aircraft_boost.
We continue with the definition of the growth bound, for which we determine the matrix L(u)
in (14). First, we compute an a priori enclosure K 0 of (1) with respect to τ = 0.25, U 0 = U and the
hyper-interval P(K) where K = [58, 83]×[−3◦ , 0]×[0, 56] is the hyper-interval that confines the set of
real quantizer symbols. To this end, we employ the interval arithmetic based ODE solver implemented
in vnode-lp to obtain
K 0 = [57.55, 83.23] × [−4.29◦ , 1.22◦ ] × [−1.38, 56.28].
The implementation of the computation of the a priori enclosure can be found in the example directory
./examples/aircraft/helper/a_priori_enclosure. To obtain the matrix L(u), we maximize
the partial derivatives of f (·, u) over the set K 0 . The solution of the linear IVP ṙ(t) = L(u)r(t) + w,
r(0) = r0 , at time τ provides the growth bound (15) that we access through the lambda
auto radius_post = [](state_type &r, const state_type &, const input_type &u) {
/* the ode for the growth bound */
auto rhs =[](state_type& rr, const state_type &r, const input_type &) {
/* lipschitz matrix */
double L[3][2];
L[0][0]=-0.001919*(2.7+3.08*(1.25+4.2*u[1])*(1.25+4.2*u[1]));
L[0][1]=9.81;
L[1][0]=0.002933+0.004802*u[1];
L[1][1]=0.00361225;
L[2][0]=0.07483;
L[2][1]=83.22;
/* to account for input disturbances */
state_type w={{0.108,0.002,0}};
rr[0] = L[0][0]*r[0]+L[0][1]*r[1]+w[0];
rr[1] = L[1][0]*r[0]+L[1][1]*r[1]+w[1];
rr[2] = L[2][0]*r[0]+L[2][1]*r[1]+w[2];
};
/* use 10 intermediate steps */
scots::runge_kutta_fixed4(rhs,r,u,state_dim,tau,10);
};
SCOTS (0.2) – USER MANUAL 13
The real quantizer symbols X̄ 2 and the input alphabet U2 are introduced as instances of the class
UniformGrid by
state_type s_lb={{58,-3*M_PI/180,0}};
state_type s_ub={{83,0,56}};
state_type s_eta={{25.0/362,3*M_PI/180/66,56.0/334}};
scots::UniformGrid ss(state_dim,s_lb,s_ub,s_eta);
input_type i_lb={{0,0}};
input_type i_ub={{32000,8*M_PI/180}};
input_type i_eta={{32000,8.0/9.0*M_PI/180}};
scots::UniformGrid is(input_dim,i_lb,i_ub,i_eta);
The grid parameter s_eta for the real quantizer symbols X̄ 2 has been determined according to the
optimization procedure in [4].
For the computation of the symbolic transition function F2 we instantiate the class Abstraction
and set the measurement error bound to z
scots::Abstraction<state_type,input_type> abs(ss,is);
state_type z={{0.0125,0.0025/180*M_PI,0.05}};
abs.set_measurement_error_bound(z);
Note that, due to the numerical errors in the computation of the solution of the IVP ϕ(τ, x, u) it
is possible that the computed transition function F2 does not satisfies the requirements in Sectin 5.2.
Similarly, the computation of the growth bound β(r, u) might be erroneous. Therefore, it is crucial to
pick adequate ODE solver parameters to obtain high confidence in the correctness of the computation.
We list the runtimes of the computation of F2 for two different solvers for various parameters in
Table 7. The implementations can be found in the directories ./exampels/aircraft_boost and
./examples/aircraft.
8. CONTROLLER SYNTHESIS
Let Σ2 be an invariance or reachability specification associated with Z2 ⊆ X̄ 2 for (5). The algorithms
Alg. 1 and Alg. 2 to compute the winning domain D−1 (U2 ) associated with the control problem (S2 , Σ2 )
are implemented in the following functions.
(1) Alg. 1 is implemented solve_invariance_game with signature
template<class F>
WinningDomain solve_reachability_game(const TransitionFunction& tf, F& ap)
ap(abs_state) returns true if and only if the abstract state x 2 ∈ X̄ 2 , represented by the ID
abs_state, is an element of the safe set Z2 .
14 MATTHIAS RUNGGER MARCH 29, 2017
ap(abs_state) returns true if and only if the abstract state x 2 ∈ X̄ 2 , represented by the ID
abs_state, is an element of the safe set Z2 . Additionally, a lambda expression as above can
be supplemented to solve_reachability_game to define the avoid set A2 .
(3) Optionally, the IDs of the cells contained in the set Z2 together with the uniform grid informa-
tion can be stored to a file using the function
template<class F>
bool write_to_file(const UniformGrid& g, F& ap, const std::string& filename)
The grid points associated with the stored IDs are accessible from the MATLAB workspace
using the command
>> p = GridPoints(’filename’);
In order to use this MATLAB command, the mex-file GridPoints.mex needs to be compiled.
Please see the installation notes for details.
We illustrate the usage of those functions again by the aircraft example studied in the previous
section. Let (2) represent the τ-sampled behavior of the aircraft dynamics and consider the reachability
specification Σ1 for S1 associated with the set
Z1 := ([63, 75] × [−3◦ , 0◦ ] × [0, 2.5]) ∩ {x ∈ R3 |x 1 sin x 2 ≥ −0.91}.
Consider the system (5), the quantizer (9) and the perturbation map (12). As outlined in Section 4.3,
an abstract specification associated with S1 , S2 and Q◦ P 2 is a reachability specification for S2 associated
with Z2 , where Z2 is required to be a subset of {x 2 ∈ X 2 | P(x 2 ) ⊆ Z1 }. We represent Z2 as lambda
target as follows
/* define target set */
state_type t_lb = {{63,-3*M_PI/180,0}};
state_type t_ub = {{75,0,2.5}};
state_type c_lb;
state_type c_ub;
state_type x;
auto target = [&](const scots::abs_type abs_state) {
/* compute the center of cell associated with abs_state */
ss.itox(abs_state,x);
/* hyper-interval of the quantizer symbol with perturbation */
for(int i=0; i<state_dim; i++) {
c_lb[i] = x[i]-s_eta[i]/2.0-z[i];
c_ub[i] = x[i]+s_eta[i]/2.0+z[i];
}
if( t_lb[0]<=c_lb[0] && c_ub[0]<=t_ub[0] &&
t_lb[1]<=c_lb[1] && c_ub[1]<=t_ub[1] &&
t_lb[2]<=c_lb[2] && c_ub[2]<=t_ub[2]) {
if(-0.91<=(x[0]*std::sin(x[1])-
s_eta[0]/2.0-z[0]-(c_ub[0])*(s_eta[1]/2.0-z[1]))) {
return true;
}
}
return false;
2In the computation of the abstraction specification, we replace Q with Q ◦ P to account for the measurement errors, see [1,
Sec. VI.B].
SCOTS (0.2) – USER MANUAL 15
};
Once we have the lambda target representing the target set, we compute the winning domain of
(S2 , Σ2 ) by
WinningDomain win=solve_reachability_game(tf,target);
The number of states in the winning domain and the winning domain itself is obtainable by
abs_type domain = win.get_size();
std::vector<abs_type> domain = win.get_winning_domain();
It is possible to store the result as StaticController to a file. The syntax for storing the controller
to the file controller.scs is given by
write_to_file(StaticController(ss,is,std::move(win)),"controller");
For various reasons it might be helpful to visualize the target set. To this end, we write the IDs of the
grid points in the target set together with the uniform grid information to a file
write_to_file(ss,target,"target");
Subsequently, we access and plot the grid points in the MATLAB workspace by
>> p = GridPoints(’target’);
>> plot3(p(:,1),p(:,2),p(:,3),’.’);
9. CONTROLLER IMPLEMENTATION
Let C be the static controller defined in (26) that solves (S2 , Σ2 ). For the implementation of the
refined controller C ◦Q illustrated in Fig. 1 (or Fig. 2), SCOTS provides the class StaticController.
The class can be instantiated with two UniformGrids and a WinningDomain according to the con-
structor
scots::StaticController(const UniformGrid& state_grid,
const UniformGrid& input_grid,
WinningDomain&& winning_domain)
Alternatively, it is possible to instantiate the StaticController class with the default constructor
and subsequently read the content of the controller from file by
inline bool read_from_file(StaticController& sc, const std::string& filename)
To extract the control inputs associated with a state x ∈ X 1 SCOTS provides the member function
template<class state_type, class input_type>
std::vector<input_type> scots::StaticController::get_control(const state_type &x)
Internally, the mapping Q in Fig. 1 is implemented by the member function UniformGrid::xtoi,
which maps x to the ID abs_state of the nearest grid point c ∈ Rn . The cell that is associated with
that grid point c contains x, i.e., x ∈ c + J−η/2, η/2K. If x is not an element of the winning domain
∪ x 2 ∈D−1 (U2 ) x 2 , then Fc (q, Q(x)) = ∅ and no progress is possible. This is indicated by the error message
scots::StaticController: state <x> is out of winning domain: no progress possible.
For the aircraft example, we implemented a closed loop simulation in the file ./aircraft/simulate.cc.
We read the controller from file and simulate the system until the target is reached
/* read controller from file */
scots::StaticController con;
if(!read_from_file(con,"controller")) {
std::cout << "Could not read controller from controller.scs\n";
return 0;
}
/* initial state */
16 MATTHIAS RUNGGER MARCH 29, 2017
The inputs associated with a state x ∈ Rn and the center of cells in the winning domain D−1 (U2 ) are
accessed by
>> u = con.control(x);
>> Y = con.domain;
In order to be able to use those commands, you need to add the directory ./mfiles to your MATLAB
path. A demonstration of the usage of the StaticController from the MATLAB workspace can be
found in the various m-files in the example directories.
ξ̇3 = ξ1 sin ξ2
where D(u2 , x 1 ) = (2.7 + 3.08 · (1.25 + 4.2 · u2 )2 ) · x 12 , L(u2 , x 1 ) = (68.6 · (1.25 + 4.2 · u2 )) · x 12 and
mg = 60 · 103 · 9.81 account for the drag, lift and gravity, respectively [7]. The state variables x 1 ,
x 2 and x 3 correspond ot the
velocity, the flight path angle and the altitude of the aircraft. The input
alphabet is given by U = 0, 32 · 103 × [0◦ , 8◦ ] and represents the thrust of the engines (in Newton)
and the angle of attack. Following [1], we consider certain input disturbance, which we model in (1)
1
by w = (0.108, 0.002, 0)> and measurement errors of the form (12) with z = 20 (0.25, 0.05, 1)> .
The objective is to control the aircraft from a certain hight close to the ground. We cast this controller
problem as a reachability problem for which the target set is given by
Z1 := ([63, 75] × [−3◦ , 0◦ ] × [0, 2.5]) ∩ {x ∈ R3 | x 1 sin x 2 ≥ −0.91}.
For the computation of the symbolic model, we fix a sampling time of τ = 0.25 sec and restrict the
problem domain to Ja, bK with
a = (58, −3◦ , 0)> and b = (83, 0◦ , 56)>
and set η = (25.0/362, 3◦ /66, 56.0/334)> . The real quantizer symbols X̄ 2 are determined according
to (7). The set of inputs is given by the grid points U2 := µZ2 ∩ U with µ = (32 · 103 , (8/9)◦ )> . The
choice of discretization parameter leads to a successful solution of the reachability problem. The hight
of the controlled aircraft over time is illustrated in Fig. 3.
60
50
40
altitude
30
20
10
0
0 5 10 15 20
t [sec]
The configuration files for the computation in SCOTS can be found in ./examples/aircraft.
u1
δ
where α = arctan(tan(u2 )/2). The states (x 1 , x 2 ) and x 3 correspond to the position, respectively,
orientation of the vehicle in the 2-dimensional plane. The inputs are given by the velocity u1 ∈ [−1, 1]
and the rate u2 ∈ [−1, 1] of the steering angle δ.
The specification is illustrated in Fig. 5. The goal is to synthesize a controller that steers the vehicle
through the maze, without hitting the blue obstacles until the target set (red box) is reached. The
synthesis problem is casted as a reach-avoid problem.
10
0 2 4 6 8 10
For the computation of the symbolic model, we fix the sampling time to τ = 0.3 sec and limit the
problem domain to Ja, bK with
rl xl il s2
s1
rc
vs r0 v0
vc xc
The state of the system is given by x(t) = [il (t), vc (t)]> where il (t) and vc (t) denote the current
The boost converter has two operation modes depending on the position of the
through the inductor and the voltage across the capacitor at time t, respectively. The dynamical be-
switch. The state of the system is x(t) = [il (t) vc (t)]T where il (t) is the inductor
havior is described by the switched linear system
current and vc (t) the capacitor voltage. The dynamics associated with both
modes are affine of the followingẋ(t) = A g(t) x(t) + b
form
with Ai ∈ R2×2 , i ∈ [1; 2] and b given by
rl ẋ(t)
= Apx(t)1 + b, prc= 1, 2
r r0
− x l (rl + rc +r00 ) − x1l r0 +r
vs
− xl 0
with A1 = 0 , A2 = , b = xl .
c
1 r0
− x1c r0 +r
1
c x r +r − x
1
r
1
+r . 0
c 0 c c 0 c
rl 1
First, we synthesize
xl 0
a controller + rr00+r
(rl safety
to enforcexlthe
rc
specification
r0 rc
) x1l (rl + associated
r0 +rc ) with vxsl
A1 = 1 1 , A 2 = 1 r0
c
1 1 , b = .
0 xc r0 +rc Z1 := [1.15, 1.55]
xc r0 +r ×c [5.45, 5.85]. xc r0 +rc 0
In theItcomputation
is clear thatofthe
the boost
abstraction,
DC-DC weconverter
fix the sampling time to τof= switched
is an example 0.5 sec and pick a grid point
system.
distanceIn η = following,
of the (5·10−4 , 5·10 )
−4 >
. The winning domain together with a trajectory of
we use the numerical values from [13], that is, in the per unitthe closed loop is
illustrated
system xc = 70 p.u., xl = 3 p.u., rc = 0.005 p.u., rl = 0.05 p.u., r0 = 1 p.u. and the sparse
in Fig. 7. The implementation details are provided in ./examples/dcdc using
matrix representation.
vs = 1 p.u.. The goal of the boost DC-DC converter is to regulate the output
voltage across the load r0 . This control problem is usually reformulated as a
current reference5.85 scheme. Then, the goal is to keep the inductor current il (t)
5.45
FIGURE 7. The domain of the invariance controller together with a closed loop trajectory.
We continue with a demonstration on how to use the BDD representation together with the CUDD
Library to operate directly on the transition function and atomic propositions in order to create cus-
tomized synthesis algorithms. In particular, let us consider the reach-and-stay specification Σ1 associ-
ated with with Z1 ⊆ X 1 given by
Σ1 := (u, x) ∈ (U1 × X 1 )∞ | ∃ t∈[0;∞[ ∀ t 0 ∈[t;∞[ : x(t 0 ) ∈ Z1 .
The associated abstract specification Σ2 for the symbolic model S2 is given by the reach-and-stay spec-
ification associated with
Z2 := {x 2 ∈ X 2 | x 2 ⊆ Z1 }.
20 MATTHIAS RUNGGER MARCH 29, 2017
We can solve the control problem (S2 , Σ2 ) by the nested fixed point algorithm
µȲ .νY.(pre(Y ) ∩ Z2 ) ∪ pre(Ȳ ).
We implemented the fixed point computation in ./examples/bdd/dcdc_bdd by using the enforcible
predecessor computed in the class scots::Enf_Pre according to
/* set up enf_pre computation */
scots::EnfPre enf_pre(manager,TF,sym_model);
/* outer fp*/
BDD Z=manager.bddOne();
BDD ZZ=manager.bddZero();
/* inner fp*/
BDD Y=manager.bddZero();
BDD YY=manager.bddOne();
/* the controller */
BDD C=manager.bddZero();
/* helper */
BDD U=ss_input.get_cube(manager);
/* as long as not converged */
for(size_t i=1; ZZ != Z; i++) {
Z=ZZ;
BDD preZ=enf_pre(Z);
/* init inner fp */
YY = manager.bddOne();
for(size_t j=1; YY != Y; j++) {
Y=YY;
YY = ( enf_pre(Y) & S ) | preZ;
}
ZZ=YY;
/* only add (state/input) pairs whose state is not already in the * controller */
BDD N = ZZ & (!(C.ExistAbstract(U)));
C=C | N;
}
The resulting controller is stored in the BDD C. A closed loop trajectory of the system is illustrated
in Fig. 8. The trajectory is obtained by running the MATLAB file dcdc.m in the example directory
./examples/bdd/dcdc_bdd.
5.8
5.6
5.4
5.2
FIGURE 8. Closed loop trajectory of the DC-DC boost converter satisfying the reach-
and-stay specification associated with the red rectangle.
REFERENCES 21
REFERENCES
[1] G. Reißig, A. Weber, and M. Rungger. “Feedback Refinement Relations for the Synthesis of Sym-
bolic Controllers”. In: IEEE Transactions on Automatic Control (2015). DOI: 10.1109/TAC.
2016.2593947.
[2] R. Ehlers and V. Raman. “Slugs: extensible GR(1) synthesis”. In: International Conference on
Computer Aided Verification. Springer. 2016, pp. 333–339.
[3] M. Rungger and M. Zamani. “SCOTS: A Tool for the Synthesis of Symbolic Controllers”. In:
HSCC. ACM, 2016.
[4] A. Weber, M. Rungger, and G. Reissig. “Optimized State Space Grids for Abstractions”. In: IEEE
Transactions on Automatic Control (2017). DOI: 10.1109/TAC.2016.2642794.
[5] R. Bloem et al. “Synthesis of reactive (1) designs”. In: Journal of Computer and System Sciences
78.3 (2012), pp. 911–938.
[6] G. Gallo et al. “Directed hypergraphs and applications”. In: Discrete Applied Mathematics 42
(1993), pp. 177–201.
[7] I. Mitchell, A. M. Bayen, and C. J. Tomlin. “Validating a Hamilton-Jacobi Approximation to
Hybrid System Reachable Sets”. In: Proc. 4th Intl. Conf. on Hybrid Systems: Computation and
Control. Springer, 2001, pp. 418–432.
[8] K. J. Aström and R. M. Murray. Feedback systems: an introduction for scientists and engineers.
Princeton University Press, 2010.
[9] A. Girard, G. Pola, and P. Tabuada. “Approximately bisimilar symbolic models for incrementally
stable switched systems”. In: IEEE TAC 55.1 (2010), pp. 116–126.
[10] A. Girard. “Controller synthesis for safety and reachability via approximate bisimulation”. In:
Automatica 48.5 (2012), pp. 947–953.
[11] G. Reißig and M. Rungger. “Abstraction-based Solution of Optimal Stopping Problems under
Uncertainty”. In: Proc. of the 52nd IEEE Conf. on Decision and Control. 2013, pp. 3190–3196.
DOI : 10.1109/CDC.2013.6760370.