pub struct GoalContext { /* private fields */ }
Expand description
Defines Vehicle Routing Problem variant by global and local objectives: A global objective defines the way two VRP solutions are compared to select better one: for example, given the same number of assigned jobs, prefer fewer tours used instead of total solution cost.
A local objective defines how a single VRP solution is created/modified. It specifies hard constraints such as vehicle capacity, time windows, skills, etc. Also, it defines soft constraints which are used to guide search in preferred by global objective direction: reduce the number of tours served, maximize the total value of assigned jobs, etc.
Both, global and local objectives, are specified by individual features. In general, a Feature encapsulates a single VRP aspect, such as capacity constraint for job’s demand, time limitations for vehicles/jobs, etc.
Implementations§
Source§impl GoalContext
impl GoalContext
Sourcepub fn with_constraints<Iter>(&self, constraints: Iter) -> Self
pub fn with_constraints<Iter>(&self, constraints: Iter) -> Self
Creates a new instance of GoalContext
with given feature constraints.
Sourcepub fn constraints(
&self,
) -> impl Iterator<Item = Arc<dyn FeatureConstraint>> + '_
pub fn constraints( &self, ) -> impl Iterator<Item = Arc<dyn FeatureConstraint>> + '_
Returns an iterator over internal feature constraints.
Source§impl GoalContext
impl GoalContext
Sourcepub fn accept_insertion(
&self,
solution_ctx: &mut SolutionContext,
route_index: usize,
job: &Job,
)
pub fn accept_insertion( &self, solution_ctx: &mut SolutionContext, route_index: usize, job: &Job, )
Accepts job insertion.
Sourcepub fn accept_route_state(&self, route_ctx: &mut RouteContext)
pub fn accept_route_state(&self, route_ctx: &mut RouteContext)
Accepts route state.
Sourcepub fn accept_solution_state(&self, solution_ctx: &mut SolutionContext)
pub fn accept_solution_state(&self, solution_ctx: &mut SolutionContext)
Accepts solution state.
Sourcepub fn notify_failure(
&self,
solution_ctx: &mut SolutionContext,
route_indices: &[usize],
jobs: &[Job],
) -> bool
pub fn notify_failure( &self, solution_ctx: &mut SolutionContext, route_indices: &[usize], jobs: &[Job], ) -> bool
Notifies about a failed attempt to insert given jobs into given routes (indices). Returns true if failure is some attempt to handle failure was performed and retry can be performed.
Sourcepub fn merge(&self, source: Job, candidate: Job) -> Result<Job, ViolationCode>
pub fn merge(&self, source: Job, candidate: Job) -> Result<Job, ViolationCode>
Tries to merge two jobs taking into account common constraints. Returns a new job, if it is possible to merge them having a theoretically assignable job. Otherwise returns violation error code.
Sourcepub fn evaluate(
&self,
move_ctx: &MoveContext<'_>,
) -> Option<ConstraintViolation>
pub fn evaluate( &self, move_ctx: &MoveContext<'_>, ) -> Option<ConstraintViolation>
Evaluates feasibility of the refinement move.
Sourcepub fn estimate(&self, move_ctx: &MoveContext<'_>) -> InsertionCost
pub fn estimate(&self, move_ctx: &MoveContext<'_>) -> InsertionCost
Estimates insertion cost (penalty) of the refinement move.
Sourcepub fn fitness<'a>(
&'a self,
solution: &'a InsertionContext,
) -> impl Iterator<Item = Float> + 'a
pub fn fitness<'a>( &'a self, solution: &'a InsertionContext, ) -> impl Iterator<Item = Float> + 'a
Calculates solution’s fitness.
Trait Implementations§
Source§impl Clone for GoalContext
impl Clone for GoalContext
Source§fn clone(&self) -> GoalContext
fn clone(&self) -> GoalContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for GoalContext
impl Debug for GoalContext
Source§impl HeuristicObjective for GoalContext
impl HeuristicObjective for GoalContext
Source§impl Shuffled for GoalContext
impl Shuffled for GoalContext
Source§fn get_shuffled(&self, random: &dyn Random) -> Self
fn get_shuffled(&self, random: &dyn Random) -> Self
Auto Trait Implementations§
impl Freeze for GoalContext
impl !RefUnwindSafe for GoalContext
impl Send for GoalContext
impl Sync for GoalContext
impl Unpin for GoalContext
impl !UnwindSafe for GoalContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more