Skip to content

Commit

Permalink
Document example with comments instead
Browse files Browse the repository at this point in the history
  • Loading branch information
mmghannam committed Jul 29, 2024
1 parent 6c73cfc commit 4a848be
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Safe Rust bindings for the SoPlex linear programming solver.
//!
//! # Creating a model
//! You can create an LP model using the `add_col` and the `add_row` methods on the `Model`.
//! ```
//! # Example
//! ```rust
//! // You can create an LP model using the `add_col` and the `add_row` methods on the `Model`.
//! use soplex_rs::*;
//!
//! let mut lp = Model::new();
Expand All @@ -14,22 +14,18 @@
//! 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);
//!```
//!
//! # Solving and getting the result
//! When calling `optimize` you get back a `SolvedModel` where you can query information about the solution
//! and basis status of columns and rows.
//!```rust
//! // 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);
//! ```
//!
//! # Updating the model and resolving
//! After solving you need to return the `SolvedModel` object to a `Model` object as in
//! the example below.
//! ```rust
//!
//! // After solving you need to return the `SolvedModel` object to a `Model` object as in
//! // the example below.
//!
//! let mut lp = Model::from(lp); // Convert the solved model back to a mutable one
//! lp.remove_row(row);
//! assert_eq!(lp.num_rows(), 0);
Expand Down

0 comments on commit 4a848be

Please sign in to comment.