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

Volume of H-represenation #191

Open
JohnEdChristensen opened this issue Jan 22, 2020 · 2 comments
Open

Volume of H-represenation #191

JohnEdChristensen opened this issue Jan 22, 2020 · 2 comments

Comments

@JohnEdChristensen
Copy link

JohnEdChristensen commented Jan 22, 2020

I'm having difficulty finding the volume of an H-rep

using Polyhedra, QHull
cube = HalfSpace([0,0,1],1)HalfSpace([0,0,-1],0)HalfSpace([0,1,0],1)HalfSpace([0,-1,0],0)HalfSpace([1,0,0],1)HalfSpace([-1,0,0],0)
p = polyhedron(cube,QHull.Library())
Polyhedra.volume(p)

This throws the following error:

MethodError: no method matching JuMP.Model(::Nothing)
Closest candidates are:
  JuMP.Model(::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any) at /home/john/.julia/packages/JuMP/MsUSY/src/JuMP.jl:126
  JuMP.Model(; caching_mode, solver) at /home/john/.julia/packages/JuMP/MsUSY/src/JuMP.jl:163
  JuMP.Model(!Matched::MathOptInterface.AbstractOptimizer, !Matched::Dict{MathOptInterface.ConstraintIndex,JuMP.AbstractShape}, !Matched::Set{Any}, !Matched::Any, !Matched::Any, !Matched::Dict{Symbol,Any}, !Matched::Int64, !Matched::Dict{Symbol,Any}) at /home/john/.julia/packages/JuMP/MsUSY/src/JuMP.jl:126

What would be the correct way of getting the volume?

@JohnEdChristensen
Copy link
Author

JohnEdChristensen commented Jan 22, 2020

I was able to make it work by converting to a vrep using the doubledescription function:

using Polyhedra, QHull
cube = HalfSpace([0,0,1],1)HalfSpace([0,0,-1],0)HalfSpace([0,1,0],1)HalfSpace([0,-1,0],0)HalfSpace([1,0,0],1)HalfSpace([-1,0,0],0)
vcube = doubledescription(cube)
p = polyhedron(vcube,QHull.Library())
Polyhedra.volume(p)

Shouldn't you be able to calculate the volume directly from the hrep?

@blegat
Copy link
Member

blegat commented Jan 23, 2020

What would be the correct way of getting the volume?

The error message should be improved, the issue is that if the origin is not in the interior of the polytope, QHull won't work (since QHull takes a V-Rep so we need to transform the H-Rep to a V-Rep by taking the polar, which requires the origin to be in the interior). So we solve an LP to find the chebyshev center and shift the polytope by this center so that the chebyshev center of the shifted polytope is the origin. Solving this LP requires an LP solver but you did not provide any solver to QHull. You need to do for instance

using JuMP
lib = QHull.Library(with_optimizer(GLPK.Optimizer))

Shouldn't you be able to calculate the volume directly from the hrep?

QHull takes a V-Rep as input and gives as output the H-Rep and the volume. What we do is take a H-Rep, give the V-Rep of the polar to QHull which gives the H-Rep of the polar and the volume of the polar that we transform back into V-Rep and volume of the original polytope. I am not aware of a direct way to obtain the volume with QHull from the H-Rep.

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

No branches or pull requests

2 participants