3 releases
0.2.3+3.14.16 | Apr 25, 2024 |
---|---|
0.2.2+3.14.15 | Apr 11, 2024 |
0.2.1+3.14.14 | Jan 19, 2024 |
#1384 in Algorithms
163 downloads per month
Used in 3 crates
(2 directly)
2MB
56K
SLoC
Ipopt-src
description
Ipopt-src
crate is a *-src crate. This links Ipopt libraries to executable build by cargo, but does not provide Rust bindings. Ipopt is built with Mumps (mumps-src) and OpenBLAS (openblas-src)(Optional) and Intel-MKL (intel-mkl-src)(Optional).
By this package, you don't need to worry about installing Ipopt in the system, and it's a package for all platforms.
Ipopt (Interior Point OPTimizer, pronounced eye-pea-Opt) is a software package for large-scale nonlinear optimization. It is designed to find (local) solutions of mathematical optimization problems of the NLP.
Usage
-
add the following to your
Cargo.toml
:[dependencies] ipopt-src = "\*"
-
add the following to your
lib.rs
:extern crate ipopt_src;
This package does not provide bindings. Please use coinipopt-sys to use Ipopt, e.g.
[dependencies]
coinipopt-sys = { version = "\*" }
Configuration
Features
The following Cargo features are supported:
default
to enablemumps
withopenblas-static
;
There's one of the following solvers needed by ipopt(click Ipopt to get more information):
intel-mkl
to build with Intel MKL;mumps
to build with Mumps;hsl
to build with HSL;(Not supported now)spral
to build with Spral;(Not supported now)wsmp
to build with WSMP;(Not supported now)
if intel-mkl
is selected, you should choose one of the following linking mode:
intel-mkl-static
to build with Intel MKLlp64
,seq
;intel-mkl-dynamic
to build with Intel MKLlp64
,seq
;
if mumps
is selected, you should choose one of the following linking mode as mumps' liner solver:
intel-mkl-static
to build with Intel MKLlp64
,seq
;intel-mkl-dynamic
to build with Intel MKLlp64
,seq
;openblas-static
to build with OpenBLAS and link as static;openblas-dynamic
to build with OpenBLAS and link as dynamic;
Environment
The package build from the source and link statically by default. It also provide the following environment variables to allow users to link to system library customly:
CARGO_IPOPT_STATIC
to link to Ipopt statically;CARGO_IPOPT_SYSTEM
to link to Ipopt system library;CARGO_MUMPS_STATIC
to link to Mumps statically;CARGO_MUMPS_SYSTEM
to link to Mumps system library;
Set the environment variable to 1
to enable the feature. For example, to link to system library dynamically, set CARGO_${LIB_NAME}_SYSTEM
to 1
; to link to system library statically, set both CARGO_${LIB_NAME}_SYSTEM
and CARGO_${LIB_NAME}_STATIC
to 1
.
If you enable OpenBLAS(openblas-src), you can also pass env to make
by OPENBLAS_*
. Read more at here
Others
If you enable OpenBLAS(openblas-src), you can link OpenBLAS
staticaly or dynamicly by disable default feature and select what you like, for example:
ipopt-src = { version = "\*", default-features = no, features = ["mumps", "openblas-static"] }
Similarly, you can link Intel MKL (intel-mkl-src) with:
ipopt-src = { version = "\*", default-features = no, features = ["intel-mkl", "intel-mkl-system"] }
If you want more configuration, you can try this:
ipopt-src = { version = "\*", default-features = no, features = ["intel-mkl"] }
intel-mkl-src = { version = "\*", features = ["mkl-static-lp64-seq"] }
Windows and vcpkg
On Windows, openblas need vcpkg to find Ipopt. Before building, you must have the correct Ipopt installed for your target triplet and kind of linking. For instance, to link dynamically for the x86_64-pc-windows-msvc
toolchain, install ipopt
for the x64-windows
triplet:
vcpkg install ipopt --triplet x64-windows
To link Ipopt statically, install ipopt
for the x64-windows-static-md
triplet:
vcpkg install ipopt --triplet x64-windows-static-md
To link Ipopt and C Runtime (CRT) statically, install ipopt
for the x64-windows-static
triplet:
vcpkg install ipopt --triplet x64-windows-static
and build with +crt-static
option
RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-pc-windows-msvc
Please see the "Static and dynamic C runtimes" in The Rust reference for detail.
Cross Compilation
If you use OpenBLAS(openblas-src), you need to set OPENBLAS_CC
, OPENBLAS_FC
, OPENBLAS_HOSTCC
, and OPENBLAS_TARGET
to pass env to OpenBLAS, ref:openblas-src and OpenBLAS. For example:
export OPENBLAS_TARGET=ARMV8
export OPENBLAS_HOSTCC=gcc
export OPENBLAS_CC=aarch64-linux-gnu-gcc
export OPENBLAS_FC=aarch64-linux-gnu-gfortran
you can compile it for the other target by providing the --target
option to cargo build
.
Target | supported |
---|---|
arm-unknown-linux-gnueabi |
✓ |
arm-unknown-linux-gnueabihf |
✓ |
armv7-unknown-linux-gnueabi |
✓ |
armv7-unknown-linux-gnueabihf |
✓ |
armv7-unknown-linux-musleabi |
✓ |
armv7-unknown-linux-musleabihf |
✓ |
aarch64-unknown-linux-gnu |
✓ |
aarch64-unknown-linux-musl |
✓ |
riscv64gc-unknown-linux-gnu |
✓ |
x86_64-pc-windows-msvc |
✓ |
x86_64-unknown-linux-gnu |
✓ |
others | not test |
Note: Features intel-mkl-*
can only be used for x86_64-*
. Features openblas-static
can only be used for linux
.
Contribution
Your contribution is highly appreciated. Do not hesitate to open an issue or a pull request. Note that any contribution submitted for inclusion in the project will be licensed according to the terms given in LICENSE.
Dependencies
~0–1.8MB
~28K SLoC