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

Using constrainst in Zonotope -> HPolytope conversion #1154

Closed
mforets opened this issue Feb 24, 2019 · 1 comment
Closed

Using constrainst in Zonotope -> HPolytope conversion #1154

mforets opened this issue Feb 24, 2019 · 1 comment
Labels
duplicate 2️⃣ This issue or pull request already exists

Comments

@mforets
Copy link
Member

mforets commented Feb 24, 2019

julia> using Test, Revise, LazySets, LinearAlgebra
julia> N = Float64;

julia> Z = Zonotope(zeros(N, 3), Matrix(N(1)*I, 3, 3))
Zonotope{Float64}([0.0, 0.0, 0.0], [1.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 1.0])

julia> B = BallInf(zeros(N, 3), N(1)) # equivalent to Z
BallInf{Float64}([0.0, 0.0, 0.0], 1.0)

julia> @which convert(HPolytope, Z)
convert(::Type{HPolytope}, P::AbstractPolytope) in LazySets at /Users/forets/.julia/dev/LazySets/src/convert.jl:147

But it is in general more efficient to do HPolytope(constraints_list(Z)); i.e. use the HPolyhedron implementation:

function convert(::Type{HPolytope}, P::AbstractPolytope)
    return convert(HPolytope, convert(VPolytope, P))
end

function convert(::Type{HPolyhedron}, P::AbstractPolytope)
    return HPolyhedron(constraints_list(P))
end

Should we add a specific method

function convert(::Type{HPolytope}, Z::Zonotope)
    return HPolytope(constraints_list(Z))
end

More generally, should we add a kwarg to convert such that it allows to choose the implementation?

@schillic
Copy link
Member

Duplicate of #932.

@schillic schillic added the duplicate 2️⃣ This issue or pull request already exists label Feb 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate 2️⃣ This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants