Skip to main content

oximo_pounce/
lib.rs

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