1#![doc = include_str!("../README.md")]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3
4mod options;
5mod persistent;
6mod translate;
7
8pub use options::{ClarabelDirectSolve, ClarabelOptions};
9pub use persistent::ClarabelPersistent;
10pub use translate::solve;
11
12use oximo_core::{Model, ModelKind};
13use oximo_solver::{PersistentSolver, Solver, SolverError, SolverResult};
14
15#[derive(Debug, Default, Clone, Copy)]
21pub struct Clarabel;
22
23pub(crate) const NAME: &str = "Clarabel";
26
27pub(crate) const fn supported(kind: ModelKind) -> bool {
31 matches!(kind, ModelKind::LP | ModelKind::QP | ModelKind::SOCP)
32}
33
34impl Solver for Clarabel {
35 type Options = ClarabelOptions;
36
37 fn name(&self) -> &str {
38 NAME
39 }
40
41 fn supports(&self, kind: ModelKind) -> bool {
42 supported(kind)
43 }
44
45 fn solve(
46 &mut self,
47 model: &Model,
48 opts: &ClarabelOptions,
49 ) -> Result<SolverResult, SolverError> {
50 translate::solve(model, opts)
51 }
52}
53
54impl PersistentSolver for Clarabel {
55 type Handle = ClarabelPersistent;
56
57 fn persistent(&self) -> ClarabelPersistent {
58 ClarabelPersistent::new()
59 }
60}