Expand description
Safe Rust bindings for the SoPlex linear programming solver.
§Example
use soplex_rs::*;
// You can create an LP model using the `add_col` and the `add_row` methods on the `Model`.
let mut lp = Model::new();
// Add column with obj. function value of 1.0 and range from 0 to 5
let col1= lp.add_col(vec![], 1.0, 0.0, 5.0);
// Add column with obj. function value of 1.0 and range from 0 to 5
let col2 = lp.add_col(vec![], 1.0, 0.0, 5.0);
// Add row where both columns have coefficient 1 and the value is between 1 and 5
let row = lp.add_row(vec![1.0, 1.0], 1.0, 5.0);
assert_eq!(lp.num_cols(), 2);
assert_eq!(lp.num_rows(), 1);
// When calling `optimize` you get back a `SolvedModel` where you can query information about the solution
// and basis status of columns and rows.
let lp = lp.optimize();
let result = lp.status();
assert_eq!(result, Status::Optimal);
assert!((lp.obj_val() - 5.0).abs() < 1e-6);
// After solving you need to return the `SolvedModel` object to a `Model` object.
// Then you can add or remove columns and rows and optimize again.
let mut lp = Model::from(lp);
lp.remove_row(row);
assert_eq!(lp.num_rows(), 0);
let lp = lp.optimize();
let new_result = lp.status();
assert_eq!(new_result, Status::Optimal);
assert!((lp.obj_val() - 10.0).abs() < 1e-6);
let mut lp = Model::from(lp);
lp.remove_col(col1);
assert_eq!(lp.num_cols(), 1);
let lp = lp.optimize();
let new_result = lp.status();
assert_eq!(new_result, Status::Optimal);
assert!((lp.obj_val() - 5.0).abs() < 1e-6);
TODO: Setting parameters
Modules§
- ffi
- Re-export of the raw FFI bindings.
Structs§
- Model
- A linear programming model.
- Solved
Model - A solved linear programming model.
Enums§
- Algorithm
- Enum representing the type of algorithm used.
- Bool
Param - Represents the boolean parameters for some LP solver.
- Check
Mode - Enum representing the check mode.
- ColBasis
Status - Column basis status
- Factor
Update Type - Enum representing the factor update type.
- Hyper
Pricing - Enum representing the hyperpricing mode.
- IntParam
- Represents the integer parameters for some LP solver.
- ObjSense
- Enum representing the objective sense for optimization.
- Pricer
- Enum representing the pricer type.
- Ratio
Tester - Enum representing the ratio tester type.
- Read
Mode - Enum representing the read mode.
- Real
Param - Represents the real number parameters for some LP solver.
- Representation
- Enum representing the type of representation.
- RowBasis
Status - Row basis status
- Scalar
- Enum representing the scalar type.
- Simplifier
- Enum representing the simplifier type.
- Solution
Polishing - Enum representing the solution polishing mode.
- Solve
Mode - Enum representing the solve mode.
- Starter
- Enum representing the starter type.
- Status
- Status of the solver
- Sync
Mode - Enum representing the synchronization mode.
- Timer
- Enum representing the timer type.
- Verbosity
- Enum representing verbosity levels.