Skip to main content

SimplexTableau

Struct SimplexTableau 

Source
pub struct SimplexTableau { /* private fields */ }
Expand description

The Simplex tableau.

Implementations§

Source§

impl SimplexTableau

Source

pub fn new() -> Self

Create a new empty tableau.

Source

pub fn fresh_var(&mut self) -> VarId

Create a fresh variable.

Source

pub fn add_var( &mut self, lower: Option<FastRational>, upper: Option<FastRational>, ) -> VarId

Add a variable with initial bounds.

Source

pub fn add_row(&mut self, row: Row) -> Result<(), String>

Add a row to the tableau. The row represents: basic_var = constant + sum(coeffs).

Source

pub fn add_bound( &mut self, var: VarId, bound_type: BoundType, value: FastRational, constraint_id: ConstraintId, ) -> Result<(), Conflict>

Add a bound constraint.

Source

pub fn get_value(&self, var: VarId) -> Option<&FastRational>

Get the current assignment to a variable.

Source

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).

Source

pub fn check(&mut self) -> Result<SimplexResult, Conflict>

Check feasibility and fix violations using pivoting.

Source

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.

Source

pub fn vars(&self) -> Vec<VarId>

Get all variables.

Source

pub fn basic_vars(&self) -> Vec<VarId>

Get all basic variables.

Source

pub fn non_basic_vars(&self) -> Vec<VarId>

Get all non-basic variables.

Source

pub fn num_rows(&self) -> usize

Get the number of rows in the tableau.

Source

pub fn num_vars(&self) -> usize

Get the number of variables.

Source

pub fn set_blands_rule(&mut self, enable: bool)

Enable or disable Bland’s anti-cycling rule.

Source

pub fn get_model(&self) -> Option<FxHashMap<VarId, FastRational>>

Get the current model (satisfying assignment). Returns None if the system is not known to be satisfiable.

Source

pub fn is_feasible(&self) -> bool

Check if the current assignment satisfies all bounds.

Source

pub fn find_violated_bound(&self) -> Option<VarId>

Find a variable that violates its bounds, if any.

Source

pub fn get_constraints(&self, var: VarId) -> Vec<ConstraintId>

Get all constraints associated with a variable.

Source

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.

Source

pub fn propagate(&self) -> Vec<(VarId, BoundType, FastRational)>

Theory propagation: deduce new bounds from existing constraints. Returns a list of (var, bound_type, value) tuples representing deduced bounds.

Source

pub fn assert_constraint( &mut self, coeffs: FxHashMap<VarId, FastRational>, constant: FastRational, 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

Source§

fn clone(&self) -> SimplexTableau

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SimplexTableau

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SimplexTableau

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for SimplexTableau

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V