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

#375 - Intersection of a halfspace with polyhedron: line search method #677

Merged
merged 12 commits into from
Sep 28, 2018

Conversation

mforets
Copy link
Member

@mforets mforets commented Sep 26, 2018

Closes #375.

@mforets
Copy link
Member Author

mforets commented Sep 27, 2018

Some examples:

using LazySets, Optim, Compat
p = Ball2(zeros(2), 1.0)
h = HalfSpace([1.0, 1.0], 0.0) # x + y <= 0

plot(p, aspectratio=1, alpha=0.2, 1e-3)
plot!(p  h, 1e-3, aspectratio=1, alpha=0.2, color="red")

screen shot 2018-09-27 at 11 53 02

@mforets
Copy link
Member Author

mforets commented Sep 27, 2018

This one seems wrong, but i don't know why:

p = VPolygon([rand(2) for i in 1:8])
plot(p, aspectratio=1, alpha=0.2, 1e-3)
h = HalfSpace([1.0, 0.0], 0.5) # x <= 0.5
plot!(p  h, 1e-3, aspectratio=1, alpha=0.2, color="red")

screen shot 2018-09-27 at 12 05 09

@schillic
Copy link
Member

How come that σ is defined for you? I can only plot the box approximation.

@mforets
Copy link
Member Author

mforets commented Sep 27, 2018

sorry, i forgot to push that part. just a second.

@mforets
Copy link
Member Author

mforets commented Sep 27, 2018

do you agree about my definition of σ?

@mforets
Copy link
Member Author

mforets commented Sep 27, 2018

Hmm it is not a problem with VPolygon. Here is a similar error (i only get the overapproximation) using a Ball2:

p = Ball2(ones(2), 1.0)
plot(p, aspectratio=1, alpha=0.2, 1e-3)
h = HalfSpace([1.0, 0.0], 1.0) # x <= 1
plot!(p  h, 1e-3, aspectratio=1, alpha=0.2, color="red")

screen shot 2018-09-27 at 13 04 01

@mforets
Copy link
Member Author

mforets commented Sep 27, 2018

Here i get

julia> σ([1., 1], ph)
2-element Array{Float64,1}:
 1.5
 1.5

but i think it should be [1.0, 2.0].

Also

julia> σ([-1., 1], ph)
2-element Array{Float64,1}:
 -0.707107
  0.707107

gives a point which does not belong to p.

@mforets
Copy link
Member Author

mforets commented Sep 27, 2018

ok the problem is that σ does not work like ρ(ℓvec, cap) * ℓvec in general, since this condition is not sufficient for the point to belong to the set p. ...

for instance to test that the support function is correct, consider the same example but using template directions (which evaluates the supp func) instead of iterative refinement (which evaluates the supp vector):

using LazySets.Approximations

p = Ball2(ones(2), 1.0)
h = HalfSpace([1.0, 0.0], 1.0) # x <= 1
pint = overapproximate(ph, BoxDiagDirections(2))
pint = convert(HPolygon, pint)

plot(p, aspectratio=1, alpha=0.2, 1e-3)
plot!(pint, aspectratio=1, alpha=0.2, color="red")

screen shot 2018-09-27 at 14 07 34

@schillic
Copy link
Member

ok the problem is that σ does not work like ρ(ℓvec, cap) * ℓvec in general, since this condition is not sufficient for the point to belong to the set p. ...

Yes, this does not work in general.

julia> b = BallInf([0., 0.], 1.); d = [1., 0.5];

julia> ρ(d, b)
1.5

julia> ρ(d, b) * d
2-element Array{Float64,1}:
 1.5 
 0.75

julia> ρ(d, b) * d  b
false

julia> σ(d, b)
2-element Array{Float64,1}:
 1.0
 1.0

@mforets
Copy link
Member Author

mforets commented Sep 27, 2018

Yes, thanks for checking. I don't have a formula for the support vector, so i propose to move on with the computation of supp func for now.

It remains to add a add a unit test and the function to the docs. Regarding the Optim package, shall we do something similar to what is done in function load_polyhedra() ? Where do i get the number in

function __init__()
    @require Polyhedra = "67491407-f73d-577b-9b50-8179a7c68029" load_polyhedra()
    @require Optim = "????" load_optim()
end

The theorem on f(λ) can be found in Rockafellar's Variational Anaysis. I'd like to check there, i suspect one can extract the point in the set from the minimizer..

@schillic
Copy link
Member

schillic commented Sep 27, 2018

A preliminary idea for the support vector σ(d, p ∩ h): Let x := σ(d, p). Either x ∈ h holds, in which case you can return x, or we know that σ(d, p ∩ h) lies on the hyperplane described by d and ρ(d, p). So you can shift x along that hyperplane until you hit the hyperplane of h. Moving along a hyperplane is not unique, though...

@schillic
Copy link
Member

Where do i get the number

I look it up in .julia/environments/v0.7.

@schillic
Copy link
Member

Do we use "ℓ" for directions now? (I am not against that choice.)

I would also add an option to skip the emptiness check. In practice we want to do that in advance before computing ρ. The name of that option is tricky: A possible name is_known_to_be_nonempty is a bit overkill. Maybe skip_emptiness_check?

@mforets
Copy link
Member Author

mforets commented Sep 27, 2018

Do we use "ℓ" for directions now? (I am not against that choice.)

i was using it because i was following the notation from the paper. but i shall switch back to d.

I would also add an option to skip the emptiness check.

good idea. maybe emptiness_check.

@mforets mforets changed the title [WIP] #375 - Intersection of a halfspace with polyhedron: line search method #375 - Intersection of a halfspace with polyhedron: line search method Sep 28, 2018
@mforets mforets merged commit 6824ccc into master Sep 28, 2018
@mforets mforets deleted the mforets/375 branch September 28, 2018 15:41
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.

Here is my late review 🐌


# Symmetric case
ρ(ℓ::AbstractVector{N}, cap::Intersection{N, <:HalfSpace, <:LazySet};
algorithm::String="line_search", kwargs...) where {N<:AbstractFloat} = ρ(ℓ, cap.Y ∩ cap.X; algorithm=algorithm, kwargs...)
Copy link
Member

Choose a reason for hiding this comment

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

The check_intersection argument is missing here.

MathProgBase 0.7
RecipesBase 0.3
Requires 0.4
Optim 0.14.1
Copy link
Member

Choose a reason for hiding this comment

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

new line


# line search using Optim
using Optim
@test ρ(d, X ∩ H) == ρ(d, X ∩ H) == 1.0
Copy link
Member

Choose a reason for hiding this comment

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

Should the second expression be the symmetric case?

@mforets
Copy link
Member Author

mforets commented Oct 1, 2018

Thanks for the comments. I put them in #681

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