pub struct SimplexTableau { /* private fields */ }Expand description
The Simplex tableau.
Implementations§
Source§impl SimplexTableau
impl SimplexTableau
Sourcepub fn add_var(
&mut self,
lower: Option<BigRational>,
upper: Option<BigRational>,
) -> VarId
pub fn add_var( &mut self, lower: Option<BigRational>, upper: Option<BigRational>, ) -> VarId
Add a variable with initial bounds.
Sourcepub fn add_row(&mut self, row: Row) -> Result<(), String>
pub fn add_row(&mut self, row: Row) -> Result<(), String>
Add a row to the tableau. The row represents: basic_var = constant + sum(coeffs).
Sourcepub fn add_bound(
&mut self,
var: VarId,
bound_type: BoundType,
value: BigRational,
constraint_id: ConstraintId,
) -> Result<(), Conflict>
pub fn add_bound( &mut self, var: VarId, bound_type: BoundType, value: BigRational, constraint_id: ConstraintId, ) -> Result<(), Conflict>
Add a bound constraint.
Sourcepub fn get_value(&self, var: VarId) -> Option<&BigRational>
pub fn get_value(&self, var: VarId) -> Option<&BigRational>
Get the current assignment to a variable.
Sourcepub fn pivot(
&mut self,
basic_var: VarId,
non_basic_var: VarId,
) -> Result<(), String>
pub fn pivot( &mut self, basic_var: VarId, non_basic_var: VarId, ) -> Result<(), String>
Perform a pivot operation. Swap basic_var (currently basic) with non_basic_var (currently non-basic).
Sourcepub fn check(&mut self) -> Result<SimplexResult, Conflict>
pub fn check(&mut self) -> Result<SimplexResult, Conflict>
Check feasibility and fix violations using pivoting.
Sourcepub fn check_dual(&mut self) -> Result<SimplexResult, Conflict>
pub fn check_dual(&mut self) -> Result<SimplexResult, Conflict>
Dual simplex algorithm for Linear Programming.
The dual simplex maintains dual feasibility (all reduced costs non-negative) while working toward primal feasibility (all variables within bounds).
This is particularly useful for:
- Reoptimization after adding constraints
- Branch-and-bound in integer programming
- Problems that naturally start dual-feasible
Reference: Standard LP textbooks and Z3’s dual simplex implementation.
Sourcepub fn basic_vars(&self) -> Vec<VarId> ⓘ
pub fn basic_vars(&self) -> Vec<VarId> ⓘ
Get all basic variables.
Sourcepub fn non_basic_vars(&self) -> Vec<VarId> ⓘ
pub fn non_basic_vars(&self) -> Vec<VarId> ⓘ
Get all non-basic variables.
Sourcepub fn set_blands_rule(&mut self, enable: bool)
pub fn set_blands_rule(&mut self, enable: bool)
Enable or disable Bland’s anti-cycling rule.
Sourcepub fn get_model(&self) -> Option<FxHashMap<VarId, BigRational>>
pub fn get_model(&self) -> Option<FxHashMap<VarId, BigRational>>
Get the current model (satisfying assignment). Returns None if the system is not known to be satisfiable.
Sourcepub fn is_feasible(&self) -> bool
pub fn is_feasible(&self) -> bool
Check if the current assignment satisfies all bounds.
Sourcepub fn find_violated_bound(&self) -> Option<VarId>
pub fn find_violated_bound(&self) -> Option<VarId>
Find a variable that violates its bounds, if any.
Sourcepub fn get_constraints(&self, var: VarId) -> Vec<ConstraintId> ⓘ
pub fn get_constraints(&self, var: VarId) -> Vec<ConstraintId> ⓘ
Get all constraints associated with a variable.
Sourcepub fn get_unsat_core(&self, conflict: &Conflict) -> Vec<ConstraintId> ⓘ
pub fn get_unsat_core(&self, conflict: &Conflict) -> Vec<ConstraintId> ⓘ
Extract a minimal conflicting core from constraints. This is a simple implementation that returns all constraints involved. A more sophisticated version would compute a true minimal unsat core.
Sourcepub fn propagate(&self) -> Vec<(VarId, BoundType, BigRational)>
pub fn propagate(&self) -> Vec<(VarId, BoundType, BigRational)>
Theory propagation: deduce new bounds from existing constraints. Returns a list of (var, bound_type, value) tuples representing deduced bounds.
Sourcepub fn assert_constraint(
&mut self,
coeffs: FxHashMap<VarId, BigRational>,
constant: BigRational,
bound_type: BoundType,
constraint_id: ConstraintId,
) -> Result<VarId, Conflict>
pub fn assert_constraint( &mut self, coeffs: FxHashMap<VarId, BigRational>, constant: BigRational, bound_type: BoundType, constraint_id: ConstraintId, ) -> Result<VarId, Conflict>
Assert a linear constraint: sum(coeffs) + constant {<=, >=, ==} 0. Returns a new slack variable if needed, and the constraint ID.
Trait Implementations§
Source§impl Clone for SimplexTableau
impl Clone for SimplexTableau
Source§fn clone(&self) -> SimplexTableau
fn clone(&self) -> SimplexTableau
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more