Struct vrp_core::construction::heuristics::RouteContext
source · pub struct RouteContext { /* private fields */ }
Expand description
Specifies insertion context for route.
Implementations§
source§impl RouteContext
impl RouteContext
sourcepub fn new_with_state(route: Route, state: RouteState) -> Self
pub fn new_with_state(route: Route, state: RouteState) -> Self
Creates a new instance of RouteContext
with arguments provided.
sourcepub fn route(&self) -> &Route
pub fn route(&self) -> &Route
Returns a reference to route.
Examples found in repository?
More examples
examples/custom_constraint.rs (line 35)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
fn evaluate(&self, move_ctx: &MoveContext<'_>) -> Option<ConstraintViolation> {
match move_ctx {
// matching job to route is evaluated before activity matching, so use it to improve search procedure
MoveContext::Route { route_ctx, job, .. } => {
let hardware_vehicle = route_ctx.route().actor.vehicle.dimens.get_vehicle_hardware();
let hardware_job = job.dimens().get_job_hardware();
match (hardware_job, hardware_vehicle) {
(None, _) => None,
(Some(hw_job), Some(hw_vehicle)) if hw_vehicle.contains(hw_job) => None,
_ => ConstraintViolation::fail(self.code),
}
}
// matching activity to route is called for every possible insertion point in the tour
// we don't need it here as hard constraint can be validated on route-job level
MoveContext::Activity { .. } => None,
}
}
sourcepub fn state(&self) -> &RouteState
pub fn state(&self) -> &RouteState
Returns a reference to state.
sourcepub fn as_mut(&mut self) -> (&mut Route, &mut RouteState)
pub fn as_mut(&mut self) -> (&mut Route, &mut RouteState)
Unwraps given RouteContext
as pair of mutable references.
Marks context as stale.
sourcepub fn route_mut(&mut self) -> &mut Route
pub fn route_mut(&mut self) -> &mut Route
Returns mutable reference to used Route
.
Marks context as stale.
sourcepub fn state_mut(&mut self) -> &mut RouteState
pub fn state_mut(&mut self) -> &mut RouteState
Returns mutable reference to used RouteState
.
Marks context as stale.
Trait Implementations§
source§impl Debug for RouteContext
impl Debug for RouteContext
source§impl PartialEq for RouteContext
impl PartialEq for RouteContext
source§fn eq(&self, other: &RouteContext) -> bool
fn eq(&self, other: &RouteContext) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for RouteContext
Auto Trait Implementations§
impl Freeze for RouteContext
impl !RefUnwindSafe for RouteContext
impl Send for RouteContext
impl Sync for RouteContext
impl Unpin for RouteContext
impl !UnwindSafe for RouteContext
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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