Skip to content

Commit

Permalink
Merge pull request #3321 from JuliaReach/schillic/membership_zonotope
Browse files Browse the repository at this point in the history
More efficient membership check in AbstractZonotope
  • Loading branch information
schillic authored May 8, 2023
2 parents 8aceeb5 + 634a178 commit bb1804d
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/Interfaces/AbstractZonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,27 +258,24 @@ If `solver == nothing`, we fall back to `default_lp_solver(N)`.
### Algorithm
The membership problem is computed by stating and solving the following linear
program.
The membership problem is reduced to the following linear program.
Let ``p`` and ``n`` be the number of generators and ambient dimension,
respectively.
We consider the minimization of ``x_0`` in the ``p+1``-dimensional space of
elements ``(x_0, ξ_1, …, ξ_p)`` constrained to ``0 ≤ x_0 ≤ ∞``,
``ξ_i ∈ [-1, 1]`` for all ``i = 1, …, p``, and such that ``x-c = Gξ`` holds.
If a feasible solution exists, the optimal value ``x_0 = 0`` is achieved.
We consider the ``p``-dimensional space of elements ``(ξ_1, …, ξ_p)``
constrained to ``ξ_i ∈ [-1, 1]`` for all ``i = 1, …, p`` such that
``x-c = Gξ`` holds.
"""
function (x::AbstractVector, Z::AbstractZonotope; solver=nothing)
@assert length(x) == dim(Z)

p, n = ngens(Z), dim(Z)
N = promote_type(eltype(x), eltype(Z))
# (n+1) x (p+1) matrix with block-diagonal blocks 1 and genmat(Z)
A = [[one(N); zeros(N, p)]'; [zeros(N, n) genmat(Z)]]
b = [zero(N); (x - center(Z))]
lbounds = [zero(N); fill(-one(N), p)]
ubounds = [N(Inf); ones(N, p)]
sense = ['>'; fill('=', n)]
obj = [one(N); zeros(N, p)]
A = genmat(Z)
sense = '='
b = x .- center(Z)
lbounds = -one(N)
ubounds = one(N)
obj = zeros(N, p)

if isnothing(solver)
solver = default_lp_solver(N)
Expand Down

2 comments on commit bb1804d

@schillic
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/83087

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.7.5 -m "<description of version>" bb1804df18da22369f4db609a0e3802baa1ccf19
git push origin v2.7.5

Please sign in to comment.