Struct vrp_core::models::ConstraintViolation
source · pub struct ConstraintViolation {
pub code: ViolationCode,
pub stopped: bool,
}Expand description
Specifies a result of hard route constraint check.
Fields§
§code: ViolationCodeViolation code which is used as marker of specific constraint violated.
stopped: boolTrue if further insertions should not be attempted.
Implementations§
source§impl ConstraintViolation
impl ConstraintViolation
sourcepub fn fail(code: ViolationCode) -> Option<Self>
pub fn fail(code: ViolationCode) -> Option<Self>
A constraint violation failure with stopped set to true.
Examples found in repository?
examples/custom_constraint.rs (line 41)
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 skip(code: ViolationCode) -> Option<Self>
pub fn skip(code: ViolationCode) -> Option<Self>
A constraint violation failure with stopped set to false.
Trait Implementations§
source§impl Clone for ConstraintViolation
impl Clone for ConstraintViolation
source§fn clone(&self) -> ConstraintViolation
fn clone(&self) -> ConstraintViolation
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for ConstraintViolation
impl Debug for ConstraintViolation
source§impl PartialEq for ConstraintViolation
impl PartialEq for ConstraintViolation
source§fn eq(&self, other: &ConstraintViolation) -> bool
fn eq(&self, other: &ConstraintViolation) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Eq for ConstraintViolation
impl StructuralPartialEq for ConstraintViolation
Auto Trait Implementations§
impl Freeze for ConstraintViolation
impl RefUnwindSafe for ConstraintViolation
impl Send for ConstraintViolation
impl Sync for ConstraintViolation
impl Unpin for ConstraintViolation
impl UnwindSafe for ConstraintViolation
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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