pub struct TimeWindow {
pub start: Timestamp,
pub end: Timestamp,
}
Expand description
Represents a time window.
Fields§
§start: Timestamp
Start of time window.
end: Timestamp
End 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)
22fn define_problem(goal: GoalContext, transport: Arc<dyn TransportCost>) -> GenericResult<Problem> {
23 // build two PUDO (pick up/drop off) jobs with demand=1 and permissive time windows (just to show API usage)
24 let pudos = (1..=2)
25 .map(|idx| {
26 let location_idx = if idx == 1 { 1 } else { 3 };
27 MultiBuilder::default()
28 .id(format!("pudo{idx}").as_str())
29 .add_job(
30 SingleBuilder::default()
31 .demand(Demand::pudo_pickup(1))
32 .times(vec![TimeWindow::new(0., 1000.)])?
33 .duration(10.)?
34 .location(location_idx)?
35 .build()?,
36 )
37 .add_job(
38 SingleBuilder::default()
39 .demand(Demand::pudo_delivery(1))
40 .times(vec![TimeWindow::new(0., 1000.)])?
41 .duration(10.)?
42 .location(location_idx + 1)?
43 .build()?,
44 )
45 .build_as_job()
46 })
47 .collect::<Result<Vec<_>, _>>()?;
48
49 // define a single vehicle with limited capacity
50 let vehicle = VehicleBuilder::default()
51 .id("v1".to_string().as_str())
52 .add_detail(
53 VehicleDetailBuilder::default()
54 // vehicle starts at location with index 0 in routing matrix
55 .set_start_location(0)
56 .set_start_time(0.)
57 // vehicle should return to location with index 0
58 .set_end_location(0)
59 .set_end_time(10000.)
60 .build()?,
61 )
62 // the vehicle has capacity=1, so it is forced to do delivery after each pickup
63 .capacity(SingleDimLoad::new(1))
64 .build()?;
65
66 ProblemBuilder::default()
67 .add_jobs(pudos.into_iter())
68 .add_vehicles(once(vehicle))
69 .with_goal(goal)
70 .with_transport_cost(transport)
71 .build()
72}
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
impl Eq for TimeWindow
impl StructuralPartialEq 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§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