use crate::core::candidate::Candidate;
use crate::core::problem::Problem;
#[cfg(feature = "parallel")]
pub(crate) fn evaluate_batch<P>(
problem: &P,
decisions: Vec<P::Decision>,
) -> Vec<Candidate<P::Decision>>
where
P: Problem + Sync,
P::Decision: Send,
{
use rayon::prelude::*;
decisions
.into_par_iter()
.map(|d| {
let e = problem.evaluate(&d);
Candidate::new(d, e)
})
.collect()
}
#[cfg(not(feature = "parallel"))]
pub(crate) fn evaluate_batch<P>(
problem: &P,
decisions: Vec<P::Decision>,
) -> Vec<Candidate<P::Decision>>
where
P: Problem + Sync,
P::Decision: Send,
{
decisions
.into_iter()
.map(|d| {
let e = problem.evaluate(&d);
Candidate::new(d, e)
})
.collect()
}