JuliaReach / ReachabilityAnalysis.jl

Computing reachable states of dynamical systems in Julia
https://juliareach.github.io/ReachabilityAnalysis.jl/
MIT License
192 stars 16 forks source link

MethodError in gearbox model #483

Open mforets opened 3 years ago

mforets commented 3 years ago
include("/home/mforets/Projects/ARCH2021_AFF/models/Gearbox/gearbox.jl")

const boxdirs = BoxDirections{Float64, Vector{Float64}}(6);
const octdirs = CustomDirections([Vector(vi) for vi in OctDirections(6)]);

px, py, n, θ = 3, 4, 6, 0.628318530717959
vec1 = Vector(sparsevec([px, py], [tan(θ), 1.], n))
vec2 = Vector(sparsevec([px, py], [tan(θ), -1.], n))
const extdirs = vcat(collect(boxdirs), [vec1, vec2]) |> CustomDirections;

X0_GRBX01 = Hyperrectangle(low=[0, 0, -0.0168, 0.0029, 0, 0], high=[0, 0, -0.0166, 0.0031, 0, 0])
X0_GRBX01 = Hyperrectangle(low=[0, 0, -0.01675, 0.00285, 0, 0], high=[0, 0, -0.01665, 0.00315, 0, 0]);

sol = nothing

ivp = gearbox(X0=X0_GRBX01);

@time sol = solve(ivp, max_jumps=2,
                  clustering_method=LazyClustering(1), #, [1,1,2,2,1,1]),
                  intersect_source_invariant=true,
                  intersection_source_invariant_method=HRepIntersection(), # TemplateHullIntersection(extdirs),
                  intersection_method=HRepIntersection(), # TemplateHullIntersection(extdirs),
                  tspan = 0 .. 0.25,
                  alg=LGG09(δ=0.0001, template=extdirs));

@show req1(sol)
@show req2(sol)
MethodError: no method matching ReachSet(::Tuple{Bool, Vector{HalfSpace{Float64, Vector{Float64}}}}, ::IntervalArithmetic.Interval{Float64})
Closest candidates are:
  ReachSet(::ST, ::IntervalArithmetic.Interval{Float64}) where {N, ST<:LazySet{N}} at /home/mforets/.julia/dev/ReachabilityAnalysis/src/ReachSets/ReachSet.jl:25

Stacktrace:
 [1] solve(::InitialValueProblem{HybridSystem{LightAutomaton{LightGraphs.SimpleGraphs.SimpleDiGraph{Int64}, LightGraphs.SimpleGraphs.SimpleEdge{Int64}}, ConstrainedAffineContinuousSystem{Float64, Matrix{Float64}, Vector{Float64}, ST} where ST, ConstrainedLinearMap{Float64, Matrix{Float64}, ST} where ST, AutonomousSwitching, Vector{ConstrainedAffineContinuousSystem{Float64, Matrix{Float64}, Vector{Float64}, ST} where ST}, Vector{ConstrainedLinearMap{Float64, Matrix{Float64}, ST} where ST}, Vector{AutonomousSwitching}}, Vector{Tuple{Int64, Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}}}}; max_jumps::Int64, intersection_method::HRepIntersection, clustering_method::LazyClustering{Int64}, check_invariant_initial_states::Bool, intersect_invariant_initial_states::Bool, intersection_source_invariant_method::HRepIntersection, first_mode_representative::Bool, intersect_source_invariant::Bool, disjointness_method::FallbackDisjointness, fixpoint_check::Bool, WLtype::Type, kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:tspan, :alg), Tuple{IntervalArithmetic.Interval{Float64}, LGG09{Float64, Forward{ReachabilityAnalysis.BaseExpAlg, Val{:lazy}, Val{:concrete}, Val{false}, Nothing}, Vector{Float64}, CustomDirections{Float64, Vector{Float64}}, Val{false}, Missing}}}})
   @ ReachabilityAnalysis ~/.julia/dev/ReachabilityAnalysis/src/Hybrid/solve.jl:101
 [2] top-level scope
   @ ./timing.jl:210 [inlined]
 [3] top-level scope
   @ ./In[5]:0
 [4] eval
   @ ./boot.jl:360 [inlined]
 [5] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1094
dfcaporale commented 3 years ago

There are also problems with homogeneize and StepIntersect:

@time sol = solve(ivp, max_jumps=2,
                  clustering_method=LazyClustering(1), #, [1,1,2,2,1,1]),
                  intersect_source_invariant=true,
                  intersection_source_invariant_method=HRepIntersection(), # TemplateHullIntersection(extdirs),
                  intersection_method=HRepIntersection(), # TemplateHullIntersection(extdirs),
                  tspan = 0 .. 0.25,
                  alg=LGG09(δ=0.0001, template=extdirs),
                  homogeneize=true);
