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

Adding BFFPS19 CPost and Decomposed Hybrid algorithms #641

Merged
merged 17 commits into from
Jul 29, 2019

Conversation

kpotomkin
Copy link
Collaborator

@kpotomkin kpotomkin commented Jun 24, 2019

(Follow-up work was deferred to #656.)

Still to resolve:

Future work:

@kpotomkin kpotomkin self-assigned this Jun 24, 2019
@kpotomkin kpotomkin requested a review from schillic June 24, 2019 06:35
@kpotomkin kpotomkin added algorithm A discrete or continuous post reachability algorithm hybrid labels Jun 24, 2019
Copy link
Member

@schillic schillic left a comment

Choose a reason for hiding this comment

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

I have not yet looked at the algorithms. It is hard to review because I do not see the changes here.
Did you not say that there were problems with the function names? How did you resolve them?

src/Options/default_options.jl Outdated Show resolved Hide resolved
src/Options/default_options.jl Outdated Show resolved Hide resolved
src/solve.jl Outdated Show resolved Hide resolved
src/solve.jl Outdated Show resolved Hide resolved
@kpotomkin
Copy link
Collaborator Author

kpotomkin commented Jun 24, 2019

Did you not say that there were problems with the function names?

Yes, I had these problems.

How did you resolve them?

I renamed some methods (see termination methods). Regarding reach_blocks: The problem was solved thanks to having different signature in comparison with reach_blocks in BFFPSV18. In particular, I have added constraints_list (from the guard), blocks approximations option and vars. Moreover, I divided these algorithms, so they cannot be called from wrong CPost (see here)).
Regarding choosing correct reach function: it was fixed thanks to renaming here

@kpotomkin kpotomkin changed the title Adding BBFFPS19 CPost and Decomposed Hybrid algorithms [WIP]Adding BBFFPS19 CPost and Decomposed Hybrid algorithms Jun 24, 2019
@kpotomkin kpotomkin changed the title [WIP]Adding BBFFPS19 CPost and Decomposed Hybrid algorithms Adding BBFFPS19 CPost and Decomposed Hybrid algorithms Jun 24, 2019
@kpotomkin kpotomkin requested a review from schillic June 24, 2019 15:50
Copy link
Member

@schillic schillic left a comment

Choose a reason for hiding this comment

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

I omitted reach_blocks.jl and the discrete post for now.

src/ReachSets/ContinuousPost/BFFPS19/BFFPS19.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/BFFPS19.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/BFFPS19.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/BFFPS19.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/BFFPS19.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_helper.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_helper.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/BFFPS19.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach.jl Outdated Show resolved Hide resolved
@kpotomkin kpotomkin requested a review from schillic June 25, 2019 07:59
src/Options/default_options.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_helper.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl Outdated Show resolved Hide resolved
function DecomposedDiscretePost(𝑂::Options)
𝑂copy = copy(𝑂)
# TODO: Check why it takes always default value for convex_hull
check_aliases_and_add_default_value!(𝑂.dict, 𝑂copy.dict, [:overapproximation], Hyperrectangle)
Copy link
Member

Choose a reason for hiding this comment

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

What do you mean here?

Copy link
Collaborator Author

@kpotomkin kpotomkin Jun 25, 2019

Choose a reason for hiding this comment

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

Somehow user-defined :overapproximation doesn't work in clustering function. It always overapproximate ConvexHull with Hyperrectangular.

src/ReachSets/ContinuousPost/BFFPS19/BFFPS19.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_helper.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach.jl Outdated Show resolved Hide resolved
@kpotomkin kpotomkin force-pushed the kostakoida/decohybid branch from 4b4aa82 to 6d5e645 Compare June 26, 2019 11:25
@kpotomkin kpotomkin requested a review from schillic June 26, 2019 11:58
src/ReachSets/ContinuousPost/BFFPS19/BFFPS19.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/BFFPS19.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/BFFPS19.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach.jl Outdated Show resolved Hide resolved
src/solve.jl Show resolved Hide resolved
Copy link
Member

