This repository is still under development. It is not a registered Julia package, and has not been tested on macOS or Windows.
Penopt.jl is a wrapper for the Penopt Optimizer.
It has two components:
- a thin wrapper around the complete C API
- an interface to MathOptInterface
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 https://github.com/jump-dev/Penopt.jl.git
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 libpenbmi.so -Wl,--whole-archive /path/to/PENBMI2.1/lib/libpenbmi.a -Wl,--no-whole-archive
This will create a shared library libpenbmi.so
in the directory deps/usr/lib
.
Then create the following file deps/deps.jl
:
import Libdl
const libpenbmi = joinpath(dirname(@__FILE__), "usr/lib/libpenbmi.so")
function check_deps()
global libpenbmi
if !isfile(libpenbmi)
error("$(libpenbmi) does not exist, Please re-run Pkg.build(\"Penopt\"), and restart Julia.")
end
if Libdl.dlopen_e(libpenbmi) == C_NULL
error("$(libpenbmi) cannot be opened, Please re-run Pkg.build(\"Penopt\"), and restart Julia.")
end
end
You can test the installation with using Pkg; Pkg.test("Penopt")
in a Julia
session.
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.
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())