Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#512 - Add new option to discretize #528

Merged
merged 3 commits into from
Mar 8, 2019
Merged

#512 - Add new option to discretize #528

merged 3 commits into from
Mar 8, 2019

Conversation

mforets
Copy link
Member

@mforets mforets commented Mar 8, 2019

Closes #512.

  • add tests

src/ReachSets/discretize.jl Show resolved Hide resolved
src/ReachSets/discretize.jl Outdated Show resolved Hide resolved
@mforets
Copy link
Member Author

mforets commented Mar 8, 2019

    A = sparse([1, 1, 2, 3, 4], [1, 2, 2, 4, 3], [1., 2., 3., 4., 5.], 4, 4)
    X0 = BallInf(zeros(4), 0.1)
    cont_sys_homog = IVP(LCS(A), X0)
    δ = 0.01

julia> discr_sys_homog = discretize(cont_sys_homog, δ, algorithm="forward", set_operations="zonotope")
ERROR: MethodError: no method matching minkowski_sum(::BallInf{Float64}, ::Zonotope{Float64})
Closest candidates are:

  minkowski_sum(::Zonotope{N<:Real}, ::Zonotope{N<:Real}) where N<:Real at /Users/forets/.julia/dev/LazySets/src/Zonotope.jl:330
Stacktrace:
 [1] _discretize_interpolation_homog(::BallInf{Float64}, ::Array{Float64,2}, ::Hyperrectangle{Float64}, ::Val{:zonotope}) at /Users/forets/.julia/dev/Reachability/src/ReachSets/discretize.jl:6
92
 [2] #discretize_interpolation#9(::String, ::String, ::String, ::String, ::Function, ::InitialValueProblem{LinearContinuousSystem{Float64,SparseMatrixCSC{Float64,Int64}},BallInf{Float64}}, ::F
loat64) at /Users/forets/.julia/dev/Reachability/src/ReachSets/discretize.jl:648
 [3] #discretize_interpolation at ./none:0 [inlined]
 [4] #discretize#1(::String, ::String, ::String, ::String, ::Function, ::InitialValueProblem{LinearContinuousSystem{Float64,SparseMatrixCSC{Float64,Int64}},BallInf{Float64}}, ::Float64) at /Us
ers/forets/.julia/dev/Reachability/src/ReachSets/discretize.jl:100
 [5] (::getfield(Reachability.ReachSets, Symbol("#kw##discretize")))(::NamedTuple{(:algorithm, :set_operations),Tuple{String,String}}, ::typeof(discretize), ::InitialValueProblem{LinearContinu
ousSystem{Float64,SparseMatrixCSC{Float64,Int64}},BallInf{Float64}}, ::Float64) at ./none:0
 [6] top-level scope at none:0

@schillic
Copy link
Member

schillic commented Mar 8, 2019

I think generally the code cannot assume that the initial states are given as a zonotope or related sets, right? So you need to call overapproximate.

@mforets
Copy link
Member Author

mforets commented Mar 8, 2019

Agreed, i was just about to comment on that. I have been assuming that the initial states are hyperrectangular for which we have a good conversion. Changing to overapproximate doesn't work ATM (we may do this in another PR):

julia> H = rand(Hyperrectangle, dim=10);

julia> convert(Zonotope, H);

julia> using LazySets.Approximations

julia> overapproximate(H, Zonotope);
ERROR: MethodError: no method matching overapproximate(::Hyperrectangle{Float64}, ::Type{Zonotope})
Closest candidates are:
  overapproximate(::LazySet{N<:Real}, ::Type{#s65} where #s65<:HPolygon) where N<:Real at /Users/forets/.julia/dev/LazySets/src/Approximations/overapproximate.jl:42
  overapproximate(::LazySet{N<:Real}, ::Type{#s35} where #s35<:HPolygon, ::Real) where N<:Real at /Users/forets/.julia/dev/LazySets/src/Approximations/overapproximate.jl:42
  overapproximate(::ConvexHull{N<:Real,Zonotope{N<:Real},Zonotope{N<:Real}}, ::Type{#s66} where #s66<:Zonotope) where N<:Real at /Users/forets/.julia/dev/LazySets/src/Approximations/overapproximate.jl:195
  ...
Stacktrace:
 [1] top-level scope at none:0

@schillic
Copy link
Member

schillic commented Mar 8, 2019

We can also keep convert here and change that later I think.

@mforets
Copy link
Member Author

mforets commented Mar 8, 2019

I kept convert and added tests for the homogeneous and the constant case.

@mforets
Copy link
Member Author

mforets commented Mar 8, 2019

Opened #530 as follow-up for the cases where the sets are not convertible to Zonotope.

@mforets
Copy link
Member Author

mforets commented Mar 8, 2019

Thanks for the review ♻️

@mforets mforets merged commit 1b41551 into master Mar 8, 2019
@mforets mforets deleted the mforets/512 branch March 8, 2019 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants