pub struct GoalContext { /* private fields */ }
Expand description

Defines Vehicle Routing Problem variant by global and local objectives: A global objective defines the way two VRP solutions are compared in order to select better one: for example, given the same amount of assigned jobs, prefer less tours used instead of total solution cost.

A local objective defines how single VRP solution is created/modified. It specifies hard constraints such as vehicle capacity, time windows, skills, etc. Also it defines soft constraints which are used to guide search in preferred by global objective direction: reduce amount of tours served, maximize total value of assigned jobs, etc.

Both, global and local objectives, are specified by individual features. In general, a Feature encapsulates a single VRP aspect, such as capacity constraint for job’ demand, time limitations for vehicles/jobs, etc.

Implementations§

source§

impl GoalContext

source

pub fn new(features: &[Feature], goal: Goal) -> Result<Self, GenericError>

Creates a new instance of GoalContext with features specified using information about hierarchy of objectives.

source

pub fn with_constraints<Iter>(&self, constraints: Iter) -> Self
where Iter: Iterator<Item = Arc<dyn FeatureConstraint + Send + Sync>>,

Creates a new instance of GoalContext with given feature constraints.

source

pub fn constraints( &self ) -> impl Iterator<Item = Arc<dyn FeatureConstraint + Send + Sync>> + '_

Returns an iterator over internal feature constraints.

source§

impl GoalContext

source

pub fn accept_insertion( &self, solution_ctx: &mut SolutionContext, route_index: usize, job: &Job )

Accepts job insertion.

source

pub fn accept_route_state(&self, route_ctx: &mut RouteContext)

Accepts route state.

source

pub fn accept_solution_state(&self, solution_ctx: &mut SolutionContext)

Accepts solution state.

source

pub fn notify_failure( &self, solution_ctx: &mut SolutionContext, route_indices: &[usize], jobs: &[Job] ) -> bool

Notifies about failed attempt to insert given jobs into given routes (indices). Returns true if failure is some attempt to handle failure was performed and retry can be performed.

source

pub fn merge(&self, source: Job, candidate: Job) -> Result<Job, ViolationCode>

Tries to merge two jobs taking into account common constraints. Returns a new job, if it is possible to merge them together having theoretically assignable job. Otherwise returns violation error code.

source

pub fn evaluate( &self, move_ctx: &MoveContext<'_> ) -> Option<ConstraintViolation>

Evaluates feasibility of the refinement move.

source

pub fn estimate(&self, move_ctx: &MoveContext<'_>) -> InsertionCost

Estimates insertion cost (penalty) of the refinement move.

Trait Implementations§

source§

impl Clone for GoalContext

source§

fn clone(&self) -> GoalContext

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for GoalContext

source§

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

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

impl Default for GoalContext

source§

fn default() -> GoalContext

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

impl MultiObjective for GoalContext

§

type Solution = InsertionContext

The solution value type that we define the objective on.
source§

fn total_order(&self, a: &Self::Solution, b: &Self::Solution) -> Ordering

An objective defines a total ordering between any two solution values.
source§

fn fitness<'a>( &'a self, solution: &'a Self::Solution ) -> Box<dyn Iterator<Item = f64> + 'a>

An objective fitness values for given solution.
source§

fn get_order( &self, a: &Self::Solution, b: &Self::Solution, idx: usize ) -> Result<Ordering, GenericError>

Get solution order for individual objective.
source§

fn get_distance( &self, a: &Self::Solution, b: &Self::Solution, idx: usize ) -> Result<f64, GenericError>

Gets solution distance for individual objective.
source§

fn size(&self) -> usize

Returns total number of inner objectives.
source§

impl Shuffled for GoalContext

source§

fn get_shuffled(&self, random: &(dyn Random + Send + Sync)) -> Self

Returns a new instance of GoalContext with shuffled objectives.

source§

impl HeuristicObjective for GoalContext

Auto Trait Implementations§

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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

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

§

fn vzip(self) -> V