Giter VIP home page Giter VIP logo

lazysets.jl's Introduction

LazySets.jl

Scalable Symbolic-Numeric Set Computations

Introduction & Documentation Status Community Version-specific Citation License
paper docs-dev CI codecov aqua zulip zenodo license

❓ Introduction

The following article showcases the basic functionality, highlighting some of the key design choices:

Forets, Marcelo, and Christian Schilling. LazySets.jl: Scalable Symbolic-Numeric Set Computations. Proceedings of the JuliaCon Conferences (2021).

See below for how to cite it.

🎯 Resources

💾 Installing

LazySets.jl is a registered Julia package and as such you can install it by activating the pkg mode (type ], and to leave it, type <backspace>), followed by

pkg> add LazySets

See the Getting started section of the manual for other options.

📘 Publications

This library has been applied in a number of scientific works.

Click to see the full list of publications that use LazySets.

The articles appear in reverse chronological order.

[33] Verified propagation of imprecise probabilities in non-linear ODEs. Ander Gray, Marcelo Forets, Christian Schilling, Scott Ferson, and Luis Benet (2024). International Journal of Approximate Reasoning, vol. 164. doi: 10.1016/j.ijar.2023.109044.

[32] Safety verification of decision-tree policies in continuous time. Christian Schilling, Anna Lukina, Emir Demirović, and Kim G. Larsen (2023). 37th Conference on Neural Information Processing Systems (NeurIPS). pdf.

[31] Shielded reinforcement learning for hybrid systems. Asger H. Brorholt, Peter G. Jensen, Kim G. Larsen, Florian Lorber, and Christian Schilling (2023). 1st International Conference on Bridging the Gap between AI and Reality (AISoLA), LNCS, vol. 14380, pp. 33-54. doi: 10.1007/978-3-031-46002-9_3, arXiv: 2308.14424.

[30] The inverse problem for neural networks. Marcelo Forets and Christian Schilling (2023). 1st International Conference on Bridging the Gap between AI and Reality (AISoLA), LNCS, vol. 14380, pp. 241-255. doi: 10.1007/978-3-031-46002-9_14, arXiv: 2308.14093.

[29] ARCH-COMP23 category report: Continuous and hybrid systems with linear continuous dynamics. Matthias Althoff, Marcelo Forets, Yangge Li, Sayan Mitra, Christian Schilling, Mark Wetzlinger, and Daniel Zhuang (2023). 10th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH23), vol 96, pp. 34-60. doi: 10.29007/nl86.

[28] ARCH-COMP23 category report: Continuous and hybrid systems with nonlinear dynamics. Luca Geretti, Julien Alexandre Dit Sandretto, Matthias Althoff, Luis Benet, Pieter Collins, Marcelo Forets, Elena Ivanova, Yangge Li, Sayan Mitra, Stefan Mitsch, Christian Schilling, Mark Wetzlinger, and Daniel Zhuang (2023). 10th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH23), vol 96, pp. 61-88. doi: 10.29007/93f2.

[27] ARCH-COMP23 category report: Artificial intelligence and neural network control systems for continuous and hybrid systems plants. Diego Manzanas Lopez, Matthias Althoff, Marcelo Forets, Taylor T. Johnson, Tobias Ladner, and Christian Schilling (2023). 10th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH23), vol 96, pp. 89-125. doi: 10.29007/x38n.

[26] ARCH-COMP22 category report: Continuous and hybrid systems with linear continuous dynamics. Matthias Althoff, Marcelo Forets, Christian Schilling, and Mark Wetzlinger (2022). 9th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH22), vol 90, pp. 58-85. doi: 10.29007/mmzc.

[25] ARCH-COMP22 category report: Continuous and hybrid systems with nonlinear dynamics. Luca Geretti, Julien Alexandre Dit Sandretto, Matthias Althoff, Luis Benet, Pieter Collins, Parasara Sridhar Duggirala, Marcelo Forets, Edward Kim, Stefan Mitsch, Christian Schilling, and Mark Wetzlinger (2022). 9th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH22), vol 90, pp. 86-112. doi: 10.29007/fnzc.

