Skip to content

lanl-ansi/Juniper.jl

Repository files navigation

Juniper

CI codecov Documentation

Juniper (Jump Nonlinear Integer Program solver) is a solver for mixed-integer nonlinear programs.

It is a heuristic which is not guaranteed to find the global optimum. If you need the global optimum, check out Alpine.

Installation

Install Juniper using the Julia package manager:

import Pkg
Pkg.add("Juniper")

Use with JuMP

Use Juniper with JuMP as follows:

using JuMP, Juniper, Ipopt
ipopt = optimizer_with_attributes(Ipopt.Optimizer, "print_level"=>0)
optimizer = optimizer_with_attributes(Juniper.Optimizer, "nl_solver"=>ipopt)
model = Model(optimizer)
v = [10, 20, 12, 23, 42]
w = [12, 45, 12, 22, 21]
@variable(model, x[1:5], Bin)
@objective(model, Max, v' * x)
@constraint(model, sum(w[i]*x[i]^2 for i in 1:5) <= 45)
optimize!(model)
println(termination_status(model))
println(objective_value(model))
println(value.(x))

The nl_solver is used by Juniper to solve continuous nonlinear sub-problems while Juniper searches for acceptable assignments to the discrete variables. A common choice is Ipopt, but any optimizer that supports the continuous relaxation of the model may be used.

To solve problems with more complex nonlinear functions, use the @NLconstraint and @NLobjective JuMP macros.

Documentation

The online documentation is available at https://lanl-ansi.github.io/Juniper.jl/stable/.

Feasibility pump

If Juniper has difficulty finding feasible solutions on your model, try adding a solver that supports integer variables (for example, HiGHS) to run a feasibility pump:

using JuMP, Juniper, Ipopt, HiGHS
ipopt = optimizer_with_attributes(Ipopt.Optimizer, "print_level" => 0)
highs = optimizer_with_attributes(HiGHS.Optimizer, "output_flag" => false)
model = Model(
    optimizer_with_attributes(
        Juniper.Optimizer,
        "nl_solver" => ipopt,
        "mip_solver" => highs,
    ),
)

The feasibility pump is used at the start of Juniper to find a feasible solution before the branch and bound part starts. For some classes of problems this can be a highly effective pre-processor.

Citing Juniper

If you find Juniper useful in your work, we kindly request that you cite the following paper or technical report:

@inproceedings{juniper,
     Author = {Ole Kröger and Carleton Coffrin and Hassan Hijazi and Harsha Nagarajan},
     Title = {Juniper: An Open-Source Nonlinear Branch-and-Bound Solver in Julia},
     booktitle="Integration of Constraint Programming, Artificial Intelligence, and Operations Research",
     pages="377--386",
     year="2018",
     publisher="Springer International Publishing",
     isbn="978-3-319-93031-2"
}