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::{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
41impl Solver for Baron {
42 type Options = BaronOptions;
43
44 fn name(&self) -> &str {
45 "baron"
46 }
47
48 fn supports(&self, kind: ModelKind) -> bool {
49 matches!(
51 kind,
52 ModelKind::LP
53 | ModelKind::MILP
54 | ModelKind::QP
55 | ModelKind::MIQP
56 | ModelKind::NLP
57 | ModelKind::MINLP
58 )
59 }
60
61 fn solve(&mut self, model: &Model, opts: &BaronOptions) -> Result<SolverResult, SolverError> {
62 translate::solve(model, opts, self.exec.as_deref())
63 }
64}