lcp_solver/lib.rs
1//! Lemke's algorithm for the Linear Complementarity Problem (LCP).
2//!
3//! Given a matrix `M` (n x n) and a vector `q` (n), find `w, z in R^n` such that
4//!
5//! ```text
6//! w = M z + q
7//! w >= 0
8//! z >= 0
9//! w . z = 0 (complementary: for every i, w_i == 0 or z_i == 0)
10//! ```
11//!
12//! This is the numerical primitive `general-simulator` uses to decide, once per timestep, which
13//! linear segment of each piecewise-linear device (ideal diode, ideal switch) is active — replacing
14//! Newton-Raphson + voltage limiting entirely. See `docs/architecture.md` in this repository
15//! for how device segments map onto `(M, q)`.
16//!
17//! This crate has no knowledge of circuits, devices, or `general-mna`; it only implements the
18//! LCP numerics, so it can be tested and trusted in isolation first (see `tests/fixtures.rs`
19//! for hand-solved textbook cases).
20
21mod lemke;
22mod tableau;
23
24pub use lemke::{solve, solve_with_covering_vector, LcpError, Solution};