Skip to main content

Route

Trait Route 

Source
pub trait Route {
    type Place;

    // Required methods
    fn origin(&self) -> Self::Place;
    fn place(&self, task: TaskId) -> Self::Place;
    fn travel(&self, from: &Self::Place, to: &Self::Place) -> Option<u64>;
    fn reward(&self, task: TaskId, finish: u64) -> Option<u64>;

    // Provided methods
    fn departure(&self) -> u64 { ... }
    fn duration(&self, task: TaskId) -> u64 { ... }
    fn earliest_start(&self, task: TaskId) -> u64 { ... }
}
Expand description

How an agent travels between task sites, and what each task is worth when.

Times are in a unit of the implementer’s choice, the same everywhere: ticks, seconds or minutes.

Required Associated Types§

Source

type Place

Where the agent can be: a node of a graph, a grid cell, a point.

Required Methods§

Source

fn origin(&self) -> Self::Place

Where the agent starts.

Source

fn place(&self, task: TaskId) -> Self::Place

Where task is done.

Source

fn travel(&self, from: &Self::Place, to: &Self::Place) -> Option<u64>

How long the agent takes from from to to; None when it cannot get there.

Source

fn reward(&self, task: TaskId, finish: u64) -> Option<u64>

What task is worth when finished at finish; None when that is too late. See rewards for common shapes.

Provided Methods§

Source

fn departure(&self) -> u64

When the agent leaves its origin. The default is time zero.

Source

fn duration(&self, task: TaskId) -> u64

How long task takes once started. The default is zero.

Source

fn earliest_start(&self, task: TaskId) -> u64

The earliest time task may start; an agent that arrives earlier waits. The default is time zero.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<R: Route + ?Sized> Route for &R

Source§

type Place = <R as Route>::Place

Source§

fn origin(&self) -> Self::Place

Source§

fn departure(&self) -> u64

Source§

fn place(&self, task: TaskId) -> Self::Place

Source§

fn travel(&self, from: &Self::Place, to: &Self::Place) -> Option<u64>

Source§

fn duration(&self, task: TaskId) -> u64

Source§

fn earliest_start(&self, task: TaskId) -> u64

Source§

fn reward(&self, task: TaskId, finish: u64) -> Option<u64>

Implementors§

Source§

impl<R: Route> Route for Windowed<R>

Source§

type Place = <R as Route>::Place