Crate soplex_rs

Source
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.
SolvedModel
A solved linear programming model.

Enums§

Algorithm
Enum representing the type of algorithm used.
BoolParam
Represents the boolean parameters for some LP solver.
CheckMode
Enum representing the check mode.
ColBasisStatus
Column basis status
FactorUpdateType
Enum representing the factor update type.
HyperPricing
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.
RatioTester
Enum representing the ratio tester type.
ReadMode
Enum representing the read mode.
RealParam
Represents the real number parameters for some LP solver.
Representation
Enum representing the type of representation.
RowBasisStatus
Row basis status
Scalar
Enum representing the scalar type.
Simplifier
Enum representing the simplifier type.
SolutionPolishing
Enum representing the solution polishing mode.
SolveMode
Enum representing the solve mode.
Starter
Enum representing the starter type.
Status
Status of the solver
SyncMode
Enum representing the synchronization mode.
Timer
Enum representing the timer type.
Verbosity
Enum representing verbosity levels.

Type Aliases§

ColId
Id of a column in the model.
RowId
Id of a row in the model.