AlnsProblem

Trait AlnsProblem 

Source
pub trait AlnsProblem {
    type Solution: AlnsSolution;

    // Required methods
    fn create_initial_solution(&mut self) -> Self::Solution;
    fn clone_solution(&self, solution: &Self::Solution) -> Self::Solution;
    fn destroy_operators(&self) -> Vec<DestroyOperatorId>;
    fn repair_operators(&self) -> Vec<RepairOperatorId>;
    fn destroy(
        &mut self,
        solution: &mut Self::Solution,
        operator: DestroyOperatorId,
        degree: f64,
        rng: &mut StdRng,
    ) -> DestroyResult;
    fn repair(
        &mut self,
        solution: &mut Self::Solution,
        destroyed: &DestroyResult,
        operator: RepairOperatorId,
    ) -> RepairResult;

    // Provided method
    fn relatedness(&self, solution: &Self::Solution, i: usize, j: usize) -> f64 { ... }
}
Expand description

Trait for problems that can be solved by ALNS.

Required Associated Types§

Source

type Solution: AlnsSolution

Solution type

Required Methods§

Source

fn create_initial_solution(&mut self) -> Self::Solution

Create an initial solution.

Source

fn clone_solution(&self, solution: &Self::Solution) -> Self::Solution

Clone a solution.

Source

fn destroy_operators(&self) -> Vec<DestroyOperatorId>

Get available destroy operators.

Source

fn repair_operators(&self) -> Vec<RepairOperatorId>

Get available repair operators.

Source

fn destroy( &mut self, solution: &mut Self::Solution, operator: DestroyOperatorId, degree: f64, rng: &mut StdRng, ) -> DestroyResult

Apply a destroy operator.

Source

fn repair( &mut self, solution: &mut Self::Solution, destroyed: &DestroyResult, operator: RepairOperatorId, ) -> RepairResult

Apply a repair operator.

Provided Methods§

Source

fn relatedness(&self, solution: &Self::Solution, i: usize, j: usize) -> f64

Calculate relatedness between two items (for Shaw/Related removal).

Implementors§