From 35356292ec35b69572dbbe539518579c7716d099 Mon Sep 17 00:00:00 2001 From: schillic Date: Wed, 7 Feb 2024 22:47:53 +0100 Subject: [PATCH 1/4] fix doctests --- docs/Project.toml | 2 ++ src/Continuous/normalization.jl | 34 ++++++++++++---------- src/Discretization/DiscretizationModule.jl | 6 +++- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index 7b3e1217af..90d78c442d 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -8,6 +8,7 @@ JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043" Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" +MathematicalSystems = "d14a8603-c872-5ed3-9ece-53e0e82e39da" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" @@ -21,5 +22,6 @@ JLD2 = "0.4" LaTeXStrings = "1" LazySets = "2" Literate = "2" +MathematicalSystems = "0.11 - 0.13" Plots = "1" Symbolics = "5" diff --git a/src/Continuous/normalization.jl b/src/Continuous/normalization.jl index a33a451dd2..796e14f35a 100644 --- a/src/Continuous/normalization.jl +++ b/src/Continuous/normalization.jl @@ -57,12 +57,12 @@ Append one or more zero rows and columns to a matrix. ```jldoctest add_dimension_test julia> A = [0.4 0.25; 0.46 -0.67] -2×2 Array{Float64,2}: +2×2 Matrix{Float64}: 0.4 0.25 0.46 -0.67 -julia> add_dimension(A) -3×3 Array{Float64,2}: +julia> ReachabilityAnalysis.add_dimension(A) +3×3 Matrix{Float64}: 0.4 0.25 0.0 0.46 -0.67 0.0 0.0 0.0 0.0 @@ -70,8 +70,8 @@ julia> add_dimension(A) To append more than one zero row-column, use the second argument `m`: ```jldoctest add_dimension_test -julia> add_dimension(A, 2) -4×4 Array{Float64,2}: +julia> ReachabilityAnalysis.add_dimension(A, 2) +4×4 Matrix{Float64}: 0.4 0.25 0.0 0.0 0.46 -0.67 0.0 0.0 0.0 0.0 0.0 0.0 @@ -101,14 +101,14 @@ julia> X = BallInf(ones(9), 0.5); julia> dim(X) 9 -julia> Xext = add_dimension(X); +julia> Xext = ReachabilityAnalysis.add_dimension(X); julia> dim(Xext) 10 julia> X = ZeroSet(4); -julia> dim(add_dimension(X)) +julia> dim(ReachabilityAnalysis.add_dimension(X)) 5 julia> typeof(X) @@ -118,7 +118,7 @@ ZeroSet{Float64} More than one dimension can be added passing the second argument: ```jldoctest add_dimension_set -julia> Xext = add_dimension(BallInf(zeros(10), 0.1), 4); +julia> Xext = ReachabilityAnalysis.add_dimension(BallInf(zeros(10), 0.1), 4); julia> dim(Xext) 14 @@ -158,7 +158,7 @@ julia> X0 = BallInf(zeros(3), 1.0); julia> s = InitialValueProblem(LinearContinuousSystem(A), X0); -julia> sext = add_dimension(s); +julia> sext = ReachabilityAnalysis.add_dimension(s); julia> statedim(sext) 4 @@ -167,16 +167,18 @@ julia> statedim(sext) If there is an input set, it is also extended: ```jldoctest add_dimension_cont_sys +julia> using LinearAlgebra + julia> U = ConstantInput(Ball2(ones(3), 0.1)); julia> s = InitialValueProblem(ConstrainedLinearControlContinuousSystem(A, Matrix(1.0I, size(A)), nothing, U), X0); -julia> sext = add_dimension(s); +julia> sext = ReachabilityAnalysis.add_dimension(s); julia> statedim(sext) 4 -julia> dim(next_set(inputset(sext))) +julia> dim(ReachabilityAnalysis.next_set(inputset(sext))) 4 ``` @@ -189,24 +191,24 @@ julia> U = VaryingInput([Ball2(ones(3), 0.1 * i) for i in 1:3]); julia> s = InitialValueProblem(ConstrainedLinearControlContinuousSystem(A, Matrix(1.0I, size(A)), nothing, U), X0); -julia> sext = add_dimension(s); +julia> sext = ReachabilityAnalysis.add_dimension(s); julia> statedim(sext) 4 -julia> dim(next_set(inputset(sext), 1)) +julia> dim(ReachabilityAnalysis.next_set(inputset(sext), 1)) 4 ``` Extending a varying input set with more than one extra dimension: -1] normalize(::AffineContinuousSystem{Float64,Array{Float64,2},Array{Float64,1}}) at /home/mforets/.julia/dev/ReachabilityAnalysis/src/Continuous/normalization.jl:387 + ```jldoctest add_dimension_cont_sys -julia> sext = add_dimension(s, 7); +julia> sext = ReachabilityAnalysis.add_dimension(s, 7); julia> statedim(sext) 10 -julia> dim(next_set(inputset(sext), 1)) +julia> dim(ReachabilityAnalysis.next_set(inputset(sext), 1)) 10 ``` """ diff --git a/src/Discretization/DiscretizationModule.jl b/src/Discretization/DiscretizationModule.jl index f8e7b414b7..87db94e359 100644 --- a/src/Discretization/DiscretizationModule.jl +++ b/src/Discretization/DiscretizationModule.jl @@ -70,11 +70,15 @@ in the docstring of each method. Here is a list of all the available approximati ```jldoctest julia> subtypes(ReachabilityAnalysis.AbstractApproximationModel) -5-element Vector{Any}: +9-element Vector{Any}: Backward CorrectionHull + FirstOrder + FirstOrderZonotope Forward + ForwardBackward NoBloating + SecondOrderddt StepIntersect ``` From 43ff50fb7373eab8c30c18cbca8f934cd8ad522e Mon Sep 17 00:00:00 2001 From: schillic Date: Wed, 7 Feb 2024 22:51:02 +0100 Subject: [PATCH 2/4] fix add_dimension without inputs --- src/Continuous/normalization.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Continuous/normalization.jl b/src/Continuous/normalization.jl index 796e14f35a..a79f9e1c5f 100644 --- a/src/Continuous/normalization.jl +++ b/src/Continuous/normalization.jl @@ -215,7 +215,7 @@ julia> dim(ReachabilityAnalysis.next_set(inputset(sext), 1)) function add_dimension(cs, m=1) Aext = add_dimension(cs.s.A, m) X0ext = add_dimension(cs.x0, m) - if hasmethod(inputset, Tuple{typeof(cs.s)}) + if !isnothing(inputset(cs)) Uext = map(x -> add_dimension(x, m), inputset(cs)) s = CLCCS(Aext, Matrix(1.0I, size(Aext)), nothing, Uext) else From 6f29b3967544f99ce4ed4743256a3c2e36596785 Mon Sep 17 00:00:00 2001 From: schillic Date: Wed, 7 Feb 2024 22:53:17 +0100 Subject: [PATCH 3/4] make add_dimension interface and docs consistent --- src/Continuous/normalization.jl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Continuous/normalization.jl b/src/Continuous/normalization.jl index a79f9e1c5f..4a3fdf592e 100644 --- a/src/Continuous/normalization.jl +++ b/src/Continuous/normalization.jl @@ -138,14 +138,14 @@ function add_dimension(X::ZeroSet, m=1) end """ - add_dimension(cs, m=1) + add_dimension(ivp::IVP, m=1) -Adds an extra dimension to a continuous system. +Adds an extra dimension to a initial-value system. ### Input -- `cs` -- continuous system -- `m` -- (optional, default: `1`) the number of extra dimensions +- `ivp` -- initial-value system +- `m` -- (optional, default: `1`) the number of extra dimensions ### Examples @@ -212,11 +212,11 @@ julia> dim(ReachabilityAnalysis.next_set(inputset(sext), 1)) 10 ``` """ -function add_dimension(cs, m=1) - Aext = add_dimension(cs.s.A, m) - X0ext = add_dimension(cs.x0, m) - if !isnothing(inputset(cs)) - Uext = map(x -> add_dimension(x, m), inputset(cs)) +function add_dimension(ivp::IVP, m=1) # only correct for linear systems + Aext = add_dimension(ivp.s.A, m) + X0ext = add_dimension(ivp.x0, m) + if !isnothing(inputset(ivp)) + Uext = map(x -> add_dimension(x, m), inputset(ivp)) s = CLCCS(Aext, Matrix(1.0I, size(Aext)), nothing, Uext) else s = LCS(Aext) From cf3184c5a77638f1d93247b6e54066cc278919b5 Mon Sep 17 00:00:00 2001 From: schillic Date: Wed, 7 Feb 2024 22:58:10 +0100 Subject: [PATCH 4/4] activate doctests --- docs/make.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/make.jl b/docs/make.jl index 26a28af629..da0aa68fd4 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -118,7 +118,7 @@ makedocs(; assets=["assets/aligned.css"]), sitename="ReachabilityAnalysis.jl", modules=[ReachabilityAnalysis], - doctest=false, + #doctest=false, pagesonly=true, pages=["Overview" => "index.md", "Tutorials" => vcat(SET_REPRESENTATIONS,