Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates for MPB 0.4; drop Julia 0.3 #28

Merged
merged 2 commits into from
Nov 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 6 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ linprogsolvertest(GLPKSolverLP())
include(joinpath(mathprogbase_test, "mixintprog.jl"))
mixintprogtest(GLPKSolverMIP())

lpm = GLPKInterfaceLP.model(GLPKSolverLP(it_lim=9513, tol_bnd=4.149))
include(joinpath(mathprogbase_test,"conicinterface.jl"))
coniclineartest(GLPKSolverLP())
coniclineartest(GLPKSolverMIP())

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