JuliaPolyhedra / Polyhedra.jl

Polyhedral Computation Interface
Other
174 stars 27 forks source link

First time execution of `polyhedron` extremely slow with Julia 0.7 #110

Closed oyamad closed 6 years ago

oyamad commented 6 years ago

It takes more than 5 minutes (on OS X):

using Polyhedra
A = [1. 1; 1 -1; -1 0]
b = [1, 0, 0]
rep = hrep(A, b)
plib = default_library(FullDim{2}(), Float64)
polyhedron(rep, plib)
julia> versioninfo()
Julia Version 0.7.0
Commit a4cb80f3ed (2018-08-08 06:46 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)
blegat commented 6 years ago

I tested in the REPL, it is the last line that takes all the time:

polyhedron(rep, plib)

All this time seem to be only compilation as when I execute it again it is instantaneous.

oyamad commented 6 years ago

The command polyhedron(rep, plib); runs fast (even at the first time) if I replace the Nullable{T}s in https://github.com/JuliaPolyhedra/Polyhedra.jl/blob/b915c05123a563cb25a3f02ffdaf4510f34c194d/src/simplepolyhedron.jl#L18-L20

with Union{T, Nothing} (where T = HRepT, VRepT).

If I execute polyhedron(rep, plib) without ;, I get the error

Error showing value of type SimplePolyhedron{2,Float64,MixedMatHRep{2,Float64,Array{Float64,2}},MixedMatVRep{2,Float64,Array{Float64,2}}}:
ERROR: MethodError: no method matching get(::MixedMatHRep{2,Float64,Array{Float64,2}})

where get is called in https://github.com/JuliaPolyhedra/Polyhedra.jl/blob/b915c05123a563cb25a3f02ffdaf4510f34c194d/src/simplepolyhedron.jl#L85-L90

oyamad commented 6 years ago

With the current master, the following runs instantaneously:

using Polyhedra
A = [1. 1; 1 -1; -1 0]
b = [1, 0, 0]
rep = hrep(A, b)
plib = default_library(FullDim{2}(), Float64)
p = polyhedron(rep, plib);

(note the ; in the last line).

Then just

p

takes minutes. (Maybe the above comment on Nullable versus Union is irrelevant.)

What is called just by p? Is it display?

oyamad commented 6 years ago

Now it seems that it is points(p) that is extremely slow in compilation, which is defined in https://github.com/JuliaPolyhedra/Polyhedra.jl/blob/6007ee78748d2a41b708def2eb6a9e4c0b693808/src/iterators.jl#L79-L168

blegat commented 6 years ago

Is that still the case now that https://github.com/JuliaPolyhedra/Polyhedra.jl/pull/114 has been merged ?

oyamad commented 6 years ago

Yes, points(p) is still very slow even on the current master.

blegat commented 6 years ago

@oyamad Can you check whether this is still the case on master or whether it has been resolved ? master should now work on Julia v1.0 with JuMP at branch release-0.18 except for the bug https://github.com/JuliaPolyhedra/Polyhedra.jl/issues/123

oyamad commented 6 years ago

@blegat Thanks. Yes, the issue has been resolved by #122!