Skip to main content

oximo_highs/
lib.rs

1#![doc = include_str!("../README.md")]
2#![forbid(unsafe_code)]
3
4mod options;
5mod translate;
6
7pub use options::{HighsMethod, HighsOptions, HighsPresolve};
8pub use translate::solve;
9
10use oximo_core::{Model, ModelKind};
11use oximo_solver::{Solver, SolverError, SolverResult};
12
13/// HiGHS solver handle. Cheap to construct. The actual HiGHS instance is
14/// created per `solve` call so models can be re-used or shared across solves.
15///
16/// TODO: Can we do this better in the future?
17#[derive(Debug, Default, Clone, Copy)]
18pub struct Highs;
19
20/// Display name for this backend; the single source for both [`Solver::name`]
21/// and the `solver_name` stamped on every [`SolverResult`].
22pub(crate) const NAME: &str = "HiGHS";
23
24impl Solver for Highs {
25    type Options = HighsOptions;
26
27    fn name(&self) -> &str {
28        NAME
29    }
30
31    fn supports(&self, kind: ModelKind) -> bool {
32        matches!(kind, ModelKind::LP | ModelKind::MILP | ModelKind::QP)
33    }
34
35    fn solve(&mut self, model: &Model, opts: &HighsOptions) -> Result<SolverResult, SolverError> {
36        translate::solve(model, opts)
37    }
38}