pub trait HeuristicContext: Send + Sync {
    type Objective: HeuristicObjective<Solution = Self::Solution>;
    type Solution: HeuristicSolution;

    // Required methods
    fn objective(&self) -> &Self::Objective;
    fn selected<'a>(&'a self) -> Box<dyn Iterator<Item = &Self::Solution> + 'a>;
    fn ranked<'a>(
        &'a self
    ) -> Box<dyn Iterator<Item = (&Self::Solution, usize)> + 'a>;
    fn statistics(&self) -> &HeuristicStatistics;
    fn selection_phase(&self) -> SelectionPhase;
    fn environment(&self) -> &Environment;
    fn on_initial(&mut self, solution: Self::Solution, item_time: Timer);
    fn on_generation(
        &mut self,
        offspring: Vec<Self::Solution>,
        termination_estimate: f64,
        generation_time: Timer
    );
    fn on_result(self) -> HeuristicResult<Self::Objective, Self::Solution>;
}
Expand description

Represents heuristic context.

Required Associated Types§

source

type Objective: HeuristicObjective<Solution = Self::Solution>

A heuristic objective function type.

source

type Solution: HeuristicSolution

A heuristic solution type.

Required Methods§

source

fn objective(&self) -> &Self::Objective

Returns objective function used by the population.

source

fn selected<'a>(&'a self) -> Box<dyn Iterator<Item = &Self::Solution> + 'a>

Returns selected solutions base on current context.

source

fn ranked<'a>( &'a self ) -> Box<dyn Iterator<Item = (&Self::Solution, usize)> + 'a>

Returns subset of solutions within their rank sorted according their quality.

source

fn statistics(&self) -> &HeuristicStatistics

Returns current statistic used to track the search progress.

source

fn selection_phase(&self) -> SelectionPhase

Returns selection phase.

source

fn environment(&self) -> &Environment

Returns environment.

source

fn on_initial(&mut self, solution: Self::Solution, item_time: Timer)

Updates population with initial solution.

source

fn on_generation( &mut self, offspring: Vec<Self::Solution>, termination_estimate: f64, generation_time: Timer )

Updates population with a new offspring.

source

fn on_result(self) -> HeuristicResult<Self::Objective, Self::Solution>

Returns final population and telemetry metrics

Implementors§