Struct vrp_core::models::GoalContext
source · 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
impl GoalContext
sourcepub fn new(features: &[Feature], goal: Goal) -> Result<Self, GenericError>
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.
sourcepub fn with_constraints<Iter>(&self, constraints: Iter) -> Self
pub fn with_constraints<Iter>(&self, constraints: Iter) -> Self
Creates a new instance of GoalContext
with given feature constraints.
sourcepub fn constraints(
&self
) -> impl Iterator<Item = Arc<dyn FeatureConstraint + Send + Sync>> + '_
pub fn constraints( &self ) -> impl Iterator<Item = Arc<dyn FeatureConstraint + Send + Sync>> + '_
Returns an iterator over internal feature constraints.
source§impl GoalContext
impl GoalContext
sourcepub fn accept_insertion(
&self,
solution_ctx: &mut SolutionContext,
route_index: usize,
job: &Job
)
pub fn accept_insertion( &self, solution_ctx: &mut SolutionContext, route_index: usize, job: &Job )
Accepts job insertion.
sourcepub fn accept_route_state(&self, route_ctx: &mut RouteContext)
pub fn accept_route_state(&self, route_ctx: &mut RouteContext)
Accepts route state.
sourcepub fn accept_solution_state(&self, solution_ctx: &mut SolutionContext)
pub fn accept_solution_state(&self, solution_ctx: &mut SolutionContext)
Accepts solution state.
sourcepub fn notify_failure(
&self,
solution_ctx: &mut SolutionContext,
route_indices: &[usize],
jobs: &[Job]
) -> bool
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.
sourcepub fn merge(&self, source: Job, candidate: Job) -> Result<Job, ViolationCode>
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.
sourcepub fn evaluate(
&self,
move_ctx: &MoveContext<'_>
) -> Option<ConstraintViolation>
pub fn evaluate( &self, move_ctx: &MoveContext<'_> ) -> Option<ConstraintViolation>
Evaluates feasibility of the refinement move.
sourcepub fn estimate(&self, move_ctx: &MoveContext<'_>) -> InsertionCost
pub fn estimate(&self, move_ctx: &MoveContext<'_>) -> InsertionCost
Estimates insertion cost (penalty) of the refinement move.
Trait Implementations§
source§impl Clone for GoalContext
impl Clone for GoalContext
source§fn clone(&self) -> GoalContext
fn clone(&self) -> GoalContext
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for GoalContext
impl Debug for GoalContext
source§impl Default for GoalContext
impl Default for GoalContext
source§fn default() -> GoalContext
fn default() -> GoalContext
source§impl MultiObjective for GoalContext
impl MultiObjective for GoalContext
§type Solution = InsertionContext
type Solution = InsertionContext
source§fn total_order(&self, a: &Self::Solution, b: &Self::Solution) -> Ordering
fn total_order(&self, a: &Self::Solution, b: &Self::Solution) -> Ordering
source§fn fitness<'a>(
&'a self,
solution: &'a Self::Solution
) -> Box<dyn Iterator<Item = f64> + 'a>
fn fitness<'a>( &'a self, solution: &'a Self::Solution ) -> Box<dyn Iterator<Item = f64> + 'a>
solution
.