pub struct Route {
pub nodes: Vec<usize>,
}Expand description
Represents a single vehicle route servicing a sequence of customers.
The route implicitly starts at the depot (node 0) and ends at the depot (node 0).
The nodes vector stores only the customer sequence (nodes >= 1).
Fields§
§nodes: Vec<usize>Ordered sequence of customer indices visited by this vehicle.
Implementations§
Source§impl Route
impl Route
Sourcepub fn from_nodes(nodes: Vec<usize>) -> Self
pub fn from_nodes(nodes: Vec<usize>) -> Self
Creates a route with a predefined sequence of customer nodes.
Sourcepub fn distance(&self, instance: &SolomonInstance) -> f32
pub fn distance(&self, instance: &SolomonInstance) -> f32
Calculates the total euclidean distance traveled by the route:
depot (0) -> nodes[0] -> ... -> nodes[n-1] -> depot (0).
An empty route has a distance of 0.0.
Sourcepub fn total_demand(&self, instance: &SolomonInstance) -> f32
pub fn total_demand(&self, instance: &SolomonInstance) -> f32
Calculates the total demand delivered to all customers in this route.
Sourcepub fn is_capacity_feasible(&self, instance: &SolomonInstance) -> bool
pub fn is_capacity_feasible(&self, instance: &SolomonInstance) -> bool
Returns true if the total route demand does not exceed vehicle capacity.
Trait Implementations§
impl Eq for Route
impl StructuralPartialEq for Route
Auto Trait Implementations§
impl Freeze for Route
impl RefUnwindSafe for Route
impl Send for Route
impl Sync for Route
impl Unpin for Route
impl UnsafeUnpin for Route
impl UnwindSafe for Route
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