Skip to main content

ProfiledSolver

Struct ProfiledSolver 

Source
pub struct ProfiledSolver<S: SolverInterface> { /* private fields */ }
Expand description

Wraps any SolverInterface implementor with per-phase profile configuration.

Tracks the currently-applied profile and skips no-op FFI calls when the same profile is reapplied. The wrapper itself implements SolverInterface by transparently forwarding all method calls to the inner solver. ProfiledSolver::set_profile is the only non-trait-method addition.

§Generic parameter

S must implement SolverInterface. The wrapper is resolved at compile time (monomorphization) to preserve zero-cost forwarding on the hot path.

Implementations§

Source§

impl<S: SolverInterface> ProfiledSolver<S>

Source

pub fn new(inner: S) -> Self

Wrap an existing solver with the default profile.

The wrapper does NOT issue any FFI calls on construction — the inner solver is assumed to be in a state consistent with SolveProfile::default(), which is exactly how it has been constructed historically.

Source

pub fn set_profile(&mut self, profile: &SolveProfile)

Apply a new profile to the inner solver.

Only fields that differ from current_profile trigger trait-method calls on the inner solver. The dispatch order is deterministic: primal feasibility → dual feasibility → simplex cap → IPM cap.

If profile == current_profile, this method returns immediately with zero inner method calls.

After the call returns, current_profile() == profile.

§Call-site contract

Callers invoke this once per phase boundary. It is NOT intended to be called inside the hot solve loop.

Source

pub fn current_profile(&self) -> &SolveProfile

Read-only access to the currently applied profile.

Returns the profile that was last successfully applied via ProfiledSolver::set_profile, or SolveProfile::default() if no profile has been applied yet.

Source

pub fn inner(&self) -> &S

Shared reference to the wrapped inner solver.

Intended for test code and rare adapter sites that need to inspect mock-specific fields on the inner solver. Not used on the hot path.

Source

pub fn inner_mut(&mut self) -> &mut S

Exclusive reference to the wrapped inner solver.

Intended for test code and rare adapter sites that need to mutate mock-specific state on the inner solver. Not used on the hot path.

Trait Implementations§

Source§

impl<S: SolverInterface> SolverInterface for ProfiledSolver<S>

Source§

fn load_model(&mut self, template: &StageTemplate)

Bulk-loads a pre-assembled structural LP (first step of rebuild sequence). Read more
Source§

fn add_rows(&mut self, rows: &RowBatch)

Append constraint rows to the dynamic constraint region. Read more
Source§

fn set_row_bounds(&mut self, indices: &[usize], lower: &[f64], upper: &[f64])

Updates row bounds (step 3 of rebuild; patching for scenario realization). Read more
Source§

fn set_col_bounds(&mut self, indices: &[usize], lower: &[f64], upper: &[f64])

Updates column bounds (per-scenario variable bound patching). Read more
Source§

fn solve( &mut self, basis: Option<&Basis>, ) -> Result<SolutionView<'_>, SolverError>

Solve the LP currently loaded on the backend. Read more
Source§

fn get_basis(&mut self, out: &mut Basis)

Writes solver-native i32 status codes into a caller-owned Basis buffer. Read more
Source§

fn statistics(&self) -> SolverStatistics

Returns accumulated solve metrics (snapshot of monotonically increasing counters). Read more
Source§

fn name(&self) -> &'static str

Returns a static string identifying the solver backend (e.g., "HiGHS"). Read more
Source§

fn solver_name_version(&self) -> String

Returns the solver name and version as a human-readable string. Read more
Source§

fn record_reconstruction_stats(&mut self)

Record that reconstruct_basis applied a stored basis via slot reconciliation. Default implementation is a no-op; HighsSolver overrides to increment SolverStatistics::basis_reconstructions by 1. A non-zero count indicates basis reconstruction is active on this solver instance.
Source§

fn set_primal_feasibility_tolerance(&mut self, value: f64)

Set the LP solver’s primal feasibility tolerance. Read more
Source§

fn set_dual_feasibility_tolerance(&mut self, value: f64)

Set the LP solver’s dual feasibility tolerance. Read more
Source§

fn set_simplex_iteration_limit_profile(&mut self, value: u32)

Set the per-attempt simplex iteration cap. Read more
Source§

fn set_ipm_iteration_limit_profile(&mut self, value: u32)

Set the per-attempt IPM iteration cap. Read more

Auto Trait Implementations§

§

impl<S> Freeze for ProfiledSolver<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for ProfiledSolver<S>
where S: RefUnwindSafe,

§

impl<S> Send for ProfiledSolver<S>

§

impl<S> Sync for ProfiledSolver<S>
where S: Sync,

§

impl<S> Unpin for ProfiledSolver<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for ProfiledSolver<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for ProfiledSolver<S>
where S: UnwindSafe,

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