Skip to main content

oximo_pounce/
lib.rs

1#![doc = include_str!("../README.md")]
2#![forbid(unsafe_code)]
3
4mod convex;
5mod fbbt;
6mod options;
7mod persistent;
8mod tnlp;
9mod translate;
10
11#[cfg(feature = "enzyme")]
12mod exact;
13#[cfg(not(feature = "enzyme"))]
14mod hybrid;
15#[cfg(not(feature = "enzyme"))]
16mod stable;
17
18#[cfg(all(feature = "benchmark-support", not(feature = "enzyme")))]
19#[doc(hidden)]
20pub use hybrid::benchmark_support;
21
22pub use options::{
23    MuStrategy, PounceAlgorithm, PounceOptionValue, PounceOptions, PounceSolverSelection,
24};
25pub use persistent::PouncePersistent;
26
27/// The POUNCE backend:
28/// specialized convex LP/QP/SOCP engines with a general IPOPT-lineage
29/// QCP/NLP fallback.
30///
31/// On stable Rust an all-linear/quadratic model gets exact analytic
32/// derivatives (including the Hessian).
33/// A model with nonlinear functions is handed to POUNCE's builder, which
34/// finite-differences them with an L-BFGS Hessian. With the `enzyme`
35/// feature everything is exact via `oximo-autodiff`.
36#[derive(Clone, Copy, Debug, Default)]
37pub struct Pounce;
38
39impl oximo_solver::Solver for Pounce {
40    type Options = PounceOptions;
41
42    fn name(&self) -> &str {
43        "pounce"
44    }
45
46    fn supports(&self, kind: oximo_core::ModelKind) -> bool {
47        use oximo_core::ModelKind;
48        matches!(
49            kind,
50            ModelKind::LP | ModelKind::QP | ModelKind::QCP | ModelKind::SOCP | ModelKind::NLP
51        )
52    }
53
54    fn solve(
55        &mut self,
56        model: &oximo_core::Model,
57        opts: &Self::Options,
58    ) -> Result<oximo_solver::SolverResult, oximo_solver::SolverError> {
59        translate::solve(model, opts)
60    }
61}
62
63impl oximo_solver::PersistentSolver for Pounce {
64    type Handle = PouncePersistent;
65
66    fn persistent(&self) -> Self::Handle {
67        PouncePersistent::new()
68    }
69}