Skip to content

Commit 46d7253

Browse files
authored
Merge pull request #159 from JuliaPolyhedra/bl/typed_default_solver
Add type parameter to default_solver
2 parents c2e88b2 + 8c6c5fd commit 46d7253

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/center.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using JuMP
77
Return a tuple with the center and radius of the largest euclidean ball contained in the polyhedron `p`.
88
Throws an error if the polyhedron is empty or if the radius is infinite.
99
"""
10-
function hchebyshevcenter(p::HRep, solver=Polyhedra.default_solver(p))
10+
function hchebyshevcenter(p::HRep, solver=Polyhedra.default_solver(p; T=Float64)) # Need Float64 for `norm(a, 2)`
1111
model = JuMP.Model(solver)
1212
c = JuMP.@variable(model, [1:fulldim(p)])
1313
for hp in hyperplanes(p)
@@ -61,12 +61,12 @@ end
6161
6262
If `p` is a H-representation or is a polyhedron for which the H-representation has already been computed, calls `hchebyshevcenter`, otherwise, call `vchebyshevcenter`.
6363
"""
64-
function chebyshevcenter(p::Polyhedron, solver=Polyhedra.default_solver(p))
64+
function chebyshevcenter(p::Polyhedron, solver=Polyhedra.default_solver(p; T=Float64))
6565
if hrepiscomputed(p)
6666
hchebyshevcenter(p, solver)
6767
else
6868
vchebyshevcenter(p, solver)
6969
end
7070
end
71-
chebyshevcenter(p::HRepresentation, solver=Polyhedra.default_solver(p)) = hchebyshevcenter(p, solver)
72-
chebyshevcenter(p::VRepresentation, solver=Polyhedra.default_solver(p)) = vchebyshevcenter(p, solver)
71+
chebyshevcenter(p::HRepresentation, solver=Polyhedra.default_solver(p; T=Float64)) = hchebyshevcenter(p, solver)
72+
chebyshevcenter(p::VRepresentation, solver=Polyhedra.default_solver(p; T=Float64)) = vchebyshevcenter(p, solver)

src/default.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ function library end
7474
7575
Returns a default linear programming solver for the polyhedron `p` (e.g. CDD has an internal solver which is used by default).
7676
"""
77-
default_solver(p::Rep) = nothing
78-
function default_solver(p::Rep, ps::Rep...)
79-
s = default_solver(p)
77+
default_solver(p::Rep; kws...) = nothing
78+
function default_solver(p::Rep, ps::Rep...; kws...)
79+
s = default_solver(p; kws...)
8080
if s === nothing
81-
return default_solver(ps...)
81+
return default_solver(ps...; kws...)
8282
else
8383
return s
8484
end

src/defaultlibrary.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ end
3838

3939
FullDim(p::DefaultPolyhedron) = FullDim_rep(p.hrep, p.vrep)
4040
library(::Union{DefaultPolyhedron{T}, Type{<:DefaultPolyhedron{T}}}) where {T} = DefaultLibrary{T}()
41-
default_solver(p::DefaultPolyhedron) = p.solver
41+
default_solver(p::DefaultPolyhedron; T = nothing) = p.solver
4242
supportssolver(::Type{<:DefaultPolyhedron}) = true
4343

4444
hvectortype(::Type{<:DefaultPolyhedron{T, HRepT}}) where {T, HRepT} = hvectortype(HRepT)

0 commit comments

Comments
 (0)