pub trait FeatureState {
    // Required methods
    fn accept_insertion(
        &self,
        solution_ctx: &mut SolutionContext,
        route_index: usize,
        job: &Job
    );
    fn accept_route_state(&self, route_ctx: &mut RouteContext);
    fn accept_solution_state(&self, solution_ctx: &mut SolutionContext);
    fn state_keys(&self) -> Iter<'_, StateKey>;

    // Provided method
    fn notify_failure(
        &self,
        _solution_ctx: &mut SolutionContext,
        _route_indices: &[usize],
        _jobs: &[Job]
    ) -> bool { ... }
}
Expand description

Provides the way to modify solution state when the search is performed.

Required Methods§

source

fn accept_insertion( &self, solution_ctx: &mut SolutionContext, route_index: usize, job: &Job )

Accept insertion of specific job into the route. Called once job has been inserted into solution represented via solution_ctx. Target route is defined by route_index which refers to routes collection in solution context. Inserted job is job. This method can call accept_route_state internally. This method should NOT modify amount of job activities in the tour.

source

fn accept_route_state(&self, route_ctx: &mut RouteContext)

Accept route and updates its state to allow more efficient constraint checks. This method should NOT modify amount of job activities in the tour.

source

fn accept_solution_state(&self, solution_ctx: &mut SolutionContext)

Accepts insertion solution context allowing to update job insertion data. This method called twice: before insertion of all jobs starts and when it ends. Please note, that it is important to update only stale routes as this allows to avoid updating non changed route states.

source

fn state_keys(&self) -> Iter<'_, StateKey>

Returns unique constraint state keys used to store some state. If the data is only read, then it shouldn’t be returned. Used to avoid state key interference.

Provided Methods§

source

fn notify_failure( &self, _solution_ctx: &mut SolutionContext, _route_indices: &[usize], _jobs: &[Job] ) -> bool

Notifies a state that given routes (indices) and jobs cannot be assigned due to constraint violations. This method can be used to modify solution context to help resolve some limitations imposed by constraints and, generally, can modify solution context. If some action was taken which might help to assign given jobs to given routes, then true should be returned. Please note, if this method wrongly returns true, it might cause infinite loops in insertion evaluation process. Default implementation returns false which is safe and ok for most of the features.

Implementors§