You can use incidentpoints to simplify the code.
CDD computes the incidence information and incidentpoints just retrieve this information. In your code sample, you recompute it.
using Polyhedra, CDDLib, JuMP, Statistics
model = Model()
@variables(model, begin
x
y
end)
@constraints(model, begin
0 <= x <= 1.0
0 <= y <= 1.0
x <= y
end)
print(model)
poly = polyhedron(model, CDDLib.Library())
removehredundancy!(poly)
barycenters = [mean(incidentpoints(poly, hidx)) for hidx in eachindex(halfspaces(poly))]
I get the output
Feasibility
Subject to
x - y ≤ 0.0
x ∈ [0.0, 1.0]
y ∈ [0.0, 1.0]
3-element Array{Array{Float64,1},1}:
[0.5, 0.5]
[0.0, 0.5]
[0.5, 1.0]
Also: try to avoid things like hcat(points( vrep( poly ) )...) or vcat( barycenters... ). If you have millions of points, it will compile a hcat or vcat with millions of arguments which will be quite slow to compile !