• Stars
    star
    101
  • Rank 338,289 (Top 7 %)
  • Language
    Julia
  • License
    Other
  • Created over 11 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Julia interface to the GNU Linear Programming Kit

GLPK.jl

Build Status codecov

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

The wrapper has two components:

Affiliation

This wrapper is maintained by the JuMP community and is not an GNU project.

License

GLPK.jl is licensed under the GPL v3 license.

Installation

Install GLPK using Pkg.add:

import Pkg
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.

To use a custom binary, read the Custom solver binaries section of the JuMP documentation.

Use with JuMP

To use GLPK with JuMP, use GLPK.Optimizer:

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

If the model is primal or dual infeasible, GLPK will attempt to find a certificate of infeasibility. This can be expensive, particularly if you do not intend to use the certificate. If this is the case, use:

model = Model(() -> GLPK.Optimizer(; want_infeasibility_certificates = false))

MathOptInterface API

The GLPK optimizer supports the following constraints and attributes.

List of supported objective functions:

List of supported variable types:

List of supported constraint types:

List of supported model attributes:

Options

Options for GLPK are comprehensively documented in the PDF documentation, but they are hard to find.

  • Options when solving a linear program are defined in Section 2.8.1
  • Options when solving a mixed-integer program are defined in Section 2.10.5

However, the following options are likely to be the most useful:

Parameter Example Explanation
msg_lev GLPK.GLP_MSG_ALL Message level for terminal output
presolve GLPK.GLP_ON Turn presolve on or off
tol_int 1e-5 Absolute tolerance for integer feasibility
tol_obj 1e-7 Relative objective tolerance for mixed-integer programs

Callbacks

Here is an example using GLPK's solver-specific callbacks.

using JuMP, GLPK, Test

model = Model(GLPK.Optimizer)
@variable(model, 0 <= x <= 2.5, Int)
@variable(model, 0 <= y <= 2.5, Int)
@objective(model, Max, y)
reasons = UInt8[]
function my_callback_function(cb_data)
    reason = GLPK.glp_ios_reason(cb_data.tree)
    push!(reasons, reason)
    if reason != GLPK.GLP_IROWGEN
        return
    end
    x_val = callback_value(cb_data, x)
    y_val = callback_value(cb_data, y)
    if y_val - x_val > 1 + 1e-6
        con = @build_constraint(y - x <= 1)
        MOI.submit(model, MOI.LazyConstraint(cb_data), con)
    elseif y_val + x_val > 3 + 1e-6
        con = @build_constraint(y - x <= 1)
        MOI.submit(model, MOI.LazyConstraint(cb_data), con)
    end
end
MOI.set(model, GLPK.CallbackFunction(), my_callback_function)
optimize!(model)
@test termination_status(model) == MOI.OPTIMAL
@test primal_status(model) == MOI.FEASIBLE_POINT
@test value(x) == 1
@test value(y) == 2
@show reasons

C API

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.

Thread safety

GLPK is not thread-safe and should not be used with multithreading.

More Repositories

1

JuMP.jl

Modeling language for Mathematical Optimization (linear, mixed-integer, conic, semidefinite, nonlinear)
Julia
2,221
star
2

Convex.jl

A Julia package for disciplined convex programming
Julia
567
star
3

MathOptInterface.jl

A data structure for mathematical optimization problems
Julia
392
star
4

NLopt.jl

A Julia interface to the NLopt nonlinear-optimization library
Julia
262
star
5

Gurobi.jl

A Julia interface to the Gurobi Optimizer
Julia
220
star
6

Ipopt.jl

A Julia interface to the Ipopt nonlinear solver
Julia
152
star
7

JuMPTutorials.jl

Tutorials on using JuMP for mathematical optimization in Julia
Jupyter Notebook
142
star
8

Hypatia.jl

interior point solver for general convex conic optimization problems
Julia
140
star
9

CPLEX.jl

A Julia interface to the CPLEX solver
Julia
134
star
10

Pajarito.jl

A solver for mixed-integer convex optimization
Julia
130
star
11

DiffOpt.jl

Differentiating convex optimization programs w.r.t. program parameters
Julia
122
star
12

