GLPK wrapper module for Julia



Build Status

GLPK.jl is a wrapper for the GNU Linear Programming Kit library.

It has two components:

The C API can be accessed via GLPK.glp_XXX functions, where the names and arguments are identical to the C API. See the /tests folder for inspiration.


The package is registered in the General registry and so can be installed with Pkg.add.

julia> import Pkg

julia> Pkg.add("GLPK")

In addition to installing the GLPK.jl package, this will also download and install the GLPK binaries. (You do not need to install GLPK separately.) If you require a custom build of GLPK, see the "Custom Installation" instructions below.

Custom Installation

To install custom built GLPK binaries set the environmental variable JULIA_GLPK_LIBRARY_PATH and call import Pkg; Pkg.build("GLPK"). For example, if the libraries are installed in /opt/lib just call:


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 for use with MathOptInterface or JuMP.

In the following examples the time limit is set to one minute and logging is turned off.

using GLPK
model = GLPK.Optimizer()
MOI.set(model, MOI.RawParameter("tm_lim"), 60_000) #  tm_lim is in milliseconds.
MOI.set(model, MOI.RawParameter("msg_lev"), GLPK.GLP_MSG_OFF)

For JuMP, use:

using JuMP, GLPK
model = Model(GLPK.Optimizer)
set_optimizer_attribute(model, "tm_lim", 60 * 1_000)
set_optimizer_attribute(model, "msg_lev", GLPK.GLP_MSG_OFF)

First Commit


Last Touched

3 days ago


245 commits