Skip to main content

SolverOptions

Struct SolverOptions 

Source
#[non_exhaustive]
pub struct SolverOptions { pub deterministic: bool, pub scaling_factor: u32, pub selection: ActiveNodeOrder, pub max_operations: Option<u64>, }
Expand description

Knobs for a solve. Defaults are the measured-good settings; every field is a documented trade, not a magic number.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§deterministic: bool

Canonicalise the arc order before solving, so permuted-but-equal instances return the same flow and not merely the same cost.

Costs one sort of the arc list. The solver is deterministic either way; this makes it canonical.

§The exact claim

Canonical up to permutation within a group of identical parallel arcs — arcs agreeing in tail, head, bounds and cost. That caveat is not an implementation shortcut, it is forced: such arcs are indistinguishable, so if the flow were required to be identical under every relabelling of them, they would all have to carry equal flow, and two identical arcs sharing three units of an integral flow cannot. For every distinguishable arc the flow is exactly reproducible, and the multiset of flows over each identical group is too.

§scaling_factor: u32

Scaling factor α: ε shrinks by this much each phase. Clamped to ≥ 2.

Larger α means fewer phases doing more work each.

The default is 32, which is measured, not inherited — and, now that the paper has been verified against, consistent with it: CS 1.0 defaults to α = 12 [cite: GOLDBERG-1997 §4.1] and Goldberg reports the method robust for α between 4 and 50, with differences usually under 2× [cite: GOLDBERG-1997 §7]. (An earlier revision of this crate attributed “8–16” to this paper; the paper says no such thing — that range appears in Király & Kovács as “8 to 24” [cite: KIRALY-KOVACS-2012 §3.3].) This crate shipped 8 until it was measured, at which point α = 32 was 1.9× faster than α = 8 on a 140×140 grid, monotone from 2 to 64 across every family; re-measured unchanged with arc fixing and price refinement on (2026-08-07). The sweep has not been checked against adversarial families, which this crate does not yet generate.

Run cargo run --release --example bench for the current sweep.

§selection: ActiveNodeOrder

Active-node selection order.

§max_operations: Option<u64>

Upper bound on pushes plus relabels, after which the solve gives up with SolveError::OperationBudgetExhausted.

None — the default — means no bound: the algorithm terminates on its own, and an arbitrary cap would turn a slow solve into a wrong answer. The engine sets this when it owns a time budget (design law 4).

Implementations§

Source§

impl SolverOptions

Source

pub fn with_deterministic(self, deterministic: bool) -> Self

Set deterministic.

The struct is #[non_exhaustive], so adding a knob later cannot break a caller — which also means it cannot be built with a struct expression. These setters are how it is configured.

Source

pub fn with_scaling_factor(self, scaling_factor: u32) -> Self

Set scaling_factor. Values below 2 are clamped to 2 at solve time.

Source

pub fn with_selection(self, selection: ActiveNodeOrder) -> Self

Set selection.

Source

pub fn with_max_operations(self, max_operations: Option<u64>) -> Self

Trait Implementations§

Source§

impl Clone for SolverOptions

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 Debug for SolverOptions

Source§

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

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

impl Default for SolverOptions

Source§

fn default() -> Self

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

impl Eq for SolverOptions

Source§

impl PartialEq for SolverOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SolverOptions

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