Skip to content

Commit

Permalink
Merge 48b0aa2 into dddee40
Browse files Browse the repository at this point in the history
  • Loading branch information
oyamad committed Nov 25, 2018
2 parents dddee40 + 48b0aa2 commit 7776472
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
julia 0.7
BinDeps
MathProgBase 0.6
Polyhedra 0.4 0.5
Polyhedra 0.4.4 0.5
@windows WinRPM
@osx Homebrew
8 changes: 8 additions & 0 deletions src/mathprogbase.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using SparseArrays

export CDDPolyhedraModel, CDDSolver

mutable struct CDDPolyhedraModel <: Polyhedra.AbstractPolyhedraModel
Expand Down Expand Up @@ -29,6 +31,12 @@ end
function Polyhedra.PolyhedraModel(s::CDDSolver)
CDDPolyhedraModel(s.solver_type, s.exact, nothing, :Undefined, 0, [], [], [], [])
end

function Polyhedra.PolyhedraToLPQPBridge(lpm::CDDPolyhedraModel)
T = lpm.exact ? Rational{BigInt} : Float64
Polyhedra.PolyhedraToLPQPBridge(lpm, sparse(Int[],Int[],T[]), T[], T[], T[], T[], T[], :Min, nothing, nothing)
end

MPB.LinearQuadraticModel(s::CDDSolver) = Polyhedra.PolyhedraToLPQPBridge(Polyhedra.PolyhedraModel(s))

function MPB.loadproblem!(lpm::CDDPolyhedraModel, rep::HRep, obj, sense)
Expand Down
18 changes: 18 additions & 0 deletions test/mathprogbase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,21 @@ linprogsolvertest(CDDSolver(; solver_type=:DualSimplex, exact=true))

linprogsolvertest(CDDSolver(; solver_type=:CrissCross))
linprogsolvertest(CDDSolver(; solver_type=:CrissCross, exact=true))

# Issue #31
@testset "CDDSolver: exact solution" begin
A = [7//3 1//3]
sense = '<'
b = 1//2
c = [-1//1, 0]

val = -3//14
x = [3//14, 0//1]

for solver_type in [:DualSimplex, :CrissCross]
lp_solver = CDDSolver(solver_type=solver_type, exact=true)
sol = MathProgBase.linprog(c, A, '<', b, lp_solver)
@test sol.objval == val
@test sol.sol == x
end
end

0 comments on commit 7776472

Please sign in to comment.