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

[WIP #93] - Revise add-dimension #148

Merged
merged 7 commits into from
Apr 15, 2018
Merged

[WIP #93] - Revise add-dimension #148

merged 7 commits into from
Apr 15, 2018

Conversation

mforets
Copy link
Member

@mforets mforets commented Apr 5, 2018

Closes #93.

@mforets
Copy link
Member Author

mforets commented Apr 5, 2018

There is some conflict with partition option that i didn't look into yet.

julia> A = randn(5, 5); X0 = BallInf(ones(5), 0.1)
julia> s = solve(ContinuousSystem(A, X0), :T=>0.1, :partition=>[1:2, 3:4, 5],
                 :block_types=>Dict(HPolygon=>[1:2, 3:4], Interval=>[[5]]),
                 :vars=>[1,3]);
ERROR: Option :partition must be of 'AbstractArray{#s60,1} where #s60<:AbstractArray{Int64,1}' type.
Stacktrace:
 [1] validate_solver_options_and_add_default_values!(::Reachability.Options) at /Users/forets/.julia/v0.6/Reachability/src/options.jl:276
 [2] solve(::Reachability.Systems.ContinuousSystem, ::Reachability.Options) at /Users/forets/.julia/v0.6/Reachability/src/solve.jl:92
 [3] solve(::Reachability.Systems.ContinuousSystem, ::Pair{Symbol,Float64}, ::Pair{Symbol,Array{Any,1}}, ::Vararg{Pair{Symbol,#s61} where #s61,N} where N) at /Users/forets/.julia/v0.6/Reachability/src/solve.jl:23
4

@@ -47,3 +47,12 @@ s = solve(ContinuousSystem(sparse(A), X0), :T=>0.1, :partition=>[1:2, 3:4],

s = solve(ContinuousSystem(sparse(A), X0), :T=>0.1, :partition=>[[i] for i in 1:4],
:set_type=>Interval, :vars=>[1,3], :lazy_expm=>true);

# ===============================
# System with an add dimension
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"odd"

src/options.jl Outdated
block_types = nothing
if haskey(dict, :block_types)
block_types = convert(Dict{Type{<:LazySet}, AbstractVector{<:AbstractVector{Int}}}, dict[:block_types])
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge else and if to elseif?

@schillic
Copy link
Member

schillic commented Apr 15, 2018

There is some conflict with partition option that i didn't look into yet.

The problem is that :partition has the value Any[1:2, 3:4, 5]. It must be of type AbstractVector{<:AbstractVector{Int}}, not AbstractVector{<:Any}.

Fix: In the unit test use :partition=>[1:2, 3:4, 5:5] (wrap 5 in an AbstractVector).
This, however, leads to the next error 😈

LoadError: Option :block_types with value Dict{UnionAll,Any}(Pair{UnionAll,Any}(LazySets.HPolygon, UnitRange{Int64}[1:2, 3:4]),Pair{UnionAll,Any}(LazySets.Interval, Array{Int64,1}[[5]])) must be of 'Dict{Type{#s33} where #s33<:LazySets.LazySet,AbstractArray{#s32,1} where #s32<:AbstractArray{Int64,1}}' type.
  Stacktrace:
   [1] validate_solver_options_and_add_default_values!(::Reachability.Options) at src/options.jl:276

@mforets
Copy link
Member Author

mforets commented Apr 15, 2018

thanks. i am still getting

julia> using Reachability

julia> A = randn(5, 5); X0 = BallInf(ones(5), 0.1)
LazySets.BallInf{Float64}([1.0, 1.0, 1.0, 1.0, 1.0], 0.1)

julia> system = ContinuousSystem(A, X0)
Systems.InitialValueProblem{Systems.LinearContinuousSystem{Float64,Array{Float64,2}},LazySets.BallInf{Float64}}(Systems.LinearContinuousSystem{Float64,Array{Float64,2}}([-0.209005 0.785492  0.950694 -0.29526; -0.462302
 0.464034  0.706485 0.00687863;  ; 0.352559 -0.234473  0.227757 0.475551; 0.974808 0.44691  0.35475 0.745588]), LazySets.BallInf{Float64}([1.0, 1.0, 1.0, 1.0, 1.0], 0.1))

julia> options = Options(Dict(:T=>0.1, :partition=>convert(AbstractVector{<:AbstractVector{Int}}, [1:2, 3:4, [5]]), :block_types=>Dict(HPolygon=>[1:2, 3:4], Interval=>[[5]]), :vars=>[1,3]))
Reachability.Options(Dict{Symbol,Any}(Pair{Symbol,Any}(:T, 0.1),Pair{Symbol,Any}(:vars, [1, 3]),Pair{Symbol,Any}(:partition, AbstractArray{Int64,1}[1:2, 3:4, [5]]),Pair{Symbol,Any}(:block_types, Dict{UnionAll,Any}(Pair{
UnionAll,Any}(LazySets.Interval, Array{Int64,1}[[5]]),Pair{UnionAll,Any}(LazySets.HPolygon, UnitRange{Int64}[1:2, 3:4])))))


julia> s = solve(system, options)
ERROR: MethodError: no method matching one(::Type{Array{Float64,1}})
Closest candidates are:
  one(::BitArray{2}) at bitarray.jl:427
  one(::Type{IntervalArithmetic.Interval{T<:Real}}) where T<:Real at /Users/forets/.julia/v0.6/IntervalArithmetic/src/intervals/arithmetic.jl:57
  one(::Type{IntervalArithmetic.DecoratedInterval{T<:Real}}) where T<:Real at /Users/forets/.julia/v0.6/IntervalArithmetic/src/decorations/functions.jl:7
  ...
Stacktrace:
 [1] *(::Array{Float64,1}, ::LazySets.Interval{Float64,IntervalArithmetic.Interval{Float64}}) at /Users/forets/.julia/v0.6/LazySets/src/LinearMap.jl:76
 [2] reach_blocks!(::Array{Float64,2}, ::Array{LazySets.LazySet{Float64},1}, ::Void, ::Reachability.ReachSets.##7#10{Float64}, ::Int64, ::Int64, ::Array{Int64,1}, ::Array{Union{Int64, UnitRange{Int64}},1}, ::Array{LazyS
ets.CartesianProductArray{Float64,S} where S<:LazySets.LazySet{Float64},1}) at /Users/forets/.julia/v0.6/Reachability/src/ReachSets/reach_blocks.jl:145
 [3] #reach#6(::String, ::Float64, ::Type{LazySets.Hyperrectangle}, ::Float64, ::Type{LazySets.Hyperrectangle}, ::Bool, ::Bool, ::Type{T} where T, ::Bool, ::Array{Any,1}, ::Reachability.ReachSets.#reach, ::Systems.Initi
alValueProblem{Systems.LinearDiscreteSystem{Float64,Array{Float64,2}},LazySets.ConvexHull{Float64,LazySets.BallInf{Float64},LazySets.LinearMap{Float64,Float64}}}, ::Int64) at /Users/forets/.julia/v0.6/Reachability/src/R
eachSets/reach.jl:135
 [4] (::Reachability.ReachSets.#kw##reach)(::Array{Any,1}, ::Reachability.ReachSets.#reach, ::Systems.InitialValueProblem{Systems.LinearDiscreteSystem{Float64,Array{Float64,2}},LazySets.ConvexHull{Float64,LazySets.BallI
nf{Float64},LazySets.LinearMap{Float64,Float64}}}, ::Int64) at ./<missing>:0
 [5] solve(::Systems.InitialValueProblem{Systems.LinearContinuousSystem{Float64,Array{Float64,2}},LazySets.BallInf{Float64}}, ::Reachability.Options) at /Users/forets/.julia/v0.6/Reachability/src/solve.jl:149

src/options.jl Outdated
expected_type =
Dict{Type{<:LazySet}, AbstractVector{<:AbstractVector{Int}}}
expected_type = Dict
#Dict{Type{<:LazySet}, AbstractVector{<:AbstractVector{Int}}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can re-add this because you convert the value to this type.

@schillic
Copy link
Member

schillic commented Apr 15, 2018

thanks. i am still getting

We have bi = 1:2, bj = 5 in arr[j] = ϕpowerk[bi, bj] * Xhat0[j] from reach_blocks.jl.

The problem is this. In LazySets.LinearMap we have:

function *(a::N, X::LazySet) where {N}
    return LinearMap(a * speye(N, dim(X)), X)
end

We call it with the following:

X = Interval([0.9, 1.10445]); a = [0.0029649, -0.00173048];
a * X

Here N becomes Array{Float64,2}, and there is no speye(N, k).

This is a bug in LazySets. See #321.

@schillic schillic merged commit 3060bdf into master Apr 15, 2018
@schillic schillic deleted the mforets/93 branch April 15, 2018 15:41
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