KNITRO.jl is a wrapper for the Artelys Knitro solver.
It has two components:
- a thin wrapper around the C API
- an interface to MathOptInterface.
This wrapper is maintained by the JuMP community with help from Artelys.
Contact Artelys support if you encounter any problem with this interface or the solver.
KNITRO.jl
is licensed under the MIT License.
The underlying solver is a closed-source commercial product for which you must purchase a license.
First, obtain a license and install a copy of KNITRO from Artelys.
Then, install KNITRO.jl
using the Julia package manager:
import Pkg
Pkg.add("KNITRO")
If you are having trouble installing KNITRO.jl, here are several things to try:
- Make sure that you have defined your global variables correctly, for example
with
export KNITRODIR="/path/to/knitro-vXXX-$OS-64"
andexport LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$KNITRODIR/lib"
. You can check thatKNITRO.jl
sees your library withusing KNITRO; KNITRO.has_knitro()
. - If
KNITRO.has_knitro()
returnsfalse
but you are confident that your paths are correct, try runningPkg.build("KNITRO")
and restarting Julia. In at least one user's experience, installing and using KNITRO in a temporary Julia environment (activated with] activate --temp
) does not work and the need to manually build is likely the reason why.
To use KNITRO with JuMP, use KNITRO.Optimizer
:
using JuMP, KNITRO
model = Model(KNITRO.Optimizer)
set_attribute(model, "outlev", 1)
set_attribute(model, "algorithm", 4)
To use KNITRO with AmplNLWriter.jl,
use KNITRO.amplexe
:
using JuMP
import AmplNLWriter
import KNITRO
model = Model(() -> AmplNLWriter.Optimizer(KNITRO.amplexe, ["outlev=3"]))
A variety of packages extend KNITRO.jl to support other optimization modeling systems. These include:
The Knitro optimizer supports the following constraints and attributes.
List of supported objective functions:
MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}
MOI.ObjectiveFunction{MOI.ScalarQuadraticFunction{Float64}}
MOI.ObjectiveFunction{MOI.VariableIndex}
List of supported variable types:
List of supported constraint types:
MOI.ScalarAffineFunction{Float64}
inMOI.EqualTo{Float64}
MOI.ScalarAffineFunction{Float64}
inMOI.GreaterThan{Float64}
MOI.ScalarAffineFunction{Float64}
inMOI.Interval{Float64}
MOI.ScalarAffineFunction{Float64}
inMOI.LessThan{Float64}
MOI.ScalarQuadraticFunction{Float64}
inMOI.EqualTo{Float64}
MOI.ScalarQuadraticFunction{Float64}
inMOI.GreaterThan{Float64}
MOI.ScalarQuadraticFunction{Float64}
inMOI.Interval{Float64}
MOI.ScalarQuadraticFunction{Float64}
inMOI.LessThan{Float64}
MOI.VariableIndex
inMOI.EqualTo{Float64}
MOI.VariableIndex
inMOI.GreaterThan{Float64}
MOI.VariableIndex
inMOI.Integer
MOI.VariableIndex
inMOI.Interval{Float64}
MOI.VariableIndex
inMOI.LessThan{Float64}
MOI.VariableIndex
inMOI.ZeroOne
MOI.VectorAffineFunction{Float64}
inMOI.SecondOrderCone
MOI.VectorOfVariables
inMOI.Complements
MOI.VectorOfVariables
inMOI.SecondOrderCone
List of supported model attributes:
A list of available options is provided in the KNITRO reference manual.
KNITRO.jl implements most of Knitro's functionalities. If you aim at using part
of Knitro's API that are not implemented in the MathOptInterface/JuMP ecosystem,
you can refer to the low-level API, which wraps Knitro's C API (whose templates
are specified in the file knitro.h
).
Extensive examples using the C wrapper can be found in examples/
.
Due to limitations in the interaction between Julia and C, KNITRO.jl disables
multi-threading if the problem is nonlinear. This will override any options such
as par_numthreads
that you may have set. Read GitHub issue #93
for more details.