Crates.io | ipopt_bindgen |
lib.rs | ipopt_bindgen |
version | 0.2.3 |
source | src |
created_at | 2024-04-07 18:21:31.566306 |
updated_at | 2024-10-07 20:23:57.226141 |
description | Rust bindings to the C interface of Ipopt, a library for large-scale, constrained, nonlinear optimization. |
homepage | |
repository | https://github.com/MattBolitho/ipopt_bindgen |
max_upload_size | |
id | 1199392 |
size | 45,675 |
This crate provides raw Rust bindings to the C interface of the Ipopt optimization library using bindgen.
Install Ipopt (more details later in the prerequisites section).
Add this crate to your Cargo.toml
:
[dependencies]
ipopt_bindgen = "0.2"
Use the Ipopt C interface in your project:
use ipopt_bindgen::*;
// Ipopt C interface symbols are now available.
println!("{0}.{1}.{2}", IPOPT_VERSION_MAJOR, IPOPT_VERSION_MINOR, IPOPT_VERSION_RELEASE);
Or, run the example in this repository:
cargo run --example hs071
This crate has currently been tested on:
homebrew
.Rust already has other crates that provide bindings to Ipopt:
So why create another one?
The purpose of this crate is to use the system Ipopt installation directly, rather than build it from within cargo. This has both advantages and disadvantages, and might not be right for you.
Pros:
cargo
or existing crates.Cons:
If you just want to get started with Ipopt in Rust, you should probably use one of the aforementioned existing crates. However, if you already have Ipopt installed on your system or need to use a build with specific features, this crate might be for you.
Ideally, an idiomatic Rust crate would be build on top of this one, or it could be integrated into an existing crate.
There is a full, mirrored example of the HS071 problem from the Ipopt documentation in the examples directory. Again, the ideal usage of this crate is to be consumed by a higher-level crate that provides a more idiomatic interface, but it is possible to use it directly. The example demonstrates the C API usage, which will probably aid in that endeavour!
Ipopt must be installed on your system.
The binding header file will attempt to include coin-or/IpStdCInterface.h
.
On Linux, you can either install Ipopt using your package manager or build it from source. By default, these processes should make Ipopt immediately available for use with this crate.
On Windows, you can get precompiled binaries from the Ipopt GitHub repository. Then, add the downloaded release files to your environment variables as follows:
PATH
.LIB
.INCLUDE
.On Windows, by default this crate will attempt to use the cc
crate to automatically detect an MSVC installation.
This is used to more easily supply standard library headers for the Ipopt C interface header.
If this fails, you will need to set the INCLUDE
environment variable to include your desired standard library headers.
The bindgen requirements must also be available on your system.
This basically amounts to having clang
installed.
On Windows, you can use winget install LLVM.LLVM
.
On Linux, you can use your package manager to install clang
.
LLVM also provide an apt
install script.
All meaningful changes to this project are documented in the CHANGELOG.
This repository is licensed under either of:
at your option.
Ipopt itself is licensed under the Eclipse Public License (EPL) version 2.0.