Skip to content

Latest commit

 

History

History
75 lines (53 loc) · 2.86 KB

README.md

File metadata and controls

75 lines (53 loc) · 2.86 KB

GLPK.jl

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.

Installation

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.

Custom Installation

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").

GLPK.Optimizer

Use GLPK.Optimizer to create a new optimizer object:

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

using GLPK
model = GLPK.Optimizer(tm_lim = 60000, msg_lev = GLPK.OFF)

For JuMP, use:

using JuMP, GLPK
model = Model(
    with_optimizer(GLPK.Optimizer, tm_lim = 60000, 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.

Pre-emptive checks

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)