Monty  Boehm

Monty Boehm

1659547620

SCIP.jl: Julia interface to SCIP Solver

SCIP.jl

Julia interface to the SCIP solver. 

See NEWS.md for changes in each (recent) release.

Update (April 2022)

Due to breaking changes, only SCIP 8 is supported by the wrapper on version 0.11 onwards.

Update (August 2020)

On MacOS and Linux, it is no longer required to install the SCIP binaries using this package. There now exists a BinaryBuilder.jl generated package SCIP_jll.jl and SCIP_PaPILO_jll.jl which is installed automatically as a dependency.

On Windows, the separate installation of SCIP is still mandatory, otherwise, you can use this default installation:

pkg> add SCIP

If you use an older Julia version, Windows or want a custom SCIP installation, see below for the build steps.

Custom SCIP installations.

If you prefer to link to your own installation of SCIP, please set the environment variable SCIPOPTDIR to point to the installation path. That is, either $SCIPOPTDIR/lib/libscip.so, $SCIPOPTDIR/lib/libscip.dylib or $SCIPOPTDIR/bin/scip.dll should exist, depending on your operating system.

When this is set before you install this package, it should be recognized automatically. Afterwards, you can trigger the build with

pkg> build SCIP

Setting Parameters

There are two ways of setting the parameters (all are supported). First, using MOI.set:

using MOI
using SCIP

optimizer = SCIP.Optimizer()
MOI.set(optimizer, MOI.RawOptimizerAttribute("display/verblevel"), 0)
MOI.set(optimizer, MOI.RawOptimizerAttribute("limits/gap"), 0.05)

Second, as keyword arguments to the constructor. But here, the slashes (/) need to be replaced by underscores (_) in order to end up with a valid Julia identifier. This should not lead to ambiguities as none of the official SCIP parameters contain any underscores (yet).

using MOI
using SCIP

optimizer = SCIP.Optimizer(display_verblevel=0, limits_gap=0.05)

Note that in both cases, the correct value type must be used (here, Int64 and Float64).

Design Considerations

Wrapper of Public API: All of SCIP's public API methods are wrapped and available within the SCIP package. This includes the scip_*.h and pub_*.h headers that are collected in scip.h, as well as all default constraint handlers (cons_*.h.) But the wrapped functions do not transform any data structures and work on the raw pointers (e.g. SCIP* in C, Ptr{SCIP_} in Julia). Convenience wrapper functions based on Julia types are added as needed.

Memory Management: Programming with SCIP requires dealing with variable and constraints objects that use reference counting for memory management. The SCIP.Optimizer wrapper type collects lists of SCIP_VAR* and SCIP_CONS* under the hood, and releases all reference when it is garbage collected itself (via finalize). When adding a variable (add_variable) or a constraint (add_linear_constraint), an integer index is returned. This index can be used to retrieve the SCIP_VAR* or SCIP_CONS* pointer via get_var and get_cons respectively.

Supported Features for MathOptInterface: We aim at exposing many of SCIP's features through MathOptInterface. However, the focus is on keeping the wrapper simple and avoiding duplicate storage of model data.

As a consequence, we do not currently support some features such as retrieving constraints by name (VariableIndex-set constraints are not stored as SCIP constraints explicitly).

Support for more constraint types (quadratic, SOS1/2, nonlinear expression) is implemented, but SCIP itself only supports affine objective functions, so we will stick with that. More general objective functions could be implented via a bridge.

Supported operators in nonlinear expressions are as follows:

  • unary: -, sqrt, exp, log, abs, cos, sin
  • binary: -, /, ^
  • n-ary: +, *

Author: Scipopt
Source Code: https://github.com/scipopt/SCIP.jl 
License: MIT license

#julia #global 

What is GEEK

Buddha Community

SCIP.jl: Julia interface to SCIP Solver

Mosek.jl: Interface to The Mosek Solver in Julia

Note on versions and release

Since the Mosek.jl package is designed to match a specific MOSEK version (major+minor version), there are branches for the different MOSEK versions:

  • Branch b0.8 is compatible with MOSEK 8.0. Not actively updated.
  • Branch b0.9 is compatible with MOSEK 8.1. Currently updated only for bugfixes.
  • Branch b1.1-msk9.1 is compatible with MOSEK 9.1. Not actively updated.
  • Branch b1.1-msk9.2 is compatible with MOSEK 9.2. Not actively updated.
  • Branch b1.1-msk9.3 is compatible with MOSEK 9.3. Currently updated only for bugfixes.
  • Branch b10.0 is compatible with MOSE 10.0, at the time of writing in beta. Since MOSEK 10.0 the branch names of Mosek.jl will follow Mosek, so the branch compatible with MOSEK 10.0 will be called b10.0. Release will be called MAJORVER.MINORVER.N, where N is incremented independently of MOSEK. This means that since MOSEK 10.0, Mosek.jl vX.Y.Z will require MOSEK version X.Y
  • The master branch. This is more or less kept compatible with the latest MOSEK release, either latest stable release or, if available, the latest alpha or beta.

