Skip to main content

hill_climbing

Function hill_climbing 

Source
pub fn hill_climbing<S, N, O>(
    initial: S,
    neighbors: N,
    objective: O,
    max_iter: usize,
) -> (S, f64)
where S: Clone, N: Fn(&S) -> Vec<S>, O: Fn(&S) -> f64,
Expand description

Generic hill-climbing: from initial, repeatedly move to the best improving neighbour until none improves (a local minimum) or max_iter is reached. neighbors enumerates candidate moves; objective is minimized.