Struct vrp_core::models::Feature

source ·
pub struct Feature {
    pub name: String,
    pub constraint: Option<Arc<dyn FeatureConstraint + Send + Sync>>,
    pub objective: Option<Arc<dyn FeatureObjective<Solution = InsertionContext> + Send + Sync>>,
    pub state: Option<Arc<dyn FeatureState + Send + Sync>>,
}
Expand description

An individual feature which is used to build a specific VRP variant, e.g. capacity restriction, job values, etc. Each feature consists of three optional parts (but at least one should be defined):

  • constraint: an invariant which should be hold to have a feasible VRP solution in the end. A good examples are hard constraints such as capacity, time, travel limits, etc.

  • objective: an objective of the optimization such as minimization of unassigned jobs or tours. All objectives form together a hierarchy which describes a goal of optimization, including various soft constraints: assignment of preferred jobs, optional breaks, etc. This helps to guide the search on the global objective level (e.g. comparison of various solutions in order to find out which one is “better”) and local objective level (e.g. which job should be inserted next into specific solution).

  • state: the corresponding cached data of constraint/objective to speedup/control their evaluations.

As mentioned above, at least one part should be defined. Some rules of thumb:

  • each soft constraint requires an objective so that goal of optimization is reflected on global and local levels
  • hard constraint can be defined without objective as this is an invariant
  • state should be used to avoid expensive calculations during insertion evaluation phase. FeatureObjective::estimate and FeatureConstraint::evaluate methods are called during this phase. Additionally, it can be used to do some solution modifications at FeatureState::accept_solution_state.

Fields§

§name: String

An unique id of the feature.

§constraint: Option<Arc<dyn FeatureConstraint + Send + Sync>>

A hard constraint.

§objective: Option<Arc<dyn FeatureObjective<Solution = InsertionContext> + Send + Sync>>

An objective which models soft constraints.

§state: Option<Arc<dyn FeatureState + Send + Sync>>

A state change handler.

Trait Implementations§

source§

impl Clone for Feature

source§

fn clone(&self) -> Feature

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 Default for Feature

source§

fn default() -> Feature

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

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