pub struct ConstraintViolation {
pub code: ViolationCode,
pub stopped: bool,
}
Expand description
Specifies a result of hard route constraint check.
Fields§
§code: ViolationCode
Violation code which is used as marker of specific constraint violated.
stopped: bool
True 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 fn evaluate(&self, move_ctx: &MoveContext<'_>) -> Option<ConstraintViolation> {
32 match move_ctx {
33 // matching job to route is evaluated before activity matching, so use it to improve search procedure
34 MoveContext::Route { route_ctx, job, .. } => {
35 let hardware_vehicle = route_ctx.route().actor.vehicle.dimens.get_vehicle_hardware();
36 let hardware_job = job.dimens().get_job_hardware();
37
38 match (hardware_job, hardware_vehicle) {
39 (None, _) => None,
40 (Some(hw_job), Some(hw_vehicle)) if hw_vehicle.contains(hw_job) => None,
41 _ => ConstraintViolation::fail(self.code),
42 }
43 }
44 // matching activity to route is called for every possible insertion point in the tour
45 // we don't need it here as hard constraint can be validated on route-job level
46 MoveContext::Activity { .. } => None,
47 }
48 }
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 duplicate 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
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§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