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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.