Skip to main content

cobre_solver/
profile.rs

1//! Sentinel constants for LP-solver profile iteration limits.
2//!
3//! These constants are referenced by both `HighsProfile` and the individual
4//! `SolverInterface` setter methods that accept raw iteration counts.
5
6/// Sentinel `u32` value indicating "use the historical heuristic
7/// `num_cols * 50 max 100_000`" for the simplex iteration limit.
8///
9/// When `HighsProfile::simplex_iteration_limit` equals this
10/// value, solver implementations MUST fall back to their per-call heuristic
11/// rather than applying a flat iteration cap. Any non-zero value is applied
12/// verbatim as the cap.
13///
14/// `0` is chosen as the sentinel because zero iterations is nonsensical for
15/// any LP solver; legitimate iteration caps are always positive.
16pub const DEFAULT_PROFILE_HEURISTIC_SENTINEL: u32 = 0;
17
18/// Sentinel `u32` value indicating "unbounded" for the IPM iteration limit.
19///
20/// When `HighsProfile::ipm_iteration_limit` equals this value,
21/// solver implementations MUST apply no cap (i.e., pass `i32::MAX` to the
22/// underlying solver). Any positive value is applied verbatim as the cap.
23///
24/// `0` is chosen as the sentinel because zero IPM iterations is nonsensical;
25/// legitimate iteration caps are always positive.
26pub const DEFAULT_PROFILE_IPM_UNBOUNDED_SENTINEL: u32 = 0;
27
28/// Backend-agnostic, fieldless profile type for in-crate test mocks.
29///
30/// This exists so that test-only `SolverInterface` implementations need not name
31/// `HighsProfile`, which is only available under `#[cfg(feature = "highs")]`. As
32/// a zero-field unit struct it trivially satisfies the
33/// `SolverInterface::Profile` bound (`Copy + PartialEq + Default + Send`). It is
34/// strictly test-only and must never be exported from the public API surface.
35#[cfg(test)]
36#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
37pub(crate) struct MockProfile;