[24] ARCH-COMP22 category report: Artificial intelligence and neural network control systems for continuous and hybrid systems plants. Diego Manzanas Lopez, Matthias Althoff, Luis Benet, Xin Chen, Jiameng Fan, Marcelo Forets, Chao Huang, Taylor T. Johnson, Tobias Ladner, Wenchao Li, Christian Schilling, and Qi Zhu (2022). 9th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH22), vol 90, pp. 142-184. doi: 10.29007/wfgr.

[23] Synthesis of parametric hybrid automata from time series. Miriam García Soto, Thomas A. Henzinger, and Christian Schilling (2022). Proceedings of the 20th International Symposium on Automated Technology for Verification and Analysis, LNCS, vol. 13505, pp. 337-353. doi: 10.1007/978-3-031-19992-9_22, arXiv: 2208.06383.

[22] Decomposing reach set computations with low-dimensional sets and high-dimensional matrices (extended version). Sergiy Bogomolov, Marcelo Forets, Goran Frehse, Andreas Podelski, and Christian Schilling (2022). Information and Computation, vol. 289. doi: 10.1016/j.ic.2022.104937.

[21] Conservative Time Discretization: A Comparative Study. Marcelo Forets and Christian Schilling (2022). Proceedings of the 17th International Conference on integrated Formal Methods (iFM), LNCS, vol. 13274, pp. 149-167. doi: 10.1007/978-3-031-07727-2_9, arXiv: 2111.01454.

[20] Verification of Neural-Network Control Systems by Integrating Taylor Models and Zonotopes. Christian Schilling, Marcelo Forets, and Sebastián Guadalupe (2022). Proceedings of the 36th Conference on Artificial Intelligence (AAAI). doi: 10.1609/aaai.v36i7.20790.

[19] Combining Set Propagation with Finite Element Methods for Time Integration in Transient Solid Mechanics Problems. Marcelo Forets, Daniel Freire Caporale, and Jorge M. Pérez Zerpa (2022). Computers & Structures, vol 259. doi: 10.1016/j.compstruc.2021.106699, arXiv: 2105.05841.

[18] LazySets.jl: Scalable Symbolic-Numeric Set Computations. Marcelo Forets and Christian Schilling (2021). Proceedings of the JuliaCon Conferences. doi: 10.21105/jcon.00097.

[17] Reachability of weakly nonlinear systems using Carleman linearization. Marcelo Forets and Christian Schilling (2021). Proceedings of the 15th International Conference on Reachability Problems (RP), LNCS, vol. 13035, pp. 85-99. doi: 10.1007/978-3-030-89716-1_6, arXiv: 2108.10390.

[16] Combined Exact and Heuristics Based Approach to Hamiltonian Path Problem Optimization for Route Planning. Fernando Hernandez, Rafael Sotelo, and Marcelo Forets (2021). Technical Proceedings of the 2021 Amazon Last Mile Routing Research Challenge.

[15] ARCH-COMP21 Category Report: Continuous and Hybrid Systems with Linear Continuous Dynamics. Matthias Althoff, Erika Abraham, Marcelo Forets, Goran Frehse, Daniel Freire, Christian Schilling, Stefan Schupp, and Mark Wetzlinger (2021). 8th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH21), vol 80, pp. 1-31. doi: 10.29007/lhbw.

[14] ARCH-COMP21 Category Report: Continuous and Hybrid Systems with Nonlinear Dynamics. Luca Geretti, Julien Alexandre dit Sandretto, Matthias Althoff, Luis Benet, Alexandre Chapoutot, Pieter Collins, Parasara Sridhar Duggirala, Marcelo Forets, Edward Kim, Uziel Linares, David P. Sanders, Christian Schilling, and Mark Wetzlinger (2021). 8th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH21), vol 80, pp. 32-54. doi: 10.29007/2jw8.