MethodError: no method matching reach_homog_LGG09!(::Vector{TemplateReachSet{Float64, Vector{Float64}, CustomDirections{Float64, Vector{Float64}}, SubArray{Float64, 1, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}}, ::CustomDirections{Float64, Vector{Float64}}, ::ConvexHull{Float64, CartesianProduct{Float64, HPolytope{Float64, Vector{Float64}}, Singleton{Float64, Vector{Float64}}}, MinkowskiSum{Float64, LinearMap{Float64, CartesianProduct{Float64, HPolytope{Float64, Vector{Float64}}, Singleton{Float64, Vector{Float64}}}, Float64, Matrix{Float64}}, Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}}}, ::Matrix{Float64}, ::Int64, ::Float64, ::CartesianProduct{Float64, HPolyhedron{Float64, SparseVector{Float64, Int64}}, Universe{Float64}}, ::IntervalArithmetic.Interval{Float64}, ::Val{true}, ::Val{false})
Closest candidates are:
  reach_homog_LGG09!(::Vector{RT}, ::TN, ::LazySet, ::AbstractMatrix{T} where T, ::Integer, ::N, ::Universe, ::IntervalArithmetic.Interval{Float64}, ::Any, ::Any) where {N, VN, TN, SN, RT<:TemplateReachSet{N, VN, TN, SN}} at C:\Users\danie\.julia\dev\ReachabilityAnalysis\src\Algorithms\LGG09\reach_homog.jl:6

