Struct vrp_core::models::common::TimeWindow
source · pub struct TimeWindow {
pub start: Timestamp,
pub end: Timestamp,
}Expand description
Represents a time window.
Fields§
§start: TimestampStart of time window.
end: TimestampEnd of time window.
Implementations§
source§impl TimeWindow
impl TimeWindow
sourcepub fn new(start: Timestamp, end: Timestamp) -> Self
pub fn new(start: Timestamp, end: Timestamp) -> Self
Creates a new TimeWindow.
Examples found in repository?
examples/pdptw.rs (line 32)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
fn define_problem(goal: GoalContext, transport: Arc<dyn TransportCost + Send + Sync>) -> GenericResult<Problem> {
// build two PUDO (pick up/drop off) jobs with demand=1 and permissive time windows (just to show API usage)
let pudos = (1..=2)
.map(|idx| {
let location_idx = if idx == 1 { 1 } else { 3 };
MultiBuilder::default()
.id(format!("pudo{idx}").as_str())
.add_job(
SingleBuilder::default()
.demand(Demand::pudo_pickup(1))
.times(vec![TimeWindow::new(0., 1000.)])?
.duration(10.)?
.location(location_idx)?
.build()?,
)
.add_job(
SingleBuilder::default()
.demand(Demand::pudo_delivery(1))
.times(vec![TimeWindow::new(0., 1000.)])?
.duration(10.)?
.location(location_idx + 1)?
.build()?,
)
.build_as_job()
})
.collect::<Result<Vec<_>, _>>()?;
// define a single vehicle with limited capacity
let vehicle = VehicleBuilder::default()
.id("v1".to_string().as_str())
.add_detail(
VehicleDetailBuilder::default()
// vehicle starts at location with index 0 in routing matrix
.set_start_location(0)
.set_start_time(0.)
// vehicle should return to location with index 0
.set_end_location(0)
.set_end_time(10000.)
.build()?,
)
// the vehicle has capacity=1, so it is forced to do delivery after each pickup
.capacity(SingleDimLoad::new(1))
.build()?;
ProblemBuilder::default()
.add_jobs(pudos.into_iter())
.add_vehicles(once(vehicle))
.with_goal(goal)
.with_transport_cost(transport)
.build()
}sourcepub fn intersects(&self, other: &Self) -> bool
pub fn intersects(&self, other: &Self) -> bool
Checks whether time window has intersection with another one (inclusive).
sourcepub fn intersects_exclusive(&self, other: &Self) -> bool
pub fn intersects_exclusive(&self, other: &Self) -> bool
Checks whether time window has intersection with another one (exclusive).
sourcepub fn contains(&self, time: Timestamp) -> bool
pub fn contains(&self, time: Timestamp) -> bool
Checks whether time window contains given time.
sourcepub fn overlapping(&self, other: &Self) -> Option<TimeWindow>
pub fn overlapping(&self, other: &Self) -> Option<TimeWindow>
Returns a new overlapping time window.
Trait Implementations§
source§impl Clone for TimeWindow
impl Clone for TimeWindow
source§fn clone(&self) -> TimeWindow
fn clone(&self) -> TimeWindow
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 TimeWindow
impl Debug for TimeWindow
source§impl Hash for TimeWindow
impl Hash for TimeWindow
source§impl PartialEq for TimeWindow
impl PartialEq for TimeWindow
source§fn eq(&self, other: &TimeWindow) -> bool
fn eq(&self, other: &TimeWindow) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Eq for TimeWindow
Auto Trait Implementations§
impl Freeze for TimeWindow
impl RefUnwindSafe for TimeWindow
impl Send for TimeWindow
impl Sync for TimeWindow
impl Unpin for TimeWindow
impl UnwindSafe for TimeWindow
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