SaProblem

Trait SaProblem 

Source
pub trait SaProblem: Send + Sync {
    type Solution: SaSolution;

    // Required methods
    fn initial_solution<R: Rng>(&self, rng: &mut R) -> Self::Solution;
    fn neighbor<R: Rng>(
        &self,
        solution: &Self::Solution,
        operator: NeighborhoodOperator,
        rng: &mut R,
    ) -> Self::Solution;
    fn evaluate(&self, solution: &mut Self::Solution);

    // Provided methods
    fn available_operators(&self) -> Vec<NeighborhoodOperator> { ... }
    fn on_temperature_change(
        &self,
        _temperature: f64,
        _iteration: u64,
        _best: &Self::Solution,
        _current: &Self::Solution,
    ) { ... }
}
Expand description

Trait for problem-specific SA operations.

Required Associated Types§

Source

type Solution: SaSolution

The solution type for this problem.

Required Methods§

Source

fn initial_solution<R: Rng>(&self, rng: &mut R) -> Self::Solution

Creates an initial solution.

Source

fn neighbor<R: Rng>( &self, solution: &Self::Solution, operator: NeighborhoodOperator, rng: &mut R, ) -> Self::Solution

Generates a neighbor solution using the specified operator.

Source

fn evaluate(&self, solution: &mut Self::Solution)

Evaluates the objective of a solution.

Provided Methods§

Source

fn available_operators(&self) -> Vec<NeighborhoodOperator>

Returns available neighborhood operators for this problem.

Source

fn on_temperature_change( &self, _temperature: f64, _iteration: u64, _best: &Self::Solution, _current: &Self::Solution, )

Called after each temperature level (for progress reporting).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§