Build Status |
---|
GLPK.jl is a wrapper for the GNU Linear Programming Kit library. It makes it possible to access nearly all of GLPK functionality from within Julia programs.
This package is part of the JuliaOpt project.
The package is registered in the General registry and so can be installed with Pkg.add
.
julia> import Pkg
julia> Pkg.add("GLPK")
GLPK.jl will use BinaryProvider.jl to automatically install the GLPK binaries with GMP support.
To install custom built GLPK binaries set the environmental variable JULIA_GLPK_LIBRARY_PATH
and call import Pkg; Pkg.build("GLPK")
. For instance, if the libraries are installed in /opt/lib
just call
ENV["JULIA_GLPK_LIBRARY_PATH"]="/opt/lib"
Pkg.build("GLPK")
If you do not want BinaryProvider to download the default binaries on install set JULIA_GLPK_LIBRARY_PATH
before calling import Pkg; Pkg.add("GLPK")
.
To switch back to the default binaries clear JULIA_GLPK_LIBRARY_PATH
and call import Pkg; Pkg.build("GLPK")
.
Use GLPK.Optimizer
to create a new optimizer object:
using GLPK
model = GLPK.Optimizer(tm_lim = 60.0, msg_lev = GLPK.OFF)
For JuMP, use:
using JuMP, GLPK
model = Model(
with_optimizer(GLPK.Optimizer, tm_lim = 60.0, msg_lev = GLPK.OFF)
)
Note: previous versions of GLPK.jl
required you to choose either GLPKSolverLP
or GLPKSolverMIP
. This is no longer needed; just use GLPK.Optimizer
.
GLPK.jl
has a lot of pre-emptive checks to catch cases where the C API might
throw an uninformative error. However, in benchmarks, this takes a
non-negligible amount of time (e.g. 20% in add_constraints). At the risk of
possibly running into an uninformative error, you can run the following after
importing GLPK to disable these checks:
using GLPK
GLPK.jl_set_preemptive_check(false)