Skip to main content

cobre_solver/
lib.rs

1//! # cobre-solver
2//!
3//! LP/MIP solver abstraction for the [Cobre](https://github.com/cobre-rs/cobre) power systems ecosystem.
4//!
5//! This crate defines a backend-agnostic interface for mathematical programming
6//! solvers, with a default [HiGHS](https://highs.dev) backend:
7//!
8//! - **Solver trait**: unified API for LP and MIP problem construction, solving,
9//!   and dual/basis extraction.
10//! - **`HiGHS` backend**: production-grade open-source solver, well-suited for
11//!   iterative LP solving in power system optimization.
12//! - **Basis management**: warm-starting support for iterative algorithms
13//!   that solve sequences of related LPs.
14//!
15//! Additional solver backends (e.g., Clp, CPLEX, Gurobi) can be added
16//! behind feature flags.
17//!
18//! ## Status
19//!
20//! This crate is in early development. The API **will** change.
21//!
22//! See the [repository](https://github.com/cobre-rs/cobre) for the full roadmap.
23
24// Relax strict production lints for test builds. These lints (unwrap_used,
25// expect_used, etc.) guard library code but are normal in tests.
26#![cfg_attr(
27    test,
28    allow(
29        clippy::unwrap_used,
30        clippy::expect_used,
31        clippy::float_cmp,
32        clippy::panic,
33        clippy::too_many_lines
34    )
35)]
36
37#[cfg(feature = "highs")]
38mod ffi;
39
40pub mod trait_def;
41pub use trait_def::SolverInterface;
42
43pub mod types;
44pub use types::{
45    Basis, LpSolution, RowBatch, SolutionView, SolverError, SolverStatistics, StageTemplate,
46};
47
48#[cfg(feature = "highs")]
49pub mod highs;
50#[cfg(feature = "highs")]
51pub use highs::HighsSolver;
52
53#[cfg(feature = "test-support")]
54pub mod test_support {
55    //! Test-only utilities for configuring solver options from integration tests.
56    //!
57    //! Do **not** enable this feature in production builds. The re-exported functions
58    //! call into the `HiGHS` C API directly and bypass all safe-wrapper validation.
59
60    pub use crate::ffi::{
61        cobre_highs_set_double_option, cobre_highs_set_int_option, cobre_highs_set_string_option,
62    };
63}