[13] ARCH-COMP21 Category Report: Artificial Intelligence and Neural Network Controlled Systems for Continuous and Hybrid Systems Plants. Taylor T. Johnson, Diego Manzanas Lopez, Luis Benet, Marcelo Forets, Christian Schilling, Radoslav Ivanov, Taylor Carpenter, James Weimer, and Insup Lee (2021). 8th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH21), vol 80, pp. 90-119. doi: 10.29007/kfk9.

[12] Synthesis of hybrid automata with affine dynamics from time-series data. Miriam García Soto, Thomas A. Henzinger, and Christian Schilling (2021). 24th International Conference on Hybrid Systems: Computation and Control (HSCC). doi: 10.1145/3447928.3456704, arXiv: 2102.12734.

[11] Algorithms for verifying deep neural networks. Changliu Liu, Tomer Arnon, Christopher Lazarus, Christopher A. Strong, Clark W. Barrett, and Mykel J. Kochenderfer (2021). Foundations and Trends in Optimization, vol 4, pp. 244-404. doi: 10.1561/2400000035, arXiv: 1903.06758.

[10] Efficient reachability analysis of parametric linear hybrid systems with time-triggered transitions. Marcelo Forets, Daniel Freire, and Christian Schilling (2020). Proceedings of the 18th International Conference on Formal Methods and Models for System Design (MEMOCODE), pp. 137-142. doi: 10.1109/MEMOCODE51338.2020.9314994, arXiv: 2006.12325.

[9] ARCH-COMP20 Category Report: Continuous and Hybrid Systems with Linear Continuous Dynamics. Matthias Althoff, Stanley Bak, Zongnan Bao, Marcelo Forets, Daniel Freire, Goran Frehse, Niklas Kochdumper, Yangge Li, Sayan Mitra, Rajarshi Ray, Christian Schilling, Stefan Schupp, and Mark Wetzlinger (2020). 7th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH20), vol 74, pp. 16-48. doi: 10.29007/7dt2.

[8] ARCH-COMP20 Category Report: Continuous and Hybrid Systems with Nonlinear Dynamics. Luca Geretti, Julien Alexandre dit Sandretto, Matthias Althoff, Luis Benet, Alexandre Chapoutot, Xin Chen, Pieter Collins, Marcelo Forets, Daniel Freire, Fabian Immler, Niklas Kochdumper, David P. Sanders, and Christian Schilling (2020). 7th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH20), vol 74, pp. 49-75. doi: 10.29007/zkf6.

[7] Case Study: Reachability Analysis of a unified Combat-Command-and-Control Model. Sergiy Bogomolov, Marcelo Forets, and Kostiantyn Potomkin (2020). Proceedings of the 14th International Conference on Reachability Problems (RP), LNCS, vol 12448, pp. 52-66. doi: 10.1007/978-3-030-61739-4_4.

[6] Reachability analysis of linear hybrid systems via block decomposition. Sergiy Bogomolov, Marcelo Forets, Goran Frehse, Kostiantyn Potomkin, and Christian Schilling (2020). IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, vol. 39, pp. 4018-4029. Presented at Embedded Systems Week 2020. doi: 10.1109/TCAD.2020.3012859, arXiv: 1905.02458.

[5] ARCH-COMP19 Category Report: Continuous and Hybrid Systems with Linear Continuous Dynamics. Matthias Althoff, Stanley Bak, Marcelo Forets, Goran Frehse, Niklas Kochdumper, Rajarshi Ray, Christian Schilling, and Stefan Schupp (2019). 6th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH19), vol 61, pp. 14-40. doi: 10.29007/bj1w.