@schillic schillic left a comment

Choose a reason for hiding this comment

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

I looked at the "sparse" algorithm only, but I assume that the same comments apply in the dense case.

src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach.jl Outdated Show resolved Hide resolved
src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl Outdated Show resolved Hide resolved
@kpotomkin kpotomkin changed the title Adding BBFFPS19 CPost and Decomposed Hybrid algorithms [WIP]Adding BBFFPS19 CPost and Decomposed Hybrid algorithms Jul 1, 2019
src/solve.jl Show resolved Hide resolved
@mforets
Copy link
Member

mforets commented Jul 5, 2019

A comment regarding the tests. I've ran test/Reachability/models and:

  • bouncing ball works
  • thermostat breaks with the following missing function:
julia> sol = solve(system, options, opC, DecomposedDiscretePost());
[info] Reachable States Computation...
[info] Time discretization...
[info] elapsed time: 4.220e-04 seconds
[info] - Decomposing X0
[info] elapsed time: 1.717e-05 seconds
[info] - Computing successors
ERROR: MethodError: no method matching overapproximate(::EmptySet{Float64}, ::Type{CartesianProductArray}, ::Array{Type{#s127} w
here #s127<:LazySet,1})
Closest candidates are:
  overapproximate(::Intersection{N,#s84,#s63} where #s63<:AbstractPolyhedron{N} where #s84<:(CartesianProductArray{N,S} where S<
:LazySet{N}), ::Type{CartesianProductArray}, ::Any) where N at /Users/forets/.julia/dev/LazySets/src/Approximations/overapproxim
ate.jl:951
  overapproximate(::Intersection{N,#s84,#s63} where #s63<:(CartesianProductArray{N,S} where S<:LazySet{N}) where #s84<:AbstractP
olyhedron{N}, ::Type{CartesianProductArray}, ::Any) where N at /Users/forets/.julia/dev/LazySets/src/Approximations/overapproxim
ate.jl:971
  overapproximate(::S<:LazySet, ::Type{S<:LazySet}, ::Any...) where S<:LazySet at /Users/forets/.julia/dev/LazySets/src/Approxim
ations/overapproximate.jl:18
  ...
Stacktrace:
 [1] getX_store at /Users/forets/.julia/dev/Reachability/src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.jl:9 [inlined]
 [2] reach_blocks!(::Array{Float64,2}, ::Array{LazySet{Float64},1}, ::ConstantInput{MinkowskiSum{Float64,LazySets.LinearMap{Floa
t64,Singleton{Float64,Array{Float64,1}},Float64,Array{Float64,2}},Hyperrectangle{Float64}}}, ::Function, ::getfield(Reachability
.ReachSets, Symbol("##81#87")), ::Int64, ::Int64, ::Nothing, ::Array{Int64,1}, ::Array{Int64,1}, ::Float64, ::Array{HalfSpace{Fl
oat64,Array{Float64,1}},1}, ::Array{Type{#s127} where #s127<:LazySet,1}, ::Array{Int64,1}, ::getfield(Reachability.ReachSets, Sy
mbol("##97#98")){Int64,HalfSpace{Float64,Array{Float64,1}}}, ::ProgressMeter.Progress, ::Array{ReachSet{CartesianProductArray{Fl
oat64,LazySet{Float64}},Float64},1}) at /Users/forets/.julia/dev/Reachability/src/ReachSets/ContinuousPost/BFFPS19/reach_blocks.
jl:247
 [3] macro expansion at /Users/forets/.julia/dev/Reachability/src/ReachSets/ContinuousPost/BFFPS19/reach.jl:212 [inlined]
 [4] reach_mixed(::InitialValueProblem{ConstrainedLinearControlDiscreteSystem{Float64,Array{Float64,2},IdentityMultiple{Float64}
,HalfSpace{Float64,Array{Float64,1}},ConstantInput{MinkowskiSum{Float64,LazySets.LinearMap{Float64,Singleton{Float64,Array{Float
64,1}},Float64,Array{Float64,2}},Hyperrectangle{Float64}}}},ConvexHull{Float64,Singleton{Float64,Array{Float64,1}},MinkowskiSum{
Float64,MinkowskiSum{Float64,MinkowskiSum{Float64,LazySets.LinearMap{Float64,Singleton{Float64,Array{Float64,1}},Float64,Array{F
loat64,2}},LazySets.LinearMap{Float64,Singleton{Float64,Array{Float64,1}},Float64,Array{Float64,2}}},Hyperrectangle{Float64}},Hy
perrectangle{Float64}}}}, ::Reachability.TwoLayerOptions) at /Users/forets/.julia/dev/Reachability/src/ReachSets/ContinuousPost/
BFFPS19/reach.jl:211
 [5] reach_mixed(::InitialValueProblem{ConstrainedLinearControlContinuousSystem{Float64,Array{Float64,2},IdentityMultiple{Float6
4},HalfSpace{Float64,Array{Float64,1}},ConstantInput{LazySets.LinearMap{Float64,Singleton{Float64,Array{Float64,1}},Float64,Arra
y{Float64,2}}}},Singleton{Float64,Array{Float64,1}}}, ::Reachability.TwoLayerOptions) at /Users/forets/.julia/dev/Reachability/s
rc/ReachSets/ContinuousPost/BFFPS19/reach.jl:235
 [6] macro expansion at /Users/forets/.julia/dev/Reachability/src/ReachSets/ContinuousPost/BFFPS19/BFFPS19.jl:249 [inlined]
 [7] post(::BFFPS19, ::InitialValueProblem{ConstrainedLinearControlContinuousSystem{Float64,Array{Float64,2},IdentityMultiple{Fl
oat64},HalfSpace{Float64,Array{Float64,1}},ConstantInput{LazySets.LinearMap{Float64,Singleton{Float64,Array{Float64,1}},Float64,
Array{Float64,2}}}},Singleton{Float64,Array{Float64,1}}}, ::Options) at /Users/forets/.julia/dev/Reachability/src/ReachSets/Cont
inuousPost/BFFPS19/BFFPS19.jl:248
 [8] #solve!#40(::BFFPS19, ::Function, ::InitialValueProblem{ConstrainedLinearControlContinuousSystem{Float64,Array{Float64,2},A
rray{Float64,2},HalfSpace{Float64,Array{Float64,1}},ConstantInput{Singleton{Float64,Array{Float64,1}}}},Singleton{Float64,Array{
Float64,1}}}, ::Options) at /Users/forets/.julia/dev/Reachability/src/solve.jl:74
 [9] (::getfield(Reachability, Symbol("#kw##solve!")))(::NamedTuple{(:op,),Tuple{BFFPS19}}, ::typeof(Reachability.solve!), ::Ini
tialValueProblem{ConstrainedLinearControlContinuousSystem{Float64,Array{Float64,2},Array{Float64,2},HalfSpace{Float64,Array{Floa
t64,1}},ConstantInput{Singleton{Float64,Array{Float64,1}}}},Singleton{Float64,Array{Float64,1}}}, ::Options) at ./none:0
 [10] solve!(::InitialValueProblem{HybridSystem{LightAutomaton{LightGraphs.SimpleGraphs.SimpleDiGraph{Int64},LightGraphs.SimpleG
raphs.SimpleEdge{Int64}},ConstrainedLinearControlContinuousSystem{Float64,Array{Float64,2},Array{Float64,2},HalfSpace{Float64,Ar
ray{Float64,1}},ConstantInput{Singleton{Float64,Array{Float64,1}}}},ConstrainedIdentityMap{HalfSpace{Float64,Array{Float64,1}}},
AutonomousSwitching,Array{ConstrainedLinearControlContinuousSystem{Float64,Array{Float64,2},Array{Float64,2},HalfSpace{Float64,A
rray{Float64,1}},ConstantInput{Singleton{Float64,Array{Float64,1}}}},1},Array{ConstrainedIdentityMap{HalfSpace{Float64,Array{Flo
at64,1}}},1},Array{AutonomousSwitching,1}},Array{Tuple{Int64,Singleton{Float64,Array{Float64,1}}},1}}, ::Options, ::BFFPS19, ::D
ecomposedDiscretePost) at /Users/forets/.julia/dev/Reachability/src/solve.jl:173
 [11] solve(::InitialValueProblem{HybridSystem{LightAutomaton{LightGraphs.SimpleGraphs.SimpleDiGraph{Int64},LightGraphs.SimpleGr
aphs.SimpleEdge{Int64}},ConstrainedLinearControlContinuousSystem{Float64,Array{Float64,2},Array{Float64,2},HalfSpace{Float64,Arr
ay{Float64,1}},ConstantInput{Singleton{Float64,Array{Float64,1}}}},ConstrainedIdentityMap{HalfSpace{Float64,Array{Float64,1}}},A
utonomousSwitching,Array{ConstrainedLinearControlContinuousSystem{Float64,Array{Float64,2},Array{Float64,2},HalfSpace{Float64,Ar
ray{Float64,1}},ConstantInput{Singleton{Float64,Array{Float64,1}}}},1},Array{ConstrainedIdentityMap{HalfSpace{Float64,Array{Floa
t64,1}}},1},Array{AutonomousSwitching,1}},Array{Tuple{Int64,Singleton{Float64,Array{Float64,1}}},1}}, ::Options, ::BFFPS19, ::De
composedDiscretePost) at /Users/forets/.julia/dev/Reachability/src/solve.jl:101
 [12] top-level scope at none:0

t1 += δ

terminate, skip, reach_set_intersected = termination(k, X_store, t0)
if reach_set_intersected isa EmptySet
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if reach_set_intersected isa EmptySet
if isempty(reach_set_intersected)
break
end

or even isempty(reach_set_intersected) && break (same in the other places).

Copy link
Member

Choose a reason for hiding this comment

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

Okay since we always operate on bounded sets and the emptiness information is given in the type. Generally isempty is more costly.

Copy link
Member

Choose a reason for hiding this comment

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

The termination makes an isempty check (see eg. termination_inv_out), and a new isempty check is made here. This is intended? Why not using the first output argument (terminate) here?

Copy link
Member

Choose a reason for hiding this comment

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

The termination makes an isempty check

Not always. You can also terminate by bounding the number of steps.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm and you can't use the second argument, skip? What is the purpose of these checks? Adding documentation would help the maintainability of this code :)

@kpotomkin kpotomkin force-pushed the kostakoida/decohybid branch from ccb582f to fe55b73 Compare July 15, 2019 01:34
@kpotomkin
Copy link
Collaborator Author

Should I squash the commits?

@mforets
Copy link
Member

mforets commented Jul 15, 2019

Either way is good; we can squash just before merging.

Can you add the new continuous post and discrete post to the hybrid tests?

@schillic
Copy link
Member

We are not done here (build is failing, tests are missing).

@mforets
Copy link
Member

mforets commented Jul 15, 2019

This PR should be updated accordingly to #647

@kpotomkin kpotomkin changed the title [WIP]Adding BBFFPS19 CPost and Decomposed Hybrid algorithms Adding BBFFPS19 CPost and Decomposed Hybrid algorithms Jul 18, 2019
@mforets
Copy link
Member

mforets commented Jul 28, 2019

Are we done here?

@schillic
Copy link
Member

schillic commented Jul 29, 2019

Are we done here?

The missing items are collected in the first comment. But we just agreed to merge and open a follow-up issue.

Copy link
Member

@schillic schillic left a comment

Choose a reason for hiding this comment

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

The remaining tasks can be addressed in a follow-up issue.

@schillic schillic changed the title Adding BBFFPS19 CPost and Decomposed Hybrid algorithms Adding BFFPS19 CPost and Decomposed Hybrid algorithms Jul 29, 2019
@schillic schillic merged commit 83489b8 into master Jul 29, 2019
@schillic schillic deleted the kostakoida/decohybid branch July 29, 2019 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
algorithm A discrete or continuous post reachability algorithm hybrid
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants