Utils
Foundational helpers built on LazySets: Dionysos sets are LazySets (a box is a Hyperrectangle via UT.box, an ellipsoid a LazySets.Ellipsoid), plus what LazySets lacks for symbolic control — callable cost functions, exact ellipsoid predicates (is_included / is_disjoint), periodic splitting, data structures, RRT search, and scalar optimization. The PathCompleteFramework submodule provides path-complete Lyapunov functions.
API reference
Dionysos.Utils.BlackBoxControlFunction — Type
BlackBoxControlFunction{F}Arbitrary user-supplied state-input function f(x, u); same freedom and serialization caveat as BlackBoxFunction.
Dionysos.Utils.BlackBoxFunction — Type
BlackBoxFunction{F}Arbitrary user-supplied state function f(x), in the spirit of MathematicalSystems' BlackBox maps: full modeling freedom, but unlike the structured functions it does not serialize reliably (closures, e.g. to JLD2).
Dionysos.Utils.Box — Type
Box{N, T}Concrete alias of LazySets.Hyperrectangle backed by SVectors, for struct fields and container element types.
Dionysos.Utils.NodeT — Type
NodeT{S, A}A node of a Tree: a state of type S, the action of type A that reached it from its parent (nothing for the root), and the cost bookkeeping used by RRT/RRT*.
A defaults to Any (the action type is generally only known lazily while the tree grows); instantiate Tree{S, A} with a concrete A when the action type is known up front.
Dionysos.Utils.PolyhedralFunction — Type
Piecewise-affine convex function x ↦ max(lower_bound, maxᵢ pieceᵢ(x)) on domain (∞ outside).
Dionysos.Utils.QuadraticFunction — Type
Quadratic form x ↦ x'Qx.
Dionysos.Utils.QuadraticStateControlFunction — Type
QuadraticStateControlFunction{T, MT<:AbstractMatrix{T}}Quadratic function on state and input defined as x'Qx + u'Ru + 2x'Nu + 2x'q + 2u'r + v
Dionysos.Utils.ScalarControlFunction — Type
Root of state-input functions f(x, u).
Dionysos.Utils.ScalarFunction — Type
Root of state functions f(x).
Dionysos.Utils.SemiLinearSet — Type
SemiLinearSet{T, PT}A finite union of polytopes: alias of LazySets.UnionSetArray restricted to HPolytope parts, so the whole LazySets API (∈, isempty, dim, intersection, plotting) applies. Build with semilinear_set; the parts live in S.array.
Dionysos.Utils.Tree — Type
Tree{S, A}A rooted tree of NodeT{S, A} nodes, tracking its leaves and node count. Built incrementally by add_node!; the search backbone of the RRT-based abstractions.
Dionysos.Utils.RRT — Method
Basic generic RRT algorihtm
SI : initial state (this will be the root of the tree) ;
SF : target state that we try to reach ;
distance : function that defines a metric between the states ;
rand_state : function that returns a random candidate state ;
new_conf : function that returns a reachable state, with the action and the cost ;
keep : function to filter the node that we want to add during an iteration;
stop_crit : stop criteria ;
RRTstar : boolean to use RRT* ;
compute_transition : to compute transition between to given state (if RRTstar is true).Dionysos.Utils.add_node! — Method
add_node!(tree, state, parent, action, cost; path_cost = parent.path_cost + cost)Create a node for state, attach it to parent with the action and edge cost that reached it, and register it as a leaf of tree. Returns the new node.
Dionysos.Utils.box — Method
box(lb, ub) -> LazySets.HyperrectangleThe axis-aligned box {x : lb ≤ x ≤ ub}. Errors if lb ≰ ub componentwise.
Dionysos.Utils.derivative_bisection — Method
derivative_bisection(f, df, ddf; interval, δ, verbose, stopIfNegative) -> (f(x⋆), x⋆)Minimize a convex f by bisecting on the sign of f′: the sub-interval is halved toward where the derivative changes sign. ddf supplies the local curvature bound used by the stopIfNegative early exit.
Dionysos.Utils.get_length_semiaxis — Method
Semi-axis lengths √λᵢ(Q) of the ellipsoid, longest first.
Dionysos.Utils.get_quadratic_form — Method
get_quadratic_form(E::LazySets.Ellipsoid)Quadratic-form matrix P = Q⁻¹ of the ellipsoid, i.e. the matrix such that E = {x : (x − c)ᵀ P (x − c) ≤ 1}.
Dionysos.Utils.get_sublevel_set — Method
Sublevel-set scaling {x : (x−c)ᵀP(x−c) ≤ α}, i.e. Q ← α·Q.
Dionysos.Utils.golden_section_search — Method
golden_section_search(f; interval, δ, verbose, stopIfNegative) -> (f(x⋆), x⋆)Golden-section search for the minimum of a unimodal f on interval. Derivative free; brackets the minimum by keeping the golden ratio between four probe points.
Dionysos.Utils.invert_incl_mode — Method
Inclusion mode to use for the hole B when discretizing A \ B (soundness inverts it).
Dionysos.Utils.is_disjoint — Method
is_disjoint(X, Y) -> BoolWhether X ∩ Y = ∅. Generic sets delegate to LazySets; an exact analytic kernel runs for two LazySets.Ellipsoids (see sets/ellipsoid_intersection.jl).
Dionysos.Utils.is_included — Method
is_included(X, Y) -> BoolWhether X ⊆ Y. Generic sets delegate to LazySets; an exact analytic kernel runs for two LazySets.Ellipsoids (see sets/ellipsoid_inclusion.jl) — Dionysos owns this verb because extending Base.issubset on two LazySets-owned types would be piracy.
Dionysos.Utils.minus_hole — Method
Hole B of A \ B.
Dionysos.Utils.minus_included — Method
Included region A of A \ B.
Dionysos.Utils.newton_method — Method
newton_method(f, df, ddf; interval, x0, ϵ, verbose, stopIfNegative) -> (f(x⋆), x⋆)Newton's method for a stationary point of f, iterating x -= f′(x)/f″(x) until |f′(x)| ≤ ϵ or x leaves interval; the result is projected back onto interval.
Dionysos.Utils.project_set — Method
Project S onto the coordinates dims (identity when dims covers S).
Dionysos.Utils.sample — Method
Sample a point of X uniformly (LazySets rejection sampling).
Dionysos.Utils.samples — Method
Sample N points of X uniformly (LazySets rejection sampling); pass rng for reproducibility.
Dionysos.Utils.semilinear_set — Method
semilinear_set(parts) -> SemiLinearSetThe union of the given polyhedral sets, each converted to HPolytope.
Dionysos.Utils.set_in_period — Method
set_in_period(rect, periodic_dims, periods, start) -> LazySets.UnionSetArraySplit rect along periodic boundaries and return the union of the wrapped boxes.
Dionysos.Utils.set_minus — Method
set_minus(A, B) -> LazySets.IntersectionThe set difference A \ B, represented lazily as A ∩ Bᶜ.
Dionysos.Utils.set_union — Method
set_union(sets) -> LazySets.UnionSetArrayLazy union ⋃ᵢ setsᵢ of the given (Dionysos or LazySets) sets.
Dionysos.Utils.wrap_coord — Method
wrap_coord(x::SVector{N, T}, periodic_dims::SVector{P, Int}, periods::SVector{P, T}; start = zeros(SVector{P, T}))Wraps the vector x into a periodic domain along dimensions specified in periodic_dims, with period lengths periods and optional offset start.
Arguments
x: The coordinate vector to wrap.periodic_dims: Indices of the periodic dimensions.periods: Period lengths for the periodic dimensions.start(optional): Starting values of the periodic domains (defaults to0.0).
Returns
A wrapped SVector where each periodic dimension is mapped to the interval [start[i], start[i] + periods[i]).
Dionysos.Utils.wrap_value — Method
Wrap the scalar x into [start, start + period).
Path-Complete Framework
Dionysos.Utils.PathCompleteFramework.LabDigraph — Type
struct LabDigraph{T<:Real, U}Store a graph as an explicit list of edges (u, v, label), preserving parallel edges and arbitrary vertex types.
Dionysos.Utils.PathCompleteFramework.PCLF — Type
mutable struct PCLFStore a path-complete Lyapunov function (i.e. a graph and a collection of Lyapunov pieces) for a linear switched system and the corresponding JSR approximation
Dionysos.Utils.PathCompleteFramework.compute_polyhedral_pieces_pclf — Method
Compute a path-complete Lyapunov function (PCLF) with general polyhedral pieces defined over a partition of the state space into cones.
Each node s is associated with a piecewise-linear Lyapunov function:
V_s(x) = max_i |p_{s,i}ᵀ x|,where the rows of a matrix P_s define the supporting hyperplanes of the polytope.
Method
The method formulates a feasibility linear program (LP) based on:
Positivity constraints ensuring V_s(x) ≥ 0 on each cone
Dominance constraints ensuring correct piecewise structure
Decrease conditions along edges:
V_v(A_σ x) ≤ ρ V_u(x)
These constraints are enforced on the extreme rays of the cones in partitions.
A bisection on ρ is used to approximate the joint spectral radius (JSR).
Arguments
f: hybrid system containing the system matricesA_σD: labeled directed graph defining the PCLF structureoptimizer: JuMP optimizerpartitions: dictionary mapping each node to a list of cones (matrices of rays)
Keyword arguments
tol: tolerance for bisection on ρmaxiter: maximum number of iterationsMLF: if true, extracts the Lyapunov piecesverbose: enable solver outputmin_c: lower bound on auxiliary scalar variables
Returns
PCLF: structure containing the graph, Lyapunov pieces, and JSR approximation
Notes
- This method allows for more general polyhedral Lyapunov functions than the symmetric 2n-face construction.
- The number of faces depends on the number of rows of
P_s. - Less conservative but computationally more expensive.
- The quality depends on the chosen cone partition.
Dionysos.Utils.PathCompleteFramework.compute_quadratic_pieces_pclf — Method
Compute a path-complete Lyapunov function (PCLF) with quadratic (ellipsoidal) pieces for a switched linear system.
Each node s of the graph is associated with a quadratic Lyapunov function:
V_s(x) = xᵀ P_s x,where P_s is a symmetric positive definite matrix. The corresponding sublevel sets are ellipsoids.
Method
The method formulates a semidefinite feasibility problem (SDP) and performs a bisection on γ. For each edge (u → v, σ), it enforces the Lyapunov inequality:
A_σᵀ P_v A_σ ≤ γ² P_u,implemented via linear matrix inequalities (LMIs):
γ² P_u - A_σᵀ P_v A_σ - I ≽ 0.Additional constraints ensure positive definiteness and boundedness of the matrices P_s.
Arguments
f: hybrid system containing the system matricesA_σG: labeled directed graph defining the PCLF structureoptimizer: JuMP-compatible SDP solver
Keyword arguments
tol: tolerance for bisection on γmaxiter: maximum number of iterationsMLF: if true, extracts the Lyapunov matricesP_s
Returns
PCLF: structure containing the graph, Lyapunov pieces (ellipsoids), and JSR approximation
Notes
- This method searches for a quadratic (ellipsoidal) Lyapunov function on each node.
- It relies on semidefinite programming (SDP), which is more expensive than LP-based polyhedral methods but often less conservative.
- The resulting Lyapunov function is smooth and globally defined on each node.
Dionysos.Utils.PathCompleteFramework.compute_symmetric_2n_faces_polyhedral_pieces_pclf — Method
Compute a path-complete Lyapunov function (PCLF) with symmetric polyhedral pieces having 2n faces for a switched linear system.
Each node s of the graph is associated with a polyhedral Lyapunov function of the form:
V_s(x) = max_i |(G_s x)_i| / w_s[i]whose sublevel sets are polytopes:
{ x : -γ w_s ≤ G_s x ≤ γ w_s }.Method
The method constructs and solves a feasibility linear program (LP) using bisection on γ. For each edge (u → v, σ), it enforces:
|G_v A_σ G_u^{-1}| * w_u ≤ γ w_v,where the absolute value is taken elementwise.
Arguments
f: hybrid system containing the system matricesA_σD: labeled directed graph defining the PCLF structureoptimizer: JuMP optimizer
Keyword arguments
Gmats: choice of matrices G_s (identity, Dict, or Vector)tol: tolerance for bisection on γmaxiter: maximum number of bisection iterationsMLF: if true, extracts the Lyapunov piecesverbose: enable solver outputmin_w: lower bound to enforce strict positivity of w
Returns
PCLF: structure containing the graph, Lyapunov pieces, and JSR approximation
Notes
- The resulting Lyapunov functions are structured and correspond to weighted ∞-norms in transformed coordinates.
- This approach is computationally efficient but may be conservative.