Skip to main content

oximo_pounce/
lib.rs

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