[4] ARCH-COMP19 Category Report: Continuous and Hybrid Systems with Nonlinear Dynamics. Fabian Immler, Matthias Althoff, Luis Benet, Alexandre Chapoutot, Xin Chen, Marcelo Forets, Luca Geretti, Niklas Kochdumper, David P. Sanders, and Christian Schilling (2019). 6th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH19), vol 61, pp. 41-61. doi: 10.29007/m75b.

[3] JuliaReach: a Toolbox for Set-Based Reachability. Sergiy Bogomolov, Marcelo Forets, Goran Frehse, Kostiantyn Potomkin, Christian Schilling (2019). Proceedings of the 22nd International Conference on Hybrid Systems: Computation and Control (HSCC), pp. 39-44. doi: 10.1145/3302504.3311804, arXiv: 1901.10736.

[2] ARCH-COMP18 Category Report: Continuous and Hybrid Systems with Linear Continuous Dynamics. Matthias Althoff, Stanley Bak, Xin Chen, Chuchu Fan, Marcelo Forets, Goran Frehse, Niklas Kochdumper, Yangge Li, Sayan Mitra, Rajarshi Ray, Christian Schilling, and Stefan Schupp (2018). 5th International Workshop on Applied Verification of Continuous and Hybrid Systems (ARCH18), vol 54, pp. 23–52. doi: 10.29007/73mb.

[1] Reach Set Approximation through Decomposition with Low-dimensional Sets and High-dimensional Matrices. Sergiy Bogomolov, Marcelo Forets, Goran Frehse, Frédéric Viry, Andreas Podelski, and Christian Schilling (2018). Proceedings of the 21st International Conference on Hybrid Systems: Computation and Control (HSCC), pp. 41–50. doi: 10.1145/3178126.3178128, arXiv: 1801.09526.

🗺 Ecosystem

Several projects in the Julia technical computing stack use this library.

Click to see the full list of Julia packages that use LazySets.

👨‍🏫 Workshop at JuliaCon 2021

Abstract

We present JuliaReach, a Julia ecosystem to perform reachability analysis of dynamical systems. JuliaReach builds on sound scientific approaches and was, in two occasions (2018 and 2020) the winner of the annual friendly competition on Applied Verification for Continuous and Hybrid Systems (ARCH-COMP).

The workshop consists of three parts (respectively packages) in JuliaReach: our core package for set representations, our main package for reachability analysis, and a new package applying reachability analysis with potential use in domain of control, robotics and autonomous systems.

In the first part we present LazySets.jl, which provides ways to symbolically represent sets of points as geometric shapes, with a special focus on convex sets and polyhedral approximations. LazySets.jl provides methods to apply common set operations, convert between different set representations, and efficiently compute with sets in high dimensions.

In the second part we present ReachabilityAnalysis.jl, which provides tools to approximate the set of reachable states of systems with both continuous and mixed discrete-continuous dynamics, also known as hybrid systems. It implements conservative discretization and set-propagation techniques at the state-of-the-art.

In the third part we present NeuralNetworkAnalysis.jl, which is an application of ReachabilityAnalysis.jl to analyze dynamical systems that are controlled by neural networks. This package can be used to validate or invalidate specifications, for instance about the safety of such systems.

Workshop materials are available here: https://github.com/JuliaReach/JuliaCon-2021-Workshop-Its-All-Set

JuliaCon 2021 video

📜 How to cite

If you use this package in your work, please cite it using the metadata here or below.

Click to see BibTeX entry.
@article{lazysets21,
  title     = {{LazySets.jl: Scalable Symbolic-Numeric Set Computations}},
  author    = {Forets, Marcelo and Schilling, Christian},
  journal   = {Proceedings of the JuliaCon Conferences},
  year      = {2021},
  publisher = {The Open Journal},
  volume    = {1},
  number    = {1},
  pages     = {11},
  doi       = {10.21105/jcon.00097}
}

lazysets.jl's People

Contributors

