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
andFeatureConstraint::evaluate
methods are called during this phase. Additionally, it can be used to do some solution modifications atFeatureState::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.