Trait rosomaxa::HeuristicContext
source · 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§
sourcetype Objective: HeuristicObjective<Solution = Self::Solution>
type Objective: HeuristicObjective<Solution = Self::Solution>
A heuristic objective function type.
sourcetype Solution: HeuristicSolution
type Solution: HeuristicSolution
A heuristic solution type.
Required Methods§
sourcefn selected<'a>(&'a self) -> Box<dyn Iterator<Item = &Self::Solution> + 'a>
fn selected<'a>(&'a self) -> Box<dyn Iterator<Item = &Self::Solution> + 'a>
Returns selected solutions base on current context.
sourcefn ranked<'a>(
&'a self
) -> Box<dyn Iterator<Item = (&Self::Solution, usize)> + 'a>
fn ranked<'a>( &'a self ) -> Box<dyn Iterator<Item = (&Self::Solution, usize)> + 'a>
Returns subset of solutions within their rank sorted according their quality.
sourcefn statistics(&self) -> &HeuristicStatistics
fn statistics(&self) -> &HeuristicStatistics
Returns current statistic used to track the search progress.
sourcefn selection_phase(&self) -> SelectionPhase
fn selection_phase(&self) -> SelectionPhase
Returns selection phase.
sourcefn environment(&self) -> &Environment
fn environment(&self) -> &Environment
Returns environment.
sourcefn on_initial(&mut self, solution: Self::Solution, item_time: Timer)
fn on_initial(&mut self, solution: Self::Solution, item_time: Timer)
Updates population with initial solution.
sourcefn on_generation(
&mut self,
offspring: Vec<Self::Solution>,
termination_estimate: f64,
generation_time: Timer
)
fn on_generation( &mut self, offspring: Vec<Self::Solution>, termination_estimate: f64, generation_time: Timer )
Updates population with a new offspring.
sourcefn on_result(self) -> HeuristicResult<Self::Objective, Self::Solution>
fn on_result(self) -> HeuristicResult<Self::Objective, Self::Solution>
Returns final population and telemetry metrics