1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! # simplex-trace
//!
//! A simplex solver for linear programs that uses **exact rational arithmetic** and records
//! **every step** (tableaus, ratio tests, pivots, phase changes) as plain data, so a teaching
//! tool or UI can replay the method exactly as it is done by hand.
//!
//! Supported methods: primal simplex, Big-M (with a symbolic `M`), two-phase and dual simplex.
//! Variables are non-negative unless declared free or non-positive (see [`Sign`]). Every
//! optimal solution includes a [`Sensitivity`] analysis
//! (shadow prices, reduced costs and ranges), and [`reoptimize`] repairs it with dual simplex
//! pivots after constraints are added, instead of solving again.
//!
//! With the **`serde`** feature, [`Problem`], [`Solution`], [`Trace`] and every [`Step`] can be
//! (de)serialized, e.g. to JSON for a web front end. Numbers are exact strings such as `"3/2"`.
//!
//! ```
//! use simplex_trace::{solve, Method, Options, Problem, Relation, Status, ratio};
//!
//! // min 4x1 + x2 s.t. 3x1 + x2 = 3, 4x1 + 3x2 >= 6, x1 + 2x2 <= 4
//! let problem = Problem::minimize([4, 1])
//! .subject_to([3, 1], Relation::Eq, 3)
//! .subject_to([4, 3], Relation::Ge, 6)
//! .subject_to([1, 2], Relation::Le, 4);
//!
//! let solution = solve(&problem, Method::TwoPhase, &Options::default()).unwrap();
//! assert_eq!(
//! solution.status,
//! Status::Optimal { objective: ratio(17, 5), values: vec![ratio(2, 5), ratio(9, 5)] }
//! );
//!
//! // Every tableau and pivot is available for display or replay.
//! for snapshot in solution.trace.tableaus() {
//! println!("{snapshot}");
//! }
//! ```
pub use Error;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// Compile the Rust examples of the README as doctests, so it cannot drift from the API.
;