SumOfSquares.jl

Sum of Squares Programming for Julia
Julia
116
star
13

HiGHS.jl

A Julia interface to the HiGHS solver
Julia
108
star
14

Dualization.jl

Automatic dualization feature for MathOptInterface.jl
Julia
95
star
15

SCS.jl

A Julia interface for the SCS conic programming solver
Julia
81
star
16

Cbc.jl

A Julia interface to the Coin-OR Branch and Cut solver (CBC)
Julia
81
star
17

KNITRO.jl

A Julia interface to the Artelys Knitro solver
Julia
77
star
18

Xpress.jl

A Julia interface to the FICO Xpress Optimization suite
Julia
65
star
19

AmplNLWriter.jl

A Julia interface to AMPL-enabled solvers
Julia
65
star
20

MultiObjectiveAlgorithms.jl

A Julia package for solving multi-objective optimization problems
Julia
62
star
21

Pavito.jl

A gradient-based outer approximation solver for convex mixed-integer nonlinear programming (MINLP)
Julia
60
star
22

Clp.jl

A Julia interface to the Coin-OR Linear Programming solver (CLP)
Julia
54
star
23

PiecewiseLinearOpt.jl

Solve optimization problems containing piecewise linear functions
Julia
53
star
24

MutableArithmetics.jl

Interface for arithmetics on mutable types in Julia
TeX
49
star
25

ECOS.jl

A Julia interface to the ECOS conic optimization solver
Julia
41
star
26

PolyJuMP.jl

A JuMP extension for Polynomial Optimization
Julia
41
star
27

ParametricOptInterface.jl

Extension for dealing with parameters
Julia
36
star
28

NEOSServer.jl

A Julia interface for the NEOS Optimisation Server
Julia
31
star
29

MosekTools.jl

A MathOptInterface.jl interface to the MOSEK solver
Julia
29
star
30

CSDP.jl

A Julia interface to the Coin-OR solver CSDP
Julia
21
star
31

benchmarks

A repository for long-term benchmarking of JuMP performance
Julia
19
star
32

MathOptFormat

Specification and description of the MathOptFormat file format
Python
18
star
33

MiniZinc.jl

A Julia interface to the MiniZinc constraint modeling language
Julia
18
star
34

BARON.jl

A Julia interface to the BARON mixed-integer nonlinear programming solver
Julia
18
star
35

jump-dev.github.io

Source for jump.dev
Jupyter Notebook
14
star
36

open-energy-modeling-benchmarks

Julia
13
star
37

MINLPTests.jl

Unit and Integration Tests for JuMP NLP and MINLP solvers
Julia
12
star
38

SDPA.jl

A Julia interface to the SDPA semidefinite programming solver
Julia
11
star
39

MatrixOptInterface.jl

An interface to pass matrix form problems
Julia
11
star
40

SDPNAL.jl

A Julia interface to the SDPNAL+ solver
Julia
11
star
41

ComplexOptInterface.jl

Extension of MathOptInterface to complex sets
Julia
8
star
42

SDPLR.jl

Julia wrapper for SDPLR
Julia
7
star
43

Penopt.jl

A Julia interface to the Penopt SDP solver
Julia
7
star
44

SolverTests

Test that all solvers pass the tests before a new MOI release
7
star
45

SeDuMi.jl

A Julia interface to the SeDuMi SDP solver
Julia
6
star
46

SDPT3.jl

A Julia interface to the SDPT3 solver
Julia
5
star
47

DSDP.jl

A Julia interface to the DSDP semidefinite programming solver
Julia
4
star
48

GSOC2021

GSOC2021 information for JuMP
3
star
49

JuMPPaperBenchmarks

Benchmarks for a paper on JuMP 1.0
Julia
2
star
50

Gurobi_jll.jl

A Julia package for installing the Gurobi Optimizer
Julia
2
star
51

MOIPaperBenchmarks

Benchmarks for a paper on MathOptInterface
Julia
1
star
52

GSOC2022

GSOC2022 information for JuMP
1
star
53

HiGHSBuilder

Julia
1
star
54

GSOC2020

GSOC2020 information for JuMP
1
star
55

GSOC

1
star