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 thirteen default options defined in HiGHS Implementation SS4.1:
| Option | Value | Type |
|---|---|---|
solver | "simplex" | string |
simplex_strategy | 1 | int |
simplex_scale_strategy | 0 | int |
presolve | "off" | string |
parallel | "off" | string |
output_flag | 0 | bool |
primal_feasibility_tolerance | 1e-7 | double |
dual_feasibility_tolerance | 1e-7 | double |
simplex_dual_edge_weight_strategy | 1 | int |
dual_simplex_cost_perturbation_multiplier | 0.0 | double |
simplex_initial_condition_check | 0 | bool |
simplex_price_strategy | 1 | int |
rebuild_refactor_solution_error_tolerance | 1e-6 | 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 solve(
&mut self,
basis: Option<&Basis>,
) -> Result<SolutionView<'_>, SolverError>
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 name(&self) -> &'static str
fn name(&self) -> &'static str
"HiGHS"). Read moreSource§fn solver_name_version(&self) -> String
fn solver_name_version(&self) -> String
Source§fn load_model(&mut self, template: &StageTemplate)
fn load_model(&mut self, template: &StageTemplate)
Source§fn add_rows(&mut self, rows: &RowBatch)
fn add_rows(&mut self, rows: &RowBatch)
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])
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])
Source§fn statistics(&self) -> SolverStatistics
fn statistics(&self) -> SolverStatistics
Source§fn record_reconstruction_stats(&mut self)
fn record_reconstruction_stats(&mut self)
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.