Skip to main content

HighsSolver

Struct HighsSolver 

Source
pub struct HighsSolver { /* private fields */ }
Expand description

HiGHS LP solver instance implementing SolverInterface.

Owns an opaque HiGHS handle and pre-allocated buffers for solution extraction, scratch i32 index conversion, and statistics accumulation.

Construct with HighsSolver::new. The handle is destroyed automatically when the instance is dropped.

§Example

use cobre_solver::{HighsSolver, SolverInterface};

let solver = HighsSolver::new().expect("HiGHS initialisation failed");
assert_eq!(solver.name(), "HiGHS");

Implementations§

Source§

impl HighsSolver

Source

pub fn new() -> Result<Self, SolverError>

Creates a new HiGHS solver instance with performance-tuned defaults.

Calls cobre_highs_create() to allocate the HiGHS handle, then applies the thirteen default options defined in HiGHS Implementation SS4.1:

OptionValueType
solver"simplex"string
simplex_strategy1int
simplex_scale_strategy0int
presolve"off"string
parallel"off"string
output_flag0bool
primal_feasibility_tolerance1e-7double
dual_feasibility_tolerance1e-7double
simplex_dual_edge_weight_strategy1int
dual_simplex_cost_perturbation_multiplier0.0double
simplex_initial_condition_check0bool
simplex_price_strategy1int
rebuild_refactor_solution_error_tolerance1e-6double
§Errors

Returns Err(SolverError::InternalError { .. }) if:

  • cobre_highs_create() returns a null pointer.
  • Any configuration call returns HIGHS_STATUS_ERROR.

In both failure cases the HiGHS handle is destroyed before returning to prevent a resource leak.

Trait Implementations§

Source§

impl Drop for HighsSolver

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl SolverInterface for HighsSolver

Source§

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

§Preconditions

When basis is Some(b), the caller must size b.row_status to exactly self.num_rows (the current LP row count). Callers that grow the LP by adding rows are responsible for reconciling their basis to the new row count before invoking this method.

Source§

fn set_primal_feasibility_tolerance(&mut self, value: f64)

Configures the primal feasibility tolerance on the underlying HiGHS instance and caches the value in current_profile.

Subsequent solves (default attempt and any retry level that does not override this tolerance) use value as the primal tolerance until another setter call changes it. After retry escalation completes, the solver automatically re-applies the profile tolerances via apply_profile_tolerances — callers do not need to re-call this method.

This is not a hot-path method; it is called by ProfiledSolver::set_profile only when the corresponding field changes.

Source§

fn set_dual_feasibility_tolerance(&mut self, value: f64)

Configures the dual feasibility tolerance on the underlying HiGHS instance and caches the value in current_profile.

Symmetric to Self::set_primal_feasibility_tolerance; see that method for the full contract.

Source§

fn set_simplex_iteration_limit_profile(&mut self, value: u32)

Caches the per-attempt simplex iteration cap in current_profile.

No FFI call is issued here. The actual cap is applied by set_iteration_limits before each solve attempt: a value of DEFAULT_PROFILE_HEURISTIC_SENTINEL (0) causes the heuristic num_cols × 50 max 100_000 to be used; any non-zero value is applied verbatim.

This is not a hot-path method; it is called by ProfiledSolver::set_profile only when the corresponding field changes.

Source§

fn set_ipm_iteration_limit_profile(&mut self, value: u32)

Caches the per-attempt IPM iteration cap in current_profile.

No FFI call is issued here. The actual cap is applied by set_iteration_limits before each solve attempt. Any positive value is applied verbatim; zero is treated as “unbounded” (no cap).

This is not a hot-path method; it is called by ProfiledSolver::set_profile only when the corresponding field changes.

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 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 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 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§

impl Send for HighsSolver

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