Julia wrapper for Penopt (
Author jump-dev
7 Stars
Updated Last
1 Year Ago
Started In
August 2019


Penopt.jl is a wrapper for the Penopt Optimizer.

It has two components:

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


This wrapper is maintained by the JuMP community and is not officially supported by Penopt.


Penopt.jl is licensed under the MIT License.

The underlying solver is a closed-source commercial product for which you must purchase a license.


You can install Penopt.jl through the Julia package manager:

] add

then, open a terminal in the directory when Penopt is installed (find this directory by writing using Penopt; pathof(Penopt) in a Julia session).

$ mkdir -p deps/usr/lib
$ cd deps/usr/lib
$ gcc  -Wl,--no-undefined -shared -lm -lgfortran -lopenblas -llapack -o -Wl,--whole-archive /path/to/PENBMI2.1/lib/libpenbmi.a -Wl,--no-whole-archive

This will create a shared library in the directory deps/usr/lib. Then create the following file deps/deps.jl:

import Libdl
const libpenbmi = joinpath(dirname(@__FILE__), "usr/lib/")
function check_deps()
    global libpenbmi
    if !isfile(libpenbmi)
        error("$(libpenbmi) does not exist, Please re-run\"Penopt\"), and restart Julia.")

    if Libdl.dlopen_e(libpenbmi) == C_NULL
        error("$(libpenbmi) cannot be opened, Please re-run\"Penopt\"), and restart Julia.")


You can test the installation with using Pkg; Pkg.test("Penopt") in a Julia session.

Use with JuMP

using JuMP, Penopt
model = Model(Penopt.Optimizer)
set_attribute(model, "PBM_MAX_ITER", 100)
set_attribute(model, "TR_MODE", 1)


See the Penbmi Documentation for a list and description of allowable parameters.

Accessing Penopt-specific attributes via JuMP

You can get and set Penopt-specific attributes via JuMP as follows:

@show MOI.get(model, Penopt.NumberOfOuterIterations())
@show MOI.get(model, Penopt.NumberOfNewtonSteps())
@show MOI.get(model, Penopt.NumberOfLinesearchSteps())