1#![doc = include_str!("../README.md")]
2#![forbid(unsafe_code)]
3
4mod options;
9mod translate;
10
11pub use options::BaronOptions;
12pub use translate::solve;
13
14use oximo_core::{Model, ModelKind};
15use oximo_solver::{Iis, InfeasibilityDiagnosis, Solver, SolverError, SolverResult};
16
17#[derive(Debug, Default, Clone)]
20pub struct Baron {
21 pub exec: Option<String>,
25}
26
27impl Baron {
28 #[must_use]
30 pub fn new() -> Self {
31 Self::default()
32 }
33
34 #[must_use]
36 pub fn with_exec(path: impl Into<String>) -> Self {
37 Self { exec: Some(path.into()) }
38 }
39}
40
41pub(crate) const NAME: &str = "BARON";
44
45pub(crate) const fn supported(kind: ModelKind) -> bool {
46 matches!(
47 kind,
48 ModelKind::LP
49 | ModelKind::MILP
50 | ModelKind::QP
51 | ModelKind::MIQP
52 | ModelKind::QCP
53 | ModelKind::MIQCP
54 | ModelKind::SOCP
55 | ModelKind::MISOCP
56 | ModelKind::NLP
57 | ModelKind::MINLP
58 )
59}
60
61impl Solver for Baron {
62 type Options = BaronOptions;
63
64 fn name(&self) -> &str {
65 NAME
66 }
67
68 fn supports(&self, kind: ModelKind) -> bool {
69 supported(kind)
70 }
71
72 fn solve(&mut self, model: &Model, opts: &BaronOptions) -> Result<SolverResult, SolverError> {
73 translate::solve(model, opts, self.exec.as_deref())
74 }
75}
76
77impl InfeasibilityDiagnosis for Baron {
78 fn compute_iis(&mut self, model: &Model, opts: &BaronOptions) -> Result<Iis, SolverError> {
79 translate::compute_iis(model, opts, self.exec.as_deref())
80 }
81}