diff --git a/docs/src/lib/systems.md b/docs/src/lib/systems.md index ca9eebf18a..36959e8537 100644 --- a/docs/src/lib/systems.md +++ b/docs/src/lib/systems.md @@ -24,7 +24,7 @@ normalize(::InitialValueProblem) ReachabilityAnalysis.add_dimension ``` -## Homogeneization +## Homogenization ```@docs homogenize diff --git a/docs/src/man/systems.md b/docs/src/man/systems.md index 23498e040b..c7acf608c1 100644 --- a/docs/src/man/systems.md +++ b/docs/src/man/systems.md @@ -74,7 +74,7 @@ in `MathematicalSystems.jl` for additional details in second order ODEs types. ## Normalization -## Homogeneization +## Homogenization ## Nonlinear systems diff --git a/src/Continuous/homogeneization.jl b/src/Continuous/homogenization.jl similarity index 74% rename from src/Continuous/homogeneization.jl rename to src/Continuous/homogenization.jl index 7c76e30cba..6a63f63817 100644 --- a/src/Continuous/homogeneization.jl +++ b/src/Continuous/homogenization.jl @@ -1,15 +1,18 @@ # ==================================================== -# Homogeneization of linear systems +# Homogenization of linear systems # ==================================================== +using ..DiscretizationModule: next_set + # no-op homogenize(ivp::IVP{LCS{N,MT},ST}) where {N,MT<:AbstractMatrix{N},ST} = ivp homogenize(sys::LCS{N,MT}) where {N,MT<:AbstractMatrix{N}} = sys """ - homogenize(ivp::IVP{CLCCS{N,MT,IdentityMultiple{N},XT,ConstantInput{SI}},ST}) where {N, MT<:AbstractMatrix{N}, XT<:LazySet{N}, SI<:Singleton{N}, ST<:LazySet{N}} + homogenize(ivp::IVP{<:CLCCS{N,MTA,MTB,XT,UT},ST}) where {N, MTA<:AbstractMatrix{N}, + MTB<:IdentityMultiple{N}, XT<:LazySet{N}, UT<:ConstantInput{<:Singleton{N}}, ST<:LazySet{N}} -Transform an inhomogeneous linear initial-value problem into an homogeneous one +Transform an inhomogeneous linear initial-value problem into a homogeneous one by introducing auxiliary state variables. ### Input @@ -23,25 +26,30 @@ Homogeneous initial-value problem. ### Notes This function transforms the canonical initial-value problem ``x' = Ax + u``, -``x ∈ X`` with ``u(0) ∈ U = {u}`` (a singleton) into an homogeneous problem +``x ∈ X`` with ``u(0) ∈ U = {u}`` (a singleton) into a homogeneous problem without inputs ``y' = Â * y``, ``y ∈ Y``. """ -function homogenize(ivp::IVP{CLCCS{N,MT,IdentityMultiple{N},XT,ConstantInput{SI}},ST}) where {N, - MT<:AbstractMatrix{N}, - XT<:LazySet{N}, - SI<:Singleton{N}, - ST<:LazySet{N}} +function homogenize(ivp::IVP{<:CLCCS{N,MTA,MTB,XT,UT},ST}) where {N, + MTA<:AbstractMatrix{N}, + MTB<:IdentityMultiple{N}, + XT<:LazySet{N}, + UT<:ConstantInput{<:Singleton{N}}, + ST<:LazySet{N}} # homogenized state matrix + B = input_matrix(ivp) + @assert isone(B.M.λ) "input matrix should be normalized" U = ReachabilityAnalysis.next_set(inputset(ivp)) A = state_matrix(ivp) Â = _homogenize_state_matrix(A, U) - # homogenized input set + # homogenized initial set X0 = initial_state(ivp) Y0 = _homogenize_initial_state(X0) + # homogenized state constraint X = stateset(ivp) Y = _homogenize_stateset(X) + ivph = IVP(CLCS(Â, Y), Y0) return ivph end @@ -49,7 +57,7 @@ end """ homogenize(sys::SOACS) -Transform an inhomogeneous second order system into an homogeneous one +Transform an inhomogeneous second order system into a homogeneous one by introducing auxiliary state variables. ### Input diff --git a/src/ReachabilityAnalysis.jl b/src/ReachabilityAnalysis.jl index 32020eb042..273d50f9e6 100644 --- a/src/ReachabilityAnalysis.jl +++ b/src/ReachabilityAnalysis.jl @@ -27,7 +27,7 @@ include("Flowpipes/solutions.jl") # =========================================================== include("Continuous/fields.jl") include("Continuous/normalization.jl") -include("Continuous/homogeneization.jl") +include("Continuous/homogenization.jl") include("Continuous/linearization.jl") # =========================================================== diff --git a/test/algorithms/BOX.jl b/test/algorithms/BOX.jl index 315d9e5071..13e216570a 100644 --- a/test/algorithms/BOX.jl +++ b/test/algorithms/BOX.jl @@ -6,7 +6,6 @@ # continuous algorithm sol = solve(ivp; tspan=tspan, alg=alg) @test isa(sol.alg, BOX) - @test setrep(sol) <: Hyperrectangle @test setrep(sol) == Hyperrectangle{Float64,Array{Float64,1},Array{Float64,1}} @test dim(sol) == 1 # discrete algorithm @@ -15,6 +14,18 @@ NSTEPS = 500 fp_d = ReachabilityAnalysis.post(alg, ivp_discr, NSTEPS) + # homogenization + A = hcat(state_matrix(ivp)) + X = stateset(ivp) + X0 = initial_state(ivp) + B = Id(1, 1.0) # TODO implement for different multiple + U = ConstantInput(Singleton([0.0])) + ivp2 = @ivp(ConstrainedLinearControlContinuousSystem(A, B, X, U), X(0) ∈ X0) + sol2 = solve(ivp2; tspan=(0.0, 1.0), alg=alg, homogenize=true) + @test isa(sol2.alg, BOX) + @test setrep(sol2) == Hyperrectangle{Float64,Array{Float64,1},Array{Float64,1}} + @test dim(sol2) == 2 + # higher-dimensional homogeneous ivp, tspan = linear5D_homog() sol = solve(ivp; tspan=tspan, alg=BOX(; δ=0.01))