Struct Tour

Source
pub struct Tour { /* private fields */ }
Expand description

Represents a tour, a smart container for jobs with their associated activities.

Implementations§

Source§

impl Tour

Source

pub fn new(actor: &Actor) -> Self

Creates a new tour with start and optional end using actor properties.

Source

pub fn set_start(&mut self, activity: Activity) -> &mut Tour

Sets tour start.

Source

pub fn set_end(&mut self, activity: Activity) -> &mut Tour

Sets tour end.

Source

pub fn insert_last(&mut self, activity: Activity) -> &mut Tour

Inserts activity within its job to the end of tour.

Source

pub fn insert_at(&mut self, activity: Activity, index: usize) -> &mut Tour

Inserts activity within its job at specified index.

Source

pub fn remove(&mut self, job: &Job) -> bool

Removes job within its activities from the tour.

Source

pub fn remove_activity_at(&mut self, idx: usize) -> Job

Removes activity and its job from the tour.

Source

pub fn all_activities(&self) -> Iter<'_, Activity>

Returns all activities in tour.

Source

pub fn activities_slice(&self, start: usize, end: usize) -> &[Activity]

Returns activities slice in specific range (all inclusive).

Source

pub fn all_activities_mut(&mut self) -> IterMut<'_, Activity>

Returns all activities in tour as mutable.

Source

pub fn job_activities<'a>( &'a self, job: &'a Job, ) -> impl Iterator<Item = &Activity> + 'a

Returns all activities in tour for specific job.

Source

pub fn legs(&self) -> impl Iterator<Item = Leg<'_>> + '_ + Clone

Returns counted tour legs.

Source

pub fn jobs(&self) -> impl Iterator<Item = &Job> + '_

Returns all jobs.

Examples found in repository?
examples/custom_objective.rs (line 79)
78fn calculate_solution_fitness(solution_ctx: &SolutionContext) -> Cost {
79    solution_ctx.routes.iter().flat_map(|route_ctx| route_ctx.route().tour.jobs()).map(estimate_job_cost).sum::<Cost>()
80}
Source

pub fn get(&self, index: usize) -> Option<&Activity>

Returns activity by its index in tour.

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut Activity>

Returns mutable activity by its index in tour.

Source

pub fn start(&self) -> Option<&Activity>

Returns start activity in tour.

Source

pub fn end(&self) -> Option<&Activity>

Returns end activity in tour.

Source

pub fn end_idx(&self) -> Option<usize>

Returns end activity in tour.

Source

pub fn contains(&self, job: &Job) -> bool

Checks whether job is present in tour

Source

pub fn index(&self, job: &Job) -> Option<usize>

Returns index of first job occurrence in the tour.

Source

pub fn index_last(&self, job: &Job) -> Option<usize>

Returns index of last job occurrence in the tour.

Source

pub fn has_job(&self, job: &Job) -> bool

Checks whether job is present in tour.

Source

pub fn has_jobs(&self) -> bool

Checks whether tour has jobs.

Source

pub fn job_activity_count(&self) -> usize

Returns total amount of job activities.

Source

pub fn total(&self) -> usize

Returns amount of all activities in tour.

Source

pub fn job_count(&self) -> usize

Returns amount of jobs.

Source

pub fn deep_copy(&self) -> Tour

Creates a copy of existing tour deeply copying all activities and jobs.

Trait Implementations§

Source§

impl Debug for Tour

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Tour

Source§

fn default() -> Tour

Returns the “default value” for a type. Read more
Source§

impl Index<usize> for Tour

Source§

type Output = Activity

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl Freeze for Tour

§

impl !RefUnwindSafe for Tour

§

impl Send for Tour

§

impl Sync for Tour

§

impl Unpin for Tour

§

impl !UnwindSafe for Tour

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V