aa25desh avatar bgarate avatar birm avatar dependabot[bot] avatar dfcaporale avatar github-actions[bot] avatar goretkin avatar juliatagbot avatar kpotomkin avatar lassepe avatar lucaferranti avatar mforets avatar mortenpi avatar mvanzulli avatar nablabits avatar nikos-kekatos avatar schillic avatar sebastianguadalupe avatar tomerarnon avatar viryfrederic avatar yupbank avatar zinoex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lazysets.jl's Issues

Membership check, missing cases

This is a continuation of #68. There we added containment checks (x ∈ S) for most set types. Some are still missing.

  • HPolytope (#167)
  • Intersection (#167)
  • ConvexHull
    A sufficient test is to check containment in both generating sets, but for negative answers one has to continue, e.g., checking ray intersection from some vertex of one set in the other set.
  • ExponentialProjectionMap
  • MinkowskiSum
    One could subtract one set from the point and check for nonempty intersection with the other set. There is literature for the case that the sum consists of polytopes only, this could be interesting.

ρ crashes for AbstractFloat types and rational direction

We have ρ(d::AbstractVector{N}, S::LazySet)::N where {N<:Real}.
This will crash for Ball2, even with rational direction. None of the below work:

ρ([1//1], Ball2([1//1], 1//1))
σ([1//1], Ball2([1//1], 1//1))
ρ([1//1], Ball2(1., 1.))
σ([1//1], Ball2(1., 1.))

The problem is that Ball2 (and Ballp) is only really usable with AbstractFloat types.
I guess there is no way around. Should we instead require that these types cannot even be created with numeric types that are above AbstractFloat? At least this would avoid confusion.

Revisit LinearConstraints.jl

  1. Rename the file to the singular form?
  2. Outsource Line to a new file?
  3. Should Line's field a::Vector{N} become a::Tuple{N, N} because the constructor requires 2D input?
    On the other hand, code-wise I do not see any problem with a Line having more than two dimensions. We only use it for 2D plots, but why should we restrict the general type? If we want to keep it 2D, I would rename it to Line2 or so.
  4. Should we promote Line to LazySet?
  5. (related) Should we have a LazySet type for a half-space? This is inspired by the doc for LinearConstraint.

Action points here:

  • rename LinearConstraints.jl to Line.jl and promote Line to LazySet
  • add LinearConstraint as alias to HalfSpace and remove the type
  • outsource intersection function to a new file concrete_intersection.jl

Automatically check for existence of required subtype specific methods

We have a lot of subtypes, e.g., of LazySet.
We want all of them to provide a method for the function σ.
Hence we should check that those methods exist to prevent new types that may break things.

We can get all subtypes with the help of subtypes(LazySet) and use the method_exists function to check for existence:

for S in subtypes(LazySet)
    println(method_exists(σ, (Vector{Float64}, S)))
end

I propose that we add such tests for all abstract types, also in Reachability.

We could even create a function that automates this process if we have several common methods:
Add in LazySets.jl:

function require()::Vector{Function}
    return [
        S -> (σ, (Vector{Float64}, S)),
        S -> (my_func1, (S)),
        S -> (my_func2, (S, Real, Int))
    ]
end

Then in the unit tests we just have to go through this vector and apply the test to each of them.
We probably need a mechanism to allow several require methods for different abstract types, e.g., by changing the name.

(I have not tested the second one, the first one works.)

Use assertions

Julia still does not support deactivating evaluation of @assert macros.

I played around with the following example test.jl.

n = 10000000
@assert zeros(n) == zeros(n)

Performance:

@time include("test.jl")
0.146106 seconds (139 allocations: 152.596 MiB, 64.41% gc time)

Let us add the following lines on top that try to deactivate the check:

import Base.@assert
macro assert(arg) end

Performance:

@time include("test.jl")
0.002707 seconds (135 allocations: 9.344 KiB)

Now remove the whole @assert line.
Performance:

0.000995 seconds (112 allocations: 7.609 KiB)

You can see that writing @assert does not cost nothing (probably because it still calls the empty macro), but that it does not evaluate the code that is passed.
I find this good enough to be used.

Recipes for 3D Plots

For arbitrary 3D lazy sets, we lack an overapproximate in that dim that can be used for visualization. That would need a generalization of the Lotov-like algorithm, but in 3D.

In the meantime, we could:

  • plot the result from ball-inf approximations (eps = Inf case)
  • plot the cartesian decomposition of the given set, as valid (2+1 dim) overapproximation

Note: for the Singleton type this already works, e.g.

julia> using IterTools
julia> plot([Singleton(collect(vi)) for vi in IterTools.product([[1, -1] for i = 1:3]...)])

screen shot 2017-11-13 at 14 06 11

--

Edit

useful links:

Subset check

Add a subset check ⊆(S1, S2), in particular for special types of S1.
In particular, for polytopes (and "subtypes"), since S2 is convex, it should suffice to check containment of all corners (see #68).

Also check if Julia has an alias for , otherwise add one such as isincluded or contains.

Line intersection throws errors

This happens if the lines are parallel or identical.

l1 = Line([1., 1.], 1.)
l2 = Line([1., 1.], 1.)
intersection(l1, l2) # Base.LinAlg.SingularException(2)
l3 = Line([1., 0.], 1.)
l4 = Line([1., 0.], 1.)
intersection(l3, l4) # Base.LinAlg.LAPACKException(2)

Fix 'docstrings potentially missing' warnings

Creating the documentation warns about potentially missing docstrings.
However, they are defined and occur properly in the final documentation.

Most notably:

  • LazySets.σ
  • LazySets.apply_recipe

For the non-apply_recipe functions the problem is related to type parameters.

Improved norm of hyperrectangular sets

Currently the norm of BallInf is implemented as follows.

return maximum(map(x -> norm(x, p), vertices_list(B)))

We could instead find the corner that is furthest from the origin (by simply adding/subtracting radius from center[i], depending on the sign of center[i], for each dimension i) and then immediately return the norm of this one vertex:

return norm((@. c + unit_step(c) * r), p)

EDIT: I had to change sign to unit_step for the 0 case.

@mforets: Am I right?

A similar idea should be applicable for Hyperrectangle.

Add unit tests for d=0 in lazy sets

We should review that for d=0 the support vector returns a point in the set, or to consider the special cases that raise an error otherwise.

Add type parameters to set wrappers

Types such as CartesianProductArray consist of several instances of LazySets.
Often all the elements have the same type, which we want to exploit by introducing a type parameter.
This helps in polymorphic function definitions where we specialize to subtypes and could improve general efficiency as the compiler can create a contiguous array.

Failing doctests should fail the build

@mforets: Currently there is a failing doctest in master:

> File: .../LazySets/src/Ball1.jl

> Code block:                                                                                                       

\`\`\`jldoctest
julia> σ([0.,1], B)
1-element Array{Float64,1}:
 1.0
 0.0
\`\`\`

> Subexpression:                                                                                                    

    σ([0.,1], B)

> Output Diff:                                                                                                      

1-element 2-element Array{Float64,1}:
 1.0
 0.00.0
 1.0 

However, Travis does not complain.
See here how to potentially implement this.

Change type unions to common supertype

Quite often we have the following code patterns:

d::Union{Vector{Float64}, SparseVector{Float64,Int64}}
M::Union{Matrix{Float64}, SparseMatrixCSC{Float64,Int64}}

We should use instead the common supertype:

d::AbstractVector{Float64}
M::AbstractMatrix{Float64}

This is easier to read and gives more flexibility (e.g., allow SubArrays if not already mentioned).
I do not expect negative performance impact; we should of course validate this.

Emptiness check of intersection of two sets

Add a function is_intersection_empty(S1, S2; witness=false) that returns true if the sets S1 and S2 do not intersect.
If the flag witness is set, also produce a witness, i.e., a point (vector) x such that x ∈ S1 ∩ S2 if the intersection is nonempty.
The table below tracks the current combinations that we support:

↓ ∩ → Ball1 Ball2 Ballp HRect Polygon Zonotope Singleton
Ball1 x
Ball2 x
Ballp x
HRect x x
Polygon x
Zonotope x
Singleton x x x x x x x

Related: #139

Illustrative examples for the manual

let's create a new examples folder with some illustrative examples and pictures:

  • polygon overapproximations => iterative refinement
  • convex hulls
  • interval hulls
  • reachability algorithm for linear systems using zonotopes

Extra vertices created in iterative refinement

For example, consider:

julia> using LazySets
julia> B = BallInf([0.5, 0.5], 0.1)
julia> import LazySets.Approximations: overapproximate

The transformation to a polygon without refinement works as expected:

julia> vertices_list(overapproximate(B, 1.))
4-element Array{Array{Float64,1},1}:
 [0.6, 0.6]
 [0.4, 0.6]
 [0.4, 0.4]
 [0.6, 0.4]

However, extra vertices are created if we decrease the error tolerance:

julia> vertices_list(overapproximate(B, 1e-3))
5-element Array{Array{Float64,1},1}:
 [0.6, 0.6]
 [0.4, 0.6]
 [0.4, 0.4]
 [0.4, 0.4]
 [0.6, 0.4]

This is to be revised and possibly avoided, since many applications of
overapproximate would generate a lot of needless vertices.

Provide convex hull for VPolygon

in our use case, we need to handle small number of points (<~100).

see also: https://en.wikipedia.org/wiki/Convex_hull_algorithms

moreover, sorting the points is necessary for the supp vector implementation we plan to do, so a good candidate is Graham scan algorithm.

pointers to Julia libraries:

name content comments
QuickHull.jl naïve implementation of the QuickHull algorithm for calculating the convex hull of a set of points in 2D broken for me, see this issue
CHull2d Graham scan, monotone chain, and 2 variants broken in v0.6; very fast in the bench provided
QHull

Implement binary search for VPolygon support vector

In #13 we implemented a O(n) algorithm to compute the support vector of a VPolygon. Since the vertices are sorted in CCW fashion by construction, we can do better than that using a binary search, see references below.


  • extreme points in convex polygons in the geomalgorithms site
  • Joseph O'Rourke, Computational Geometry in C (2nd Edition), Sect 7.9 "Extreme Point of Convex Polygon" (1998).

Containment check

Add a containment check ∈(x, S) for all sets.

For some we already have is_contained. I prefer in instead (the Julia alias for ).

Roadmap: Documentation

for "v1.0" we need to finish polishing the docs. on a high-level:

  • library of functions, include them all
  • beginning example: convex hull, M-sum, lazy mexp
  • finish "About" section
  • add a wiki page describing the documentation style that we use
    (we use it for Reachability.jl as well; eventually this will be unified for all repositories)
  • polyhedral approximations: resize figures and add text ssec 3
  • decomposing an affine map tutorial (from paper)
  • fast 2d LPs: resize fig and add Algorithm (from paper)
  • small examples for a "getting started" section, use jupyter notebooks (?) << we used @examples blocks
  • common set reps: review repeated docs of sigma << this is deferred to #72
  • add Polyhedra to the docs
  • clarify questions here

Add support vector for VPolygon

given a set of 2d vertices, the support vector of a VPolygon <:LazySet can be computed by:

  • sorting vertices by polar angle (see function <=)
  • performing binary search for the given direction

a convex hull preprocessing maybe needed, in general.

in a similar manner to HPolygonOpt, there can be a VPolygonOpt for warm-starting.

Allow example doctests

as suggested here, we can turn our examples into proper doctests.

with Documenter.jl, this boils down to using jldoctest in triple backticks for each example. i don't know if we need to have the line using LazySets in each code block.

Parametric numeric type of a LazySet

In some cases we'd like to have eltype(X) where X is a LazySet, to return the underlying numeric type. Eg. eltype(BallInf(ones(2), 0.1)) would be Float64.

In principle this would just require

abstract type LazySet{N<:Number} end

But we should see if this makes sense for all LazySets, both set representations and operations.

Semantic of "VoidSet"?

The "VoidSet" is stated as the neutral element for "+" and the absorbing element for "*".

I don't understand the name (as a neutral element for "+"), it refers to a set that is empty. The empty set is the absorbing element for the Minkowski sum. Maybe "ZeroSet" is more relevant.

On the other hand, the empty set is the absorbing element for the Cartesian product.

I think it is a bit confusing, maybe we have to split both concepts?

Bug in decompose(X) vs decompose(X, Inf)

Let

Ω0 = LazySets.ConvexHull{LazySets.CartesianProductArray{LazySets.BallInf},LazySets.LinearMap{LazySets.CartesianProductArray{LazySets.BallInf}}}(LazySets.CartesianProductArray{LazySets.BallInf}(LazySets.BallInf[LazySets.BallInf([0.767292, 0.936613], 0.1), LazySets.BallInf([0.734104, 0.87296], 0.1)]), LazySets.LinearMap{LazySets.CartesianProductArray{LazySets.BallInf}}([1.92664 1.00674 1.0731 -0.995149; -2.05704 3.48059 0.0317863 1.83481; 0.990993 -1.97754 0.754192 -0.807085; -2.43723 0.782825 -3.99255 3.93324], LazySets.CartesianProductArray{LazySets.BallInf}(LazySets.BallInf[LazySets.BallInf([0.767292, 0.936613], 0.1), LazySets.BallInf([0.734104, 0.87296], 0.1)])))

then

julia> Approximations.decompose(Ω0).sfarray[1].constraints_list

4-element Array{LazySets.LinearConstraint,1}:
 LazySets.LinearConstraint([1.0, 0.0], 2.63908)  
 LazySets.LinearConstraint([0.0, 1.0], 4.04073)  
 LazySets.LinearConstraint([-1.0, 0.0], -2.04145)
 LazySets.LinearConstraint([0.0, -1.0], -2.5726) 

although

julia> Approximations.decompose(Ω0, Inf).sfarray[1].constraints_list

4-element Array{LazySets.LinearConstraint,1}:
 LazySets.LinearConstraint([1.0, 0.0], 2.84043)   
 LazySets.LinearConstraint([0.0, 1.0], 4.04709)   
 LazySets.LinearConstraint([-1.0, 0.0], -0.667292)
 LazySets.LinearConstraint([0.0, -1.0], -0.836613)

Make HPolygonOpt a subtype of HPolygon

The only type union not affected by #19 exists in Polgyon.jl to handle HPolygons and HPolygonOpts simultaneously.

We should probably just make HPolygonOpt inherit from HPolygon.
This makes sense both from the code and from the conceptual side to me.
I am, however, not sure if Julia finds the correct function if one argument is an array of a subtype; I guess it does, but this has to be tested.

@mforets: What do you think?

Introduce common interfaces (abstract supertypes) for similar types

Initial motivation: supertype for HPolygon and HPolygonOpt:

  1. Avoid copy-pasting methods in both HPolygon and HPolygonOpt.
  2. Allows to restrict a type to a polygon irrespective of the implementation.

The idea also translates to other types such as BoxSet(?) for Hyperrectangle/BallInf.

Another idea is to have different implementations of array-type sets (MinkowskiSumArray etc.) that store their dimension for faster access.

So the general message here is:
Introduce interface types and usually only work with them.
A crucial implication is that we should never access member/field variables directly (because different implementations may not have those members).
Instead there should be a function that is usually just a getter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.