Stacktrace:
 [1] post(alg::LGG09{Float64, Forward{ReachabilityAnalysis.BaseExpAlg, Val{:lazy}, Val{:concrete}, Val{false}, Nothing}, Vector{Float64}, CustomDirections{Float64, Vector{Float64}}, Val{false}, Missing}, ivp::InitialValueProblem{ConstrainedAffineContinuousSystem{Float64, Matrix{Float64}, Vector{Float64}, HPolyhedron{Float64, SparseVector{Float64, Int64}}}, HPolytope{Float64, Vector{Float64}}}, tspan::IntervalArithmetic.Interval{Float64}; Δt0::IntervalArithmetic.Interval{Float64}, kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:tspan, :alg, :homogeneize), Tuple{IntervalArithmetic.Interval{Float64}, LGG09{Float64, Forward{ReachabilityAnalysis.BaseExpAlg, Val{:lazy}, Val{:concrete}, Val{false}, Nothing}, Vector{Float64}, CustomDirections{Float64, Vector{Float64}}, Val{false}, Missing}, Bool}}})
   @ ReachabilityAnalysis ~\.julia\dev\ReachabilityAnalysis\src\Algorithms\LGG09\post.jl:50
 [2] solve(::InitialValueProblem{HybridSystem{LightAutomaton{LightGraphs.SimpleGraphs.SimpleDiGraph{Int64}, LightGraphs.SimpleGraphs.SimpleEdge{Int64}}, ConstrainedAffineContinuousSystem{Float64, Matrix{Float64}, Vector{Float64}, ST} where ST, ConstrainedLinearMap{Float64, Matrix{Float64}, ST} where ST, AutonomousSwitching, Vector{ConstrainedAffineContinuousSystem{Float64, Matrix{Float64}, Vector{Float64}, ST} where ST}, Vector{ConstrainedLinearMap{Float64, Matrix{Float64}, ST} where ST}, Vector{AutonomousSwitching}}, Vector{Tuple{Int64, Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}}}}; max_jumps::Int64, intersection_method::HRepIntersection, clustering_method::LazyClustering{Int64, Val{true}}, check_invariant_initial_states::Bool, intersect_invariant_initial_states::Bool, intersection_source_invariant_method::HRepIntersection, first_mode_representative::Bool, intersect_source_invariant::Bool, disjointness_method::FallbackDisjointness, fixpoint_check::Bool, WLtype::Type, kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:tspan, :alg, :homogeneize), Tuple{IntervalArithmetic.Interval{Float64}, LGG09{Float64, Forward{ReachabilityAnalysis.BaseExpAlg, Val{:lazy}, Val{:concrete}, Val{false}, Nothing}, Vector{Float64}, CustomDirections{Float64, Vector{Float64}}, Val{false}, Missing}, Bool}}})
   @ ReachabilityAnalysis ~\.julia\dev\ReachabilityAnalysis\src\Hybrid\solve.jl:78
 [3] top-level scope
   @ .\timing.jl:210 [inlined]
 [4] top-level scope
   @ .\In[69]:0
 [5] eval
   @ .\boot.jl:360 [inlined]
 [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base .\loading.jl:1094
dfcaporale commented 3 years ago
@time sol = solve(ivp, max_jumps=2,
                  clustering_method=LazyClustering(1), #, [1,1,2,2,1,1]),
                  intersect_source_invariant=true,
                  intersection_source_invariant_method=HRepIntersection(), # TemplateHullIntersection(extdirs),
                  intersection_method=HRepIntersection(), # TemplateHullIntersection(extdirs),
                  tspan = 0 .. 0.25,
                  alg=LGG09(δ=0.0001, template=extdirs, approx_model = StepIntersect(Forward())));
MethodError: no method matching discretize(::InitialValueProblem{ConstrainedLinearControlContinuousSystem{Float64, Matrix{Float64}, IdentityMultiple{Float64}, HPolyhedron{Float64, SparseVector{Float64, Int64}}, ConstantInput{Singleton{Float64, Vector{Float64}}}}, HPolytope{Float64, Vector{Float64}}}, ::Float64, ::StepIntersect{Forward{ReachabilityAnalysis.BaseExpAlg, Val{:lazy}, Val{:concrete}, Val{false}, Nothing}, Val{:lazy}})
Closest candidates are:
  discretize(::InitialValueProblem{var"#s14", var"#s13"} where {var"#s14"<:ConstrainedLinearControlContinuousSystem, var"#s13"<:LazySet}, ::Any, ::NoBloating) at C:\Users\danie\.julia\dev\ReachabilityAnalysis\src\Discretization\NoBloating.jl:64
  discretize(::InitialValueProblem{var"#s14", var"#s13"} where {var"#s14"<:ConstrainedLinearControlContinuousSystem, var"#s13"<:LazySet}, ::Any, ::Forward) at C:\Users\danie\.julia\dev\ReachabilityAnalysis\src\Discretization\Forward.jl:113
  discretize(::InitialValueProblem{var"#s14", var"#s13"} where {var"#s14"<:ConstrainedLinearControlContinuousSystem, var"#s13"<:LazySet}, ::Any, ::CorrectionHull) at C:\Users\danie\.julia\dev\ReachabilityAnalysis\src\Discretization\CorrectionHull.jl:100
  ...

Stacktrace:
 [1] post(alg::LGG09{Float64, StepIntersect{Forward{ReachabilityAnalysis.BaseExpAlg, Val{:lazy}, Val{:concrete}, Val{false}, Nothing}, Val{:lazy}}, Vector{Float64}, CustomDirections{Float64, Vector{Float64}}, Val{false}, Missing}, ivp::InitialValueProblem{ConstrainedAffineContinuousSystem{Float64, Matrix{Float64}, Vector{Float64}, HPolyhedron{Float64, SparseVector{Float64, Int64}}}, HPolytope{Float64, Vector{Float64}}}, tspan::IntervalArithmetic.Interval{Float64}; Δt0::IntervalArithmetic.Interval{Float64}, kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:tspan, :alg), Tuple{IntervalArithmetic.Interval{Float64}, LGG09{Float64, StepIntersect{Forward{ReachabilityAnalysis.BaseExpAlg, Val{:lazy}, Val{:concrete}, Val{false}, Nothing}, Val{:lazy}}, Vector{Float64}, CustomDirections{Float64, Vector{Float64}}, Val{false}, Missing}}}})
   @ ReachabilityAnalysis ~\.julia\dev\ReachabilityAnalysis\src\Algorithms\LGG09\post.jl:28
 [2] solve(::InitialValueProblem{HybridSystem{LightAutomaton{LightGraphs.SimpleGraphs.SimpleDiGraph{Int64}, LightGraphs.SimpleGraphs.SimpleEdge{Int64}}, ConstrainedAffineContinuousSystem{Float64, Matrix{Float64}, Vector{Float64}, ST} where ST, ConstrainedLinearMap{Float64, Matrix{Float64}, ST} where ST, AutonomousSwitching, Vector{ConstrainedAffineContinuousSystem{Float64, Matrix{Float64}, Vector{Float64}, ST} where ST}, Vector{ConstrainedLinearMap{Float64, Matrix{Float64}, ST} where ST}, Vector{AutonomousSwitching}}, Vector{Tuple{Int64, Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}}}}; max_jumps::Int64, intersection_method::HRepIntersection, clustering_method::LazyClustering{Int64, Val{true}}, check_invariant_initial_states::Bool, intersect_invariant_initial_states::Bool, intersection_source_invariant_method::HRepIntersection, first_mode_representative::Bool, intersect_source_invariant::Bool, disjointness_method::FallbackDisjointness, fixpoint_check::Bool, WLtype::Type, kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:tspan, :alg), Tuple{IntervalArithmetic.Interval{Float64}, LGG09{Float64, StepIntersect{Forward{ReachabilityAnalysis.BaseExpAlg, Val{:lazy}, Val{:concrete}, Val{false}, Nothing}, Val{:lazy}}, Vector{Float64}, CustomDirections{Float64, Vector{Float64}}, Val{false}, Missing}}}})
   @ ReachabilityAnalysis ~\.julia\dev\ReachabilityAnalysis\src\Hybrid\solve.jl:78
 [3] top-level scope
   @ .\timing.jl:210 [inlined]
 [4] top-level scope
   @ .\In[70]:0
 [5] eval
   @ .\boot.jl:360 [inlined]
 [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base .\loading.jl:1094
mforets commented 3 years ago

thanks for the reports. homogeneization in hybrid systems should special case some set operations, because the dimension of, say, the guard, will be off by 1 with respect to that of the flowpipe.