Skip to content

Commit

Permalink
updates for MPB 0.4; drop Julia 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Nov 29, 2015
1 parent 063f7b9 commit 84a1329
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 24 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ os:
- linux
- osx
julia:
- 0.3
- 0.4
- nightly
env:
Expand Down
5 changes: 2 additions & 3 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
julia 0.3
julia 0.4
GLPK 0.2.8
MathProgBase 0.3.0 0.4.0-
Compat 0.7.1
MathProgBase 0.4.0 0.5.0-
4 changes: 1 addition & 3 deletions src/GLPKInterfaceBase.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module GLPKInterfaceBase

using Compat

import GLPK

importall MathProgBase.SolverInterface
Expand Down Expand Up @@ -31,7 +29,7 @@ export
getrawsolver


abstract GLPKMathProgModel <: AbstractMathProgModel
abstract GLPKMathProgModel <: AbstractLinearQuadraticModel

function loadproblem!(lpm::GLPKMathProgModel, filename::AbstractString)
if endswith(filename, ".mps") || endswith(filename, ".mps.gz")
Expand Down
7 changes: 2 additions & 5 deletions src/GLPKInterfaceLP.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
module GLPKInterfaceLP

using Compat

import GLPK
importall MathProgBase.SolverInterface
importall ..GLPKInterfaceBase

export
GLPKSolverLP,
model,
optimize!,
loadproblem!,
writeproblem,
Expand Down Expand Up @@ -39,7 +36,7 @@ export
getinfeasibilityray,
getunboundedray

@compat type GLPKMathProgModelLP <: GLPKMathProgModel
type GLPKMathProgModelLP <: GLPKMathProgModel
inner::GLPK.Prob
method::Symbol
param::Union{GLPK.SimplexParam, GLPK.InteriorParam}
Expand All @@ -61,7 +58,7 @@ type GLPKSolverLP <: AbstractMathProgSolver
end
end

function model(s::GLPKSolverLP)
function LinearQuadraticModel(s::GLPKSolverLP)
if s.method == :Simplex || s.method == :Exact
param = GLPK.SimplexParam()
if s.presolve
Expand Down
17 changes: 7 additions & 10 deletions src/GLPKInterfaceMIP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import GLPK
importall MathProgBase.SolverInterface
importall ..GLPKInterfaceBase

using Compat

export
GLPKSolverMIP,
GLPKCallbackData,
model,
optimize!,
loadproblem!,
writeproblem,
Expand Down Expand Up @@ -51,7 +48,7 @@ export
cbaddcut!,
cbaddsolution

@compat type GLPKMathProgModelMIP <: GLPKMathProgModel
type GLPKMathProgModelMIP <: GLPKMathProgModel
inner::GLPK.Prob
param::GLPK.IntoptParam
smplxparam::GLPK.SimplexParam
Expand Down Expand Up @@ -168,7 +165,7 @@ function _internal_callback(tree::Ptr{Void}, info::Ptr{Void})
return
end

function model(s::GLPKSolverMIP)
function LinearQuadraticModel(s::GLPKSolverMIP)
lpm = GLPKMathProgModelMIP()
lpm.param.msg_lev = GLPK.MSG_ERR
lpm.smplxparam.msg_lev = GLPK.MSG_ERR
Expand Down Expand Up @@ -203,10 +200,10 @@ function model(s::GLPKSolverMIP)
return lpm
end

@compat setlazycallback!(m::GLPKMathProgModel, f::Union{Function,Void}) = (m.lazycb = f)
@compat setcutcallback!(m::GLPKMathProgModel, f::Union{Function,Void}) = (m.cutcb = f)
@compat setheuristiccallback!(m::GLPKMathProgModel, f::Union{Function,Void}) = (m.heuristiccb = f)
@compat setinfocallback!(m::GLPKMathProgModel, f::Union{Function,Void}) = (m.infocb = f)
setlazycallback!(m::GLPKMathProgModel, f::Union{Function,Void}) = (m.lazycb = f)
setcutcallback!(m::GLPKMathProgModel, f::Union{Function,Void}) = (m.cutcb = f)
setheuristiccallback!(m::GLPKMathProgModel, f::Union{Function,Void}) = (m.heuristiccb = f)
setinfocallback!(m::GLPKMathProgModel, f::Union{Function,Void}) = (m.infocb = f)

_check_tree(d::GLPKCallbackData, funcname::AbstractString) =
(d.tree != C_NULL && d.reason != -1) || error("$funcname can only be called from within a callback")
Expand Down Expand Up @@ -396,7 +393,7 @@ function setvartype!(lpm::GLPKMathProgModelMIP, vartype::Vector{Symbol})
end
end

@compat const vartype_map = Dict(
const vartype_map = Dict(
GLPK.CV => :Cont,
GLPK.IV => :Int,
GLPK.BV => :Bin
Expand Down
5 changes: 5 additions & 0 deletions src/GLPKMathProgInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ include("GLPKInterfaceMIP.jl")
const GLPKSolverLP = GLPKInterfaceLP.GLPKSolverLP
const GLPKSolverMIP = GLPKInterfaceMIP.GLPKSolverMIP

# Enables GLPK to act as a conic solver
import MathProgBase
MathProgBase.ConicModel(s::Union{GLPKSolverLP,GLPKSolverMIP}) = MathProgBase.LPQPtoConicBridge(MathProgBase.LinearQuadraticModel(s))
MathProgBase.supportedcones(::Union{GLPKSolverLP,GLPKSolverMIP}) = [:Free,:Zero,:NonNeg,:NonPos]

end
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ linprogsolvertest(GLPKSolverLP())
include(joinpath(mathprogbase_test, "mixintprog.jl"))
mixintprogtest(GLPKSolverMIP())

lpm = GLPKInterfaceLP.model(GLPKSolverLP(it_lim=9513, tol_bnd=4.149))
lpm = GLPKInterfaceLP.LinearQuadraticModel(GLPKSolverLP(it_lim=9513, tol_bnd=4.149))
@test lpm.param.it_lim == 9513
@test lpm.param.tol_bnd == 4.149
mipm = GLPKInterfaceMIP.model(GLPKSolverMIP(it_lim=5910, tol_obj=1.52e-3))
mipm = GLPKInterfaceMIP.LinearQuadraticModel(GLPKSolverMIP(it_lim=5910, tol_obj=1.52e-3))
@test mipm.smplxparam.it_lim == 5910
@test mipm.param.tol_obj == 1.52e-3

0 comments on commit 84a1329

Please sign in to comment.