soplex_rs/
lib.rs

1//! Safe Rust bindings for the SoPlex linear programming solver.
2//!
3//! # Example
4//! ```rust
5//! use soplex_rs::*;
6//!
7//! // You can create an LP model using the `add_col` and the `add_row` methods on the `Model`.
8//! let mut lp = Model::new();
9//! // Add column with obj. function value of 1.0 and range from 0 to 5
10//! let col1= lp.add_col(vec![], 1.0, 0.0, 5.0);
11//! // Add column with obj. function value of 1.0 and range from 0 to 5
12//! let col2 = lp.add_col(vec![], 1.0, 0.0, 5.0);
13//! // Add row where both columns have coefficient 1 and the value is between 1 and 5
14//! let row = lp.add_row(vec![1.0, 1.0], 1.0, 5.0);
15//! assert_eq!(lp.num_cols(), 2);
16//! assert_eq!(lp.num_rows(), 1);
17//!
18//! // When calling `optimize` you get back a `SolvedModel` where you can query information about the solution
19//! // and basis status of columns and rows.
20//! let lp = lp.optimize();
21//! let result = lp.status();
22//! assert_eq!(result, Status::Optimal);
23//! assert!((lp.obj_val() - 5.0).abs() < 1e-6);
24//!
25//!
26//! // After solving you need to return the `SolvedModel` object to a `Model` object.
27//! // Then you can add or remove columns and rows and optimize again.
28//! let mut lp = Model::from(lp);
29//! lp.remove_row(row);
30//! assert_eq!(lp.num_rows(), 0);
31//! let lp = lp.optimize();
32//! let new_result = lp.status();
33//! assert_eq!(new_result, Status::Optimal);
34//! assert!((lp.obj_val() - 10.0).abs() < 1e-6);
35//!
36//! let mut lp = Model::from(lp);
37//! lp.remove_col(col1);
38//! assert_eq!(lp.num_cols(), 1);
39//! let lp = lp.optimize();
40//! let new_result = lp.status();
41//! assert_eq!(new_result, Status::Optimal);
42//! assert!((lp.obj_val() - 5.0).abs() < 1e-6);
43//! ```
44//!
45//! TODO: Setting parameters
46
47#![deny(missing_docs)]
48
49mod status;
50
51pub use status::*;
52
53/// Re-export of the raw FFI bindings.
54pub mod ffi {
55    pub use soplex_sys::*;
56}
57
58mod basis_status;
59mod model;
60mod param;
61mod soplex_ptr;
62pub use basis_status::*;
63
64pub use param::*;
65
66pub use model::*;