A safe Rust interface for SCIP. This crate also exposes access to the SCIP's C-API through the ffi
module.
The project is currently an early-stage work in progress, issues/pull-requests are very welcome.
Make sure SCIP is installed, the easiest way to install it is to install a precompiled package from here or through conda by running
bash
conda install --channel conda-forge scip
After which russcip
would be able to find the installation in the current Conda environment. Alternatively, you can specify the installation directory through the SCIPOPTDIR
environment variable.
russcip is tested against SCIP 8.0.3 but it might work for other versions depending on which functionality you use.
By running
bash
cargo add russcip
or to get the most recent version, add the following to your Cargo.toml
toml
[dependencies]
russcip = { git = "https://github.com/mmghannam/russcip" }
Model and solve an integer program. ```rust use russcip::model::Model; use russcip::model::ObjSense; use russcip::status::Status; use russcip::variable::VarType; use russcip::retcode::Retcode; use crate::russcip::model::ModelWithProblem;
fn main() { // Create model let mut model = Model::new() .hideoutput() .includedefaultplugins() .createprob("test") .setobjsense(ObjSense::Maximize);
// Add variables
let x1_id = model.add_var(0., f64::INFINITY, 3., "x1", VarType::Integer);
let x2_id = model.add_var(0., f64::INFINITY, 4., "x2", VarType::Integer);
// Add constraints
model.add_cons(&[x1_id, x2_id], &[2., 1.], -f64::INFINITY, 100., "c1");
model.add_cons(&[x1_id, x2_id], &[1., 2.], -f64::INFINITY, 80., "c2");
let solved_model = model.solve();
let status = solved_model.get_status();
println!("Solved with status {:?}", status);
let obj_val = solved_model.get_obj_val();
println!("Objective value: {}", obj_val);
let sol = solved_model.get_best_sol().unwrap();
let vars = solved_model.get_vars();
for var in vars {
println!("{} = {}", &var.get_name(), sol.get_var_val(&var));
}
}
```
raw
featureYou can enable this feature by specifying the feature in your Cargo.toml
toml
[dependencies]
russcip = { features = ["raw"] }
This enables access to the scip_ptr
unsafe function in the Model
struct, which gives you access to the underlying SCIP raw pointer. This is can be used in combination with the ffi
module to call SCIP functions that are not wrapped yet in the safe interface.
SCIP is currently one of the fastest non-commercial solvers for mixed integer programming (MIP) and mixed integer nonlinear programming (MINLP). It is also a framework for constraint integer programming and branch-cut-and-price. It allows for total control of the solution process and the access of detailed information down to the guts of the solver.