Skip to main content

Module solver

Module solver 

Source
Expand description

Pure-Rust Cassowary linear constraint solver.

Implements the dual-phase simplex restricted tableau (Badros & Borning 1997), faithful to the cassowary-rs / kiwi reference structure. No external crates are used.

§Quick start

use oxiui_core::solver::{Solver, Variable, Constraint, Expression, Term, RelOp, Strength};

let mut solver = Solver::new();
let x = Variable::new();
solver.add_constraint(Constraint::new(
    Expression::new(vec![Term { variable: x.clone(), coefficient: 1.0 }], -42.0),
    RelOp::Equal,
    Strength::REQUIRED,
)).unwrap();
solver.update_variables();
assert!((solver.value_of(&x) - 42.0).abs() < 1e-6);

Structs§

Constraint
A linear constraint with a relational operator and a priority strength.
Expression
A linear expression: Σ coefficient·variable + constant.
Solver
The Cassowary incremental constraint solver.
Strength
Predefined constraint strengths.
Term
A variable multiplied by a coefficient.
Variable
A layout variable whose value is determined by the constraint solver.

Enums§

RelOp
Relational operator for a constraint.
SolverError
Errors produced by the solver.