autoeq-optim 0.5.58

AutoEQ objectives, constraints, and optimizer backends
Documentation
pub use super::backend::{AlgorithmType, FilterOptimizer};

/// Algorithm metadata structure (legacy public surface — derived from the
/// registry now, kept for callers in `cli.rs` that print algorithm tables).
#[derive(Debug, Clone)]
pub struct AlgorithmInfo {
    /// Algorithm name with library prefix (e.g., "autoeq:isres", "mh:de", "autoeq:de")
    pub name: &'static str,
    /// Library providing this algorithm (e.g., "Metaheuristics", "AutoEQ")
    pub library: &'static str,
    /// Classification as global or local optimizer
    pub algorithm_type: AlgorithmType,
    /// Whether the algorithm supports linear constraint handling
    pub supports_linear_constraints: bool,
    /// Whether the algorithm supports nonlinear constraint handling
    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,
        }
    }
}

/// Get all available algorithms with their metadata.
pub fn get_all_algorithms() -> Vec<AlgorithmInfo> {
    super::registry::all_algorithms()
        .iter()
        .map(|b| AlgorithmInfo::from_backend(b.as_ref()))
        .collect()
}

/// Find algorithm metadata by name (prefixed or unprefixed legacy form).
pub fn find_algorithm_info(name: &str) -> Option<AlgorithmInfo> {
    super::registry::resolve(name).map(|b| AlgorithmInfo::from_backend(b.as_ref()))
}