Skip to main content

multi_func

Function multi_func 

Source
pub fn multi_func<F>(
    bounds: Vec<Bound>,
    n_objectives: usize,
    f: F,
) -> MultiFunc<F>
where F: Fn(&[f64]) -> Vec<f64>,
Expand description

A MultiProblem defined inline by a closure, a bounds vector, and an objective count.

use forge_core::problem::{multi_func, MultiProblem};
// Schaffer N.1: minimize x² and (x−2)² on [-5, 5].
let sch = multi_func(vec![(-5.0, 5.0)], 2, |x| vec![x[0] * x[0], (x[0] - 2.0).powi(2)]);
assert_eq!(sch.n_objectives(), 2);
assert_eq!(sch.objectives(&[1.0]), vec![1.0, 1.0]);