#![doc = include_str!("../README.md")]
#![forbid(unsafe_code)]
mod options;
mod translate;
pub use options::BaronOptions;
pub use translate::solve;
use oximo_core::{Model, ModelKind};
use oximo_solver::{Solver, SolverError, SolverResult};
#[derive(Debug, Default, Clone)]
pub struct Baron {
pub exec: Option<String>,
}
impl Baron {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn with_exec(path: impl Into<String>) -> Self {
Self { exec: Some(path.into()) }
}
}
impl Solver for Baron {
type Options = BaronOptions;
fn name(&self) -> &str {
"baron"
}
fn supports(&self, kind: ModelKind) -> bool {
matches!(
kind,
ModelKind::LP
| ModelKind::MILP
| ModelKind::QP
| ModelKind::MIQP
| ModelKind::NLP
| ModelKind::MINLP
)
}
fn solve(&mut self, model: &Model, opts: &BaronOptions) -> Result<SolverResult, SolverError> {
translate::solve(model, opts, self.exec.as_deref())
}
}