Skip to main content

Lu

Struct Lu 

Source
pub struct Lu<T: Real = f64, U: BasisUpdate<T> = ForrestTomlin<T>> { /* private fields */ }
Expand description

Sparse LU factors of a basis with a basis-update policy U (Forrest–Tomlin by default): the contract’s Lu<T, U>.

Usage contract (the simplex method of Chapter 6), through LuFactor:

  1. LuFactor::factorize with a ColumnSource (the basis heading and A);
  2. LuFactor::ftran / LuFactor::btran any number of times;
  3. to exchange the column at position r: LuFactor::ftran_for_update on the entering column a_q (this yields α_q = B⁻¹ a_q and records the spike), then LuFactor::update(r, α_q[r]);
  4. when the update returns UpdateOutcome::RefactorNeeded (or an error), call LuFactor::factorize with the new heading — the factor never refactorizes by itself, since only the caller holds the columns (D-0016).

Implementations§

Source§

impl<T: Real, U: BasisUpdate<T>> Lu<T, U>

Source

pub fn new(opts: LuOptions) -> Self

An empty factor (no valid factorization yet).

Source

pub fn set_pre_order(&mut self, pre_order: Option<PreOrder>)

The column pre-order of the bump (step L5′; Chapter 5.12): None (the default) runs Algorithm M exactly as before, bit for bit; Some(PreOrder::Colamd) eliminates the bump in the COLAMD order of its columns, choosing the row by threshold partial pivoting. Read at the next LuFactor::factorize.

(The contract has it as a field LuOptions::pre_order; a field would make LuOptions, and the simplex’s SimplexOptions that holds it, 8 bytes larger, past the 256-byte limit of clippy’s large_types_passed_by_value in the simplex and the MIP solver.)

Source

pub fn pre_order(&self) -> Option<PreOrder>

The column pre-order in force (Lu::set_pre_order).

Source

pub fn set_refactor_pivot_tol(&mut self, tol: Option<f64>)

The relative threshold u_R of the replay test of LuFactor::refactorize_same_pattern (step R5 of Chapter 5.12): None (the default) uses LuOptions::rel_pivot_tol, the threshold of the Markowitz search — a replayed sequence is then one Algorithm L would have accepted, (R2); Some(u_R) with 0 < u_R ≤ u accepts the recorded pivots down to u_R times the largest entry of their column, trading a little stability for fewer fallbacks when the values drift (task L1.5b, D8). Never read by LuFactor::factorize (Algorithm L is unchanged). A setter, not a field of LuOptions, for the reason of Lu::set_pre_order.

§Panics

If u_R is not in (0, 1].

Source

pub fn refactor_pivot_tol(&self) -> Option<f64>

The replay threshold in force (Lu::set_refactor_pivot_tol).

Source

pub fn has_spike(&self) -> bool

true iff a spike is recorded and LuFactor::update may be called.

Source

pub fn update_policy(&self) -> &U

The basis-update policy (its statistics and name).

Source§

impl<T: Real, U: BasisUpdate<T>> Lu<T, U>

Source

pub fn expected_densities(&self) -> [f64; 3]

Expected result density of each kind of solve (policy (c)), for diagnostics: [ftran, btran, ftran_for_update].

Trait Implementations§

Source§

impl<T: Clone + Real, U: Clone + BasisUpdate<T>> Clone for Lu<T, U>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Real, U: Debug + BasisUpdate<T>> Debug for Lu<T, U>

Source§

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

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

impl<T: Real, U: BasisUpdate<T>> Default for Lu<T, U>

Source§

fn default() -> Self

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

impl<T: Real, U: BasisUpdate<T>> LuFactor<T> for Lu<T, U>

Source§

fn factorize<C: ColumnSource<T>>(&mut self, cols: &C) -> Result<(), LuError>

Algorithm L: factorizes the m × m basis B whose columns the source gives. Read more
Source§

fn refactorize_same_pattern<C: ColumnSource<T>>( &mut self, cols: &C, ) -> Result<(), LuError>

Algorithm R (Chapter 5.12): factorizes the m × m basis B with the pivot sequence of the last successful factorization — no search, no count lists — as long as every pivot passes the threshold test; otherwise (or without a sequence of order m) it falls back to LuFactor::factorize. Meant for new values on the same pattern; the outcome and the errors are those of factorize, and LuStats::symbolic_reuses / LuStats::symbolic_fallbacks say which path ran.
Source§

fn symbolic(&self) -> Option<&SymbolicLu>

The pivot sequence of the last successful factorization, if any.
Source§

fn ftran(&mut self, v: &mut SparseVec<T>)

v ← B⁻¹ v: row-indexed in, position-indexed out (D-0016).
Source§

fn btran(&mut self, v: &mut SparseVec<T>)

v ← B⁻ᵀ v: position-indexed in, row-indexed out.
Source§

fn ftran_for_update(&mut self, v: &mut SparseVec<T>)

LuFactor::ftran that also records the spike for the next LuFactor::update.
Source§

fn update(&mut self, r: usize, alpha_r: T) -> Result<UpdateOutcome, LuError>

Replaces the column at position r; alpha_r is entry r of the α_q returned by the last ftran_for_update. The factor never refactorizes on its own.
Source§

fn m(&self) -> usize

Dimension m of the last basis given to factorize.
Source§

fn is_valid(&self) -> bool

true iff the factor holds a valid factorization (the last factorize succeeded).
Source§

fn stats(&self) -> &LuStats

Statistics of the current factor.
Source§

fn update_stats(&self) -> &UpdateStats

Statistics of the update policy since the last factorization.
Source§

fn options(&self) -> &LuOptions

The options in force.
Source§

fn set_options(&mut self, opts: LuOptions)

Replaces the options. The factorization reads them at the next factorize, the solves and the update at their next call (e.g. a tighter LuOptions::rel_pivot_tol after numerical trouble, PLAN.md §8).
Source§

fn check_invariants(&self) -> Result<(), SparseError>

Checks invariants (F1)–(F3) of a valid factor (and of its updates).

Auto Trait Implementations§

§

impl<T, U> Forget for Lu<T, U>

§

impl<T, U> Freeze for Lu<T, U>
where Factors<T>: Freeze, U: Freeze,

§

impl<T, U> RefUnwindSafe for Lu<T, U>

§

impl<T, U> Send for Lu<T, U>
where Factors<T>: Send, U: Send,

§

impl<T, U> Sync for Lu<T, U>
where Factors<T>: Sync, U: Sync,

§

impl<T, U> Unpin for Lu<T, U>
where Factors<T>: Unpin, U: Unpin,

§

impl<T, U> UnsafeUnpin for Lu<T, U>

§

impl<T, U> UnwindSafe for Lu<T, U>

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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

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> Imply<T> for U
where T: ?Sized, U: ?Sized,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.