#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.deterministic: boolCanonicalise 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: u32Scaling 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: ActiveNodeOrderActive-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
impl SolverOptions
Sourcepub fn with_deterministic(self, deterministic: bool) -> Self
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.
Sourcepub fn with_scaling_factor(self, scaling_factor: u32) -> Self
pub fn with_scaling_factor(self, scaling_factor: u32) -> Self
Set scaling_factor. Values below 2 are
clamped to 2 at solve time.
Sourcepub fn with_selection(self, selection: ActiveNodeOrder) -> Self
pub fn with_selection(self, selection: ActiveNodeOrder) -> Self
Set selection.
Sourcepub fn with_max_operations(self, max_operations: Option<u64>) -> Self
pub fn with_max_operations(self, max_operations: Option<u64>) -> Self
Set max_operations.