Skip to main content

Crate lcp_solver

Crate lcp_solver 

Source
Expand description

Lemke’s algorithm for the Linear Complementarity Problem (LCP).

Given a matrix M (n x n) and a vector q (n), find w, z in R^n such that

w = M z + q
w >= 0
z >= 0
w . z = 0        (complementary: for every i, w_i == 0 or z_i == 0)

This is the numerical primitive general-simulator uses to decide, once per timestep, which linear segment of each piecewise-linear device (ideal diode, ideal switch) is active — replacing Newton-Raphson + voltage limiting entirely. See docs/architecture.md in this repository for how device segments map onto (M, q).

This crate has no knowledge of circuits, devices, or general-mna; it only implements the LCP numerics, so it can be tested and trusted in isolation first (see tests/fixtures.rs for hand-solved textbook cases).

Structs§

Solution

Enums§

LcpError

Functions§

solve
Solve w = M z + q, w, z >= 0, w . z = 0 via Lemke’s algorithm.
solve_with_covering_vector
Same as solve but with an explicit covering vector d (must be strictly positive for Lemke’s algorithm’s feasibility argument to hold).