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