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
impl HighsSolver
Sourcepub fn new() -> Result<Self, SolverError>
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 eight default options defined in HiGHS Implementation SS4.1:
| Option | Value | Type |
|---|---|---|
solver | "simplex" | string |
simplex_strategy | 4 | int |
simplex_scale_strategy | 2 | int |
presolve | "off" | string |
parallel | "off" | string |
output_flag | 0 | bool |
primal_feasibility_tolerance | 1e-7 | double |
dual_feasibility_tolerance | 1e-7 | double |
§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
impl Drop for HighsSolver
Source§impl SolverInterface for HighsSolver
impl SolverInterface for HighsSolver
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
Returns a static string identifying the solver backend (e.g.,
"HiGHS"). Read moreSource§fn load_model(&mut self, template: &StageTemplate)
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, cuts: &RowBatch)
fn add_rows(&mut self, cuts: &RowBatch)
Appends constraint rows to the dynamic constraint region (step 2 of rebuild). Read more
Source§fn set_row_bounds(&mut self, indices: &[usize], lower: &[f64], upper: &[f64])
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])
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) -> Result<SolutionView<'_>, SolverError>
fn solve(&mut self) -> Result<SolutionView<'_>, SolverError>
Solves the LP, returning a zero-copy view or terminal error after retry exhaustion. Read more
Source§fn reset(&mut self)
fn reset(&mut self)
Clears internal solver state for error recovery or LP structure change. Read more
Source§fn solve_with_basis(
&mut self,
basis: &Basis,
) -> Result<SolutionView<'_>, SolverError>
fn solve_with_basis( &mut self, basis: &Basis, ) -> Result<SolutionView<'_>, SolverError>
Injects a basis and solves, returning a zero-copy
SolutionView. Read moreSource§fn statistics(&self) -> SolverStatistics
fn statistics(&self) -> SolverStatistics
Returns accumulated solve metrics (snapshot of monotonically increasing counters). Read more
impl Send for HighsSolver
Auto Trait Implementations§
impl Freeze for HighsSolver
impl RefUnwindSafe for HighsSolver
impl !Sync for HighsSolver
impl Unpin for HighsSolver
impl UnsafeUnpin for HighsSolver
impl UnwindSafe for HighsSolver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more