Mosek.jl releases are taken from the b*.* branches.

Mosek.jl

Interface to the MOSEK solver in Julia.

Mosek.jl is a more or less complete mapping of the MOSEK functionality:

  • Most MOSEK C API functions are available
  • Callbacks for information retrival and log output during optimization
  • Interface for the MOSEK general convex solver

MOSEK can solve LP (linear), SOCP (second order conic), SDP (semi-definite), QP (quadratic objective, quadratic constraints), and MIP (mixed-integer problems). These can be mixed as follows:

  • LP+CONIC+SDP
  • LP+CONIC+MIP

MOSEK is commercial software, but free licenses are available for academic use. See here for details.

Installation

Use the Julia package manager to install Mosek.jl:

Pkg.add("Mosek")

The Mosek.jl package requires the MOSEK distribution binaries run. Upon installation it will attempt to either local an installed MOSEK or download and install from the MOSEK website (www.mosek.com):

  1. If the environment variable MOSEKBINDIR is defined, the installer will assume that this directory contains the necessary libraries. If it does not, the installer will fail.
  2. If the current Mosek.jl installation uses a user-defined MOSEK and this is a valid version, this will be used.
  3. If MOSEK is installed in the default location in the users HOME directory, and this installation has the correct version, this will be used.
  4. If no usable MOSEK installation is found here, the installer will attempt to download and unpack the latest distro. In this case doing Pkg.build("Mosek") will update the MOSEK distro if possible.`

If the MOSEK distro installation directory is moved it is necessary to rebuild the package using

Pkg.build("Mosek")

If you have previously installed Mosek.jl using a pre-installed MOSEK distro, setting the MOSEKJL_FORCE_DOWNLOAD=YES will force the installer to download MOSEK from the web instead of using the old version.

Note that environment variables can be set temporarily from Julia as

ENV["MOSEKBINDIR"] = "/home/myname/lib"

Furthermore, a license file is required to use MOSEK (these are free for academic use). MOSEK will look first for the enironment variable MOSEKLM_LICENSE_FILE which, if defined, must point to the relevant license file. If this is not defined, MOSEK will look for a file called mosek.lic in the default install path, e.g.

$HOME/mosek/mosek.lic

Updating the Mosek library

If the MOSEK distro was installed manually, it can be updated simply by installing a newer distro in the same place. Otherwise, doing Pkg.build("Mosek") will check the latest MOSEK distro and update if possible.

You can see if the MOSEK distro was installed internally this way:

is_internal = open(joinpath(Pkg.dir("Mosek"),"deps","inst_method"),"r") do f readstring(f) == "internal" end

When installation does not work

If you experience problems installing (in particular on Windows or OS X), you can try to pull the latest revision and see if that works

Pkg.checkout("Mosek","master")
Pkg.build("Mosek")

If this also fails, please post an issue in Github.

Documentation

All functions and constants in the Mosek.jl are briefly documented in docs strings, and an HTML reference can be built using Documenter.jl.

For a more complete description of functions, please refer to the MOSEK C API documentation.

Use with JuMP

The MathOptInterface wrapper for MOSEK is a separate package called MosekTools. However, for consistency the optimizer is still named Mosek.Optimizer.

Use MOSEK with JuMP as follows:

using JuMP, MosekTools
model = Model(Mosek.Optimizer)

MathProgBase interface

The legacy MathProgBase wrapper for MOSEK is implemented in the MosekConicInterface.jl, MosekLPQCQPInterface.jl and MosekSolverInterface.jl files in the src folder.

Download Details:

Author: MOSEK
Source Code: https://github.com/MOSEK/Mosek.jl 
License: MIT license

#julia #interface 

Monty  Boehm

Monty Boehm

1659547620

SCIP.jl: Julia interface to SCIP Solver

SCIP.jl

Julia interface to the SCIP solver. 

See NEWS.md for changes in each (recent) release.

Update (April 2022)

Due to breaking changes, only SCIP 8 is supported by the wrapper on version 0.11 onwards.

Update (August 2020)

On MacOS and Linux, it is no longer required to install the SCIP binaries using this package. There now exists a BinaryBuilder.jl generated package SCIP_jll.jl and SCIP_PaPILO_jll.jl which is installed automatically as a dependency.

On Windows, the separate installation of SCIP is still mandatory, otherwise, you can use this default installation:

pkg> add SCIP

If you use an older Julia version, Windows or want a custom SCIP installation, see below for the build steps.

Custom SCIP installations.

If you prefer to link to your own installation of SCIP, please set the environment variable SCIPOPTDIR to point to the installation path. That is, either $SCIPOPTDIR/lib/libscip.so, $SCIPOPTDIR/lib/libscip.dylib or $SCIPOPTDIR/bin/scip.dll should exist, depending on your operating system.

When this is set before you install this package, it should be recognized automatically. Afterwards, you can trigger the build with

pkg> build SCIP

Setting Parameters

There are two ways of setting the parameters (all are supported). First, using MOI.set:

using MOI
using SCIP

optimizer = SCIP.Optimizer()
MOI.set(optimizer, MOI.RawOptimizerAttribute("display/verblevel"), 0)
MOI.set(optimizer, MOI.RawOptimizerAttribute("limits/gap"), 0.05)

Second, as keyword arguments to the constructor. But here, the slashes (/) need to be replaced by underscores (_) in order to end up with a valid Julia identifier. This should not lead to ambiguities as none of the official SCIP parameters contain any underscores (yet).

using MOI
using SCIP

optimizer = SCIP.Optimizer(display_verblevel=0, limits_gap=0.05)

Note that in both cases, the correct value type must be used (here, Int64 and Float64).

Design Considerations

Wrapper of Public API: All of SCIP's public API methods are wrapped and available within the SCIP package. This includes the scip_*.h and pub_*.h headers that are collected in scip.h, as well as all default constraint handlers (cons_*.h.) But the wrapped functions do not transform any data structures and work on the raw pointers (e.g. SCIP* in C, Ptr{SCIP_} in Julia). Convenience wrapper functions based on Julia types are added as needed.

Memory Management: Programming with SCIP requires dealing with variable and constraints objects that use reference counting for memory management. The SCIP.Optimizer wrapper type collects lists of SCIP_VAR* and SCIP_CONS* under the hood, and releases all reference when it is garbage collected itself (via finalize). When adding a variable (add_variable) or a constraint (add_linear_constraint), an integer index is returned. This index can be used to retrieve the SCIP_VAR* or SCIP_CONS* pointer via get_var and get_cons respectively.

Supported Features for MathOptInterface: We aim at exposing many of SCIP's features through MathOptInterface. However, the focus is on keeping the wrapper simple and avoiding duplicate storage of model data.

As a consequence, we do not currently support some features such as retrieving constraints by name (VariableIndex-set constraints are not stored as SCIP constraints explicitly).

Support for more constraint types (quadratic, SOS1/2, nonlinear expression) is implemented, but SCIP itself only supports affine objective functions, so we will stick with that. More general objective functions could be implented via a bridge.

Supported operators in nonlinear expressions are as follows:

  • unary: -, sqrt, exp, log, abs, cos, sin
  • binary: -, /, ^
  • n-ary: +, *

Author: Scipopt
Source Code: https://github.com/scipopt/SCIP.jl 
License: MIT license

#julia #global 

Ipopt.jl: Julia interface to The Ipopt Nonlinear Solver

Ipopt.jl

Ipopt.jl is a Julia interface to the COIN-OR nonlinear solver Ipopt.

Note: This wrapper is maintained by the JuMP community and is not a COIN-OR project.

Installation

Install Ipopt.jl using the Julia package manager:

import Pkg; Pkg.add("Ipopt")

In addition to installing the Ipopt.jl package, this will also download and install the Ipopt binaries. You do not need to install Ipopt separately.

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

For details on using a different linear solver, see the Linear Solvers section below. You do not need a custom binary to change the linear solver.

JuMP and MathOptInterface

You can use Ipopt with JuMP as follows:

using JuMP, Ipopt
model = Model(Ipopt.Optimizer)
set_optimizer_attribute(model, "max_cpu_time", 60.0)
set_optimizer_attribute(model, "print_level", 0)

Supported options are listed in the Ipopt documentation.

Solver-specific callback

Ipopt provides a callback that can be used to log the status of the optimization during a solve. It can also be used to terminate the optimization by returning false. Here is an example:

using JuMP, Ipopt, Test
model = Model(Ipopt.Optimizer)
set_silent(model)
@variable(model, x >= 1)
@objective(model, Min, x + 0.5)
x_vals = Float64[]
function my_callback(
   alg_mod::Cint,
   iter_count::Cint,
   obj_value::Float64,
   inf_pr::Float64,
   inf_du::Float64,
   mu::Float64,
   d_norm::Float64,
   regularization_size::Float64,
   alpha_du::Float64,
   alpha_pr::Float64,
   ls_trials::Cint,
)
   push!(x_vals, callback_value(model, x))
   @test isapprox(obj_value, 1.0 * x_vals[end] + 0.5, atol = 1e-1)
   # return `true` to keep going, or `false` to terminate the optimization.
   return iter_count < 1
end
MOI.set(model, Ipopt.CallbackFunction(), my_callback)
optimize!(model)
@test MOI.get(model, MOI.TerminationStatus()) == MOI.INTERRUPTED
@test length(x_vals) == 2

See the Ipopt documentation for an explanation of the arguments to the callback. They are identical to the output contained in the logging table printed to the screen.

C Interface Wrapper

Ipopt.jl wraps the Ipopt C interface with minimal modifications.

A complete example is available in the test/C_wrapper.jl file.

For simplicity, the five callbacks required by Ipopt are slightly different to the C interface. They are as follows:

"""
   eval_f(x::Vector{Float64})::Float64

Returns the objective value `f(x)`.
"""
function eval_f end

"""
   eval_grad_f(x::Vector{Float64}, grad_f::Vector{Float64})::Nothing

Fills `grad_f` in-place with the gradient of the objective function evaluated at
`x`.
"""
function eval_grad_f end

"""
   eval_g(x::Vector{Float64}, g::Vector{Float64})::Nothing

Fills `g` in-place with the value of the constraints evaluated at `x`.
"""
function eval_g end

"""
   eval_jac_g(
      x::Vector{Float64},
      rows::Vector{Cint},
      cols::Vector{Cint},
      values::Union{Nothing,Vector{Float64}},
   )::Nothing

Compute the Jacobian matrix.

* If `values === nothing`
   - Fill `rows` and `cols` with the 1-indexed sparsity structure
* Otherwise:
   - Fill `values` with the elements of the Jacobian matrix according to the
     sparsity structure.

!!! warning
    If `values === nothing`, `x` is an undefined object. Accessing any elements
    in it will cause Julia to segfault.
"""
function eval_jac_g end

"""
   eval_h(
      x::Vector{Float64},
      rows::Vector{Cint},
      cols::Vector{Cint},
      obj_factor::Float64,
      lambda::Float64,
      values::Union{Nothing,Vector{Float64}},
   )::Nothing

Compute the Hessian-of-the-Lagrangian matrix.

* If `values === nothing`
   - Fill `rows` and `cols` with the 1-indexed sparsity structure
* Otherwise:
   - Fill `values` with the Hessian matrix according to the sparsity structure.

!!! warning
    If `values === nothing`, `x` is an undefined object. Accessing any elements
    in it will cause Julia to segfault.
"""
function eval_h end

INVALID_MODEL error

If you get a termination status MOI.INVALID_MODEL, it is probably because you have some undefined value in your model, e.g., a division by zero. Fix this by removing the division, or by imposing variable bounds so that you cut off the undefined region.

Instead of

model = Model(Ipopt.Optimizer)
@variable(model, x)
@NLobjective(model, 1 / x)

do

model = Model(Ipopt.Optimizer)
@variable(model, x >= 0.0001)
@NLobjective(model, 1 / x)

Linear Solvers

To improve performance, Ipopt supports a number of linear solvers. Installing these can be tricky, however, the following instructions should work. If they don't, or are not explicit enough, please open an issue.

Julia 1.7

Depending on your system, you may encounter the error: Error: no BLAS/LAPACK library loaded!. If you do, run:

import LinearAlgebra, OpenBLAS32_jll
LinearAlgebra.BLAS.lbt_forward(OpenBLAS32_jll.libopenblas_path)

Pardiso (Pardiso Project)

Linux

Tested on a clean install of Ubuntu 20.04.

Install lapack and libomp:

sudo apt install liblapack3 libomp-dev

Download Pardiso from https://www.pardiso-project.org

Rename the file libpardiso-XXXXX.so to libpardiso.so

Place the libpardiso.so library somewhere on your load path

Alternatively, if the library is located at /full/path/libpardiso.so, start Julia with export LD_LIBRARY_PATH=/full/path; julia

To make this permanent, modify your .bashrc to include:

export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/full/path/"

Set the option linear_solver to pardiso:

using Libdl
# Note: these filenames may differ. Check `/usr/lib/x86_64-linux-gnu` for the
# specific extension.
Libdl.dlopen("/usr/lib/x86_64-linux-gnu/liblapack.so.3", RTLD_GLOBAL)
Libdl.dlopen("/usr/lib/x86_64-linux-gnu/libomp.so.5", RTLD_GLOBAL)

using JuMP, Ipopt
model = Model(Ipopt.Optimizer)
set_optimizer_attribute(model, "linear_solver", "pardiso")

Mac

Tested on a MacBook Pro, 10.15.7.

Download Pardiso from https://www.pardiso-project.org

Rename the file libpardiso-XXXXX.dylib to libpardiso.dylib.

Place the libpardiso.dylib library somewhere on your load path.

  • Alternatively, if the library is located at /full/path/libpardiso.dylib, start Julia with export DL_LOAD_PATH=/full/path; julia

Set the option linear_solver to pardiso:

using JuMP, Ipopt
model = Model(Ipopt.Optimizer)
set_optimizer_attribute(model, "linear_solver", "pardiso")

Windows

Currently untested. If you have instructions that work, please open an issue.

HSL (MA27, MA86, MA97)

Linux

Tested on a clean install of Ubuntu 20.04.

Install dependencies if necessary:

sudo apt install gfortran libblas-dev libmetis-dev

Note: on Windows Subsystem for Linux, you may also need sudo apt install make.

Download the appropriate version of HSL.

Unzip the download, cd to the directory, and run the following:

./configure --prefix=</full/path/somewhere>
make
make install

where </full/path/somewhere> is replaced as appropriate.

Rename the resutling HSL library to /full/path/somewhere/lib/libhsl.so.

  • For ma27, the file is /full/path/somewhere/lib/libcoinhsl.so
  • For ma86, the file is /full/path/somewhere/lib/libhsl_ma86.so

Place the libhsl.so library somewhere on your load path.

  • Alternatively, start Julia with export LD_LIBRARY_PATH=/full/path/somewhere/lib; julia

Set the option linear_solver to ma27 or ma86 as appropriate:

using JuMP, Ipopt
model = Model(Ipopt.Optimizer)
set_optimizer_attribute(model, "linear_solver", "ma27")
# or
set_optimizer_attribute(model, "linear_solver", "ma86")

Mac

Tested on a MacBook Pro, 10.15.7.

Download the appropriate version of HSL.

Unzip the download, cd to the directory, and run the following:

./configure --prefix=</full/path/somewhere>
make
make install

Where </full/path/somewhere> is replaced as appropriate.

Rename the resutling HSL library to /full/path/somewhere/lib/libhsl.dylib.

  • For ma27, the file is /full/path/somewhere/lib/libcoinhsl.dylib
  • For ma86, the file is /full/path/somewhere/lib/libhsl_ma86.dylib

Place the libhsl.dylib library somewhere on your load path.

  • Alternatively, start Julia with export DL_LOAD_PATH=/full/path/somewhere/lib; julia

Set the option linear_solver to ma27 or ma86 as appropriate:

using JuMP, Ipopt
model = Model(Ipopt.Optimizer)
set_optimizer_attribute(model, "linear_solver", "ma27")
# or
set_optimizer_attribute(model, "linear_solver", "ma86")

Windows

Currently untested. If you have instructions that work, please open an issue.

Pardiso (MKL)

Currently untested on all platforms. If you have instructions that work, please open an issue.

Download Details:

Author: jump-dev
Source Code: https://github.com/jump-dev/Ipopt.jl 
License: View license

#julia #interface 

AmplNLWriter.jl: Julia interface to AMPL-enabled Solvers

AmplNLWriter.jl

AmplNLWriter.jl is an interface between MathOptInterface.jl and AMPL-enabled solvers.

Note: this wrapper is maintained by the JuMP community and has no official connection with the AMPL modeling language or AMPL Optimization Inc.

Installation

Install AmplNLWriter using Pkg.add.

import Pkg
Pkg.add("AmplNLWriter")

Note: AmplNLWriter requires Julia 1.6 or later.

Solvers

You also need an AMPL compatible solver.

Bonmin (https://github.com/coin-or/Bonmin)

To install Bonmin, use:

Pkg.add("Bonmin_jll")

Couenne (https://github.com/coin-or/Couenne)

To install Couenne, use:

Pkg.add("Couenne_jll")

Ipopt (https://github.com/coin-or/Ipopt)

To install Ipopt, use:

Pkg.add("Ipopt_jll")

SHOT (https://github.com/coin-or/SHOT)

To install SHOT, use:

Pkg.add("SHOT_jll")

Warning: SHOT_jll uses open-source solvers and fails many of our unit tests. You may want to compile your own binary with commercial solvers.

Usage

JLL packages

To call Bonmin via AmplNLWriter.jl, use:

using JuMP, AmplNLWriter, Bonmin_jll
model = Model(() -> AmplNLWriter.Optimizer(Bonmin_jll.amplexe))

# or equivalently

model = Model() do
    AmplNLWriter.Optimizer(Bonmin_jll.amplexe)
end

Replace Bonmin_jll with Couenne_jll, Ipopt_jll, or SHOT_jll as appropriate.

Other binaries

You can also pass a string pointing to an AMPL-compatible solver executable. For example, if the bonmin executable is on the system path, use:

using JuMP, AmplNLWriter
model = Model(() -> AmplNLWriter.Optimizer("bonmin"))

If the solver is not on the path, the full path to the solver will need to be passed in.

Options

A list of available options for each solver can be found here:

Set an option using set_optimizer_attribute. For example, to set the "bonmin.nlp_log_level" option to 0 in Bonmin, use:

using JuMP, AmplNLWriter, Bonmin_jll
model = Model(() -> AmplNLWriter.Optimizer(Bonmin_jll.amplexe))
set_optimizer_attribute(model, "bonmin.nlp_log_level", 0)

opt files

Some of the options need to be specified via an .opt file. This file must be located in the current working directory whenever the model is solved.

The .opt file must be named after the name of the solver, e.g. bonmin.opt, and each line must contain an option name and the desired value separated by a space. For instance, to set the absolute and relative tolerances in Couenne to 1 and 0.05 respectively, the couenne.opt is:

allowable_gap 1
allowable_fraction_gap 0.05

Download Details:

Author: jump-dev
Source Code: https://github.com/jump-dev/AmplNLWriter.jl 
License: MIT license

#julia #interface 

KNITRO.jl: Julia interface to The Artelys Knitro Solver

KNITRO.jl

KNITRO.jl is a Julia interface to the Artelys Knitro solver.

It has two components:

Note: This wrapper is maintained by the JuMP community with help from Artelys. Please contact Artelys support if you encounter any problem with this interface or the solver.

Installation

First, purchase and install a copy of Knitro from Artelys.

Then, install KNITRO.jl using the Julia package manager:

import Pkg; Pkg.add("KNITRO")

KNITRO.jl is available free of charge and in no way replaces or alters any functionality of Artelys Knitro solver.

Troubleshooting

If you are having issues installing, 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" and export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$KNITRODIR/lib". You can check that KNITRO.jl sees your library with using KNITRO; KNITRO.has_knitro().

If KNITRO.has_knitro() returns false but you are confident that your paths are correct, try running 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.

Use with JuMP

Use the KNITRO.Optimizer to use KNITRO with JuMP or MathOptInterface:

using JuMP
import KNITRO
model = Model(KNITRO.Optimizer)
set_optimizer_attribute(model, "honorbnds", 1)
set_optimizer_attribute(model, "outlev", 1)
set_optimizer_attribute(model, "algorithm", 4)

Use with AMPL

Pass KNITRO.amplexe to use KNITRO with the package AmplNLWriter.jl package:

using JuMP
import AmplNLWriter
import KNITRO
model = Model(() -> AmplNLWriter.Optimizer(KNITRO.amplexe, ["outlev=3"]))

Use with other packages

A variety of packages extend KNITRO.jl to support other optimization modeling systems. These include:

Low-level wrapper

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/.

Multithreading

Due to limitations in the interaction between Julia and C, KNITRO.jl disables multithreading 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.


KNITRO.jl underwent a major rewrite between versions 0.12.0 and 0.13.0, with the low-level wrapper now being generated automatically with Clang.jl. Users of JuMP should see no breaking changes, but if you used the lower-level C API you will need to update your code accordingly.


Download Details:

Author: Jump-dev
Source Code: https://github.com/jump-dev/KNITRO.jl 
License: View license

#julia #dev #interface