Skip to content

Commit

Permalink
use exact LP solver for integer sets
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Apr 22, 2024
1 parent 06d02cb commit d781867
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Utils/lp_solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ end
end

# default LP solver for rational numbers
@inline function default_lp_solver_factory(::Type{<:Rational})
@inline function default_lp_solver_factory(::Union{Type{<:Rational},Type{Int}})
return JuMP.optimizer_with_attributes(() -> GLPK.Optimizer(; method=GLPK.EXACT))
end

@inline task_local_lp_solver_key(::Type{<:AbstractFloat}) = "LAZYSETS_FLOAT_LP_SOLVER"
@inline task_local_lp_solver_key(::Type{<:Rational}) = "LAZYSETS_EXACT_LP_SOLVER"
@inline task_local_lp_solver_key(::Union{Type{<:Rational},Type{Int}}) = "LAZYSETS_EXACT_LP_SOLVER"

# default LP solver given two possibly different numeric types
@inline function default_lp_solver(M::Type{<:Number}, N::Type{<:Number})
Expand Down
16 changes: 12 additions & 4 deletions test/Utils/lp_solvers.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Check that the default model and explicit solver
# specification works for linprog
# check solver handling
for N in [Float64, Rational{Int}, Int]
LazySets.default_lp_solver(N)
end

# check that the default model and explicit solver specification work for linprog
for N in [Float64]
p = HPolyhedron{N}()
c1 = LinearConstraint(N[2, 2], N(12))
Expand All @@ -15,7 +18,10 @@ for N in [Float64]
P = HPolyhedron([HalfSpace(N[3 // 50, -4 // 10], N(1)),
HalfSpace(N[-1 // 50, 1 // 10], N(-1))])

# With default model
####################
# with default model
####################

# support vector
d = N[1, 0]
@test σ(d, p) == N[4, 2]
Expand All @@ -29,7 +35,9 @@ for N in [Float64]
# an_element
@test an_element(P) P

# With explicit solver
######################
# with explicit solver
######################
solver = optimizer_with_attributes(() -> GLPK.Optimizer(; method=GLPK.SIMPLEX))

# support vector
Expand Down

0 comments on commit d781867

Please sign in to comment.