pub use super::backend::{AlgorithmType, FilterOptimizer};
#[derive(Debug, Clone)]
pub struct AlgorithmInfo {
pub name: &'static str,
pub library: &'static str,
pub algorithm_type: AlgorithmType,
pub supports_linear_constraints: bool,
pub supports_nonlinear_constraints: bool,
}
impl AlgorithmInfo {
pub(super) fn from_backend(backend: &dyn FilterOptimizer) -> Self {
let caps = backend.capabilities();
Self {
name: backend.name(),
library: backend.library(),
algorithm_type: backend.algorithm_type(),
supports_linear_constraints: caps.linear,
supports_nonlinear_constraints: caps.nonlinear_ineq,
}
}
}
pub fn get_all_algorithms() -> Vec<AlgorithmInfo> {
super::registry::all_algorithms()
.iter()
.map(|b| AlgorithmInfo::from_backend(b.as_ref()))
.collect()
}
pub fn find_algorithm_info(name: &str) -> Option<AlgorithmInfo> {
super::registry::resolve(name).map(|b| AlgorithmInfo::from_backend(b.as_ref()))
}