pub trait FeatureState: Send + Sync {
// 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);
// 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§
Sourcefn accept_insertion(
&self,
solution_ctx: &mut SolutionContext,
route_index: usize,
job: &Job,
)
fn accept_insertion( &self, solution_ctx: &mut SolutionContext, route_index: usize, job: &Job, )
Accept insertion of a specific job into the route.
Called once a job has been inserted into a 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 the number of job activities in the tour.
Sourcefn accept_route_state(&self, route_ctx: &mut RouteContext)
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 the number of job activities in the tour.
Sourcefn accept_solution_state(&self, solution_ctx: &mut SolutionContext)
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 avoiding update of non-changed route states.
Provided Methods§
Sourcefn notify_failure(
&self,
_solution_ctx: &mut SolutionContext,
_route_indices: &[usize],
_jobs: &[Job],
) -> bool
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 an insertion evaluation process. The default implementation returns false, which is safe and ok for most of the features.