pub struct NearbyKOptMoveSelector<S, V, D: ListPositionDistanceMeter<S>, ES> { /* private fields */ }Expand description
A k-opt move selector with nearby selection for improved performance.
Instead of enumerating all O(n^k) cut combinations, uses distance-based pruning to reduce to O(n * m^(k-1)) where m = max_nearby_size.
§How It Works
- First cut: all positions in the route
- Second cut: only positions nearby (by element distance) to first cut
- Third cut: only positions nearby to second cut
- etc.
This dramatically reduces the search space for large routes.
Implementations§
Source§impl<S: PlanningSolution, V, D: ListPositionDistanceMeter<S>, ES> NearbyKOptMoveSelector<S, V, D, ES>
impl<S: PlanningSolution, V, D: ListPositionDistanceMeter<S>, ES> NearbyKOptMoveSelector<S, V, D, ES>
Sourcepub fn new(
entity_selector: ES,
distance_meter: D,
max_nearby: usize,
config: KOptConfig,
list_len: fn(&S, usize) -> usize,
sublist_remove: fn(&mut S, usize, usize, usize) -> Vec<V>,
sublist_insert: fn(&mut S, usize, usize, Vec<V>),
variable_name: &'static str,
descriptor_index: usize,
) -> Self
pub fn new( entity_selector: ES, distance_meter: D, max_nearby: usize, config: KOptConfig, list_len: fn(&S, usize) -> usize, sublist_remove: fn(&mut S, usize, usize, usize) -> Vec<V>, sublist_insert: fn(&mut S, usize, usize, Vec<V>), variable_name: &'static str, descriptor_index: usize, ) -> Self
Creates a new nearby k-opt move selector.
Trait Implementations§
Source§impl<S, V: Debug, D: ListPositionDistanceMeter<S>, ES: Debug> Debug for NearbyKOptMoveSelector<S, V, D, ES>
impl<S, V: Debug, D: ListPositionDistanceMeter<S>, ES: Debug> Debug for NearbyKOptMoveSelector<S, V, D, ES>
Source§impl<S, V, DM, ES> MoveSelector<S, KOptMove<S, V>> for NearbyKOptMoveSelector<S, V, DM, ES>where
S: PlanningSolution,
V: Clone + Send + Sync + Debug + 'static,
DM: ListPositionDistanceMeter<S> + 'static,
ES: EntitySelector<S>,
impl<S, V, DM, ES> MoveSelector<S, KOptMove<S, V>> for NearbyKOptMoveSelector<S, V, DM, ES>where
S: PlanningSolution,
V: Clone + Send + Sync + Debug + 'static,
DM: ListPositionDistanceMeter<S> + 'static,
ES: EntitySelector<S>,
Source§fn iter_moves<'a, SD: ScoreDirector<S>>(
&'a self,
score_director: &'a SD,
) -> Box<dyn Iterator<Item = KOptMove<S, V>> + 'a>
fn iter_moves<'a, SD: ScoreDirector<S>>( &'a self, score_director: &'a SD, ) -> Box<dyn Iterator<Item = KOptMove<S, V>> + 'a>
Returns an iterator over typed moves.
Source§fn size<SD: ScoreDirector<S>>(&self, score_director: &SD) -> usize
fn size<SD: ScoreDirector<S>>(&self, score_director: &SD) -> usize
Returns the approximate number of moves.
Source§fn is_never_ending(&self) -> bool
fn is_never_ending(&self) -> bool
Returns true if this selector may return the same move multiple times.
Auto Trait Implementations§
impl<S, V, D, ES> Freeze for NearbyKOptMoveSelector<S, V, D, ES>
impl<S, V, D, ES> RefUnwindSafe for NearbyKOptMoveSelector<S, V, D, ES>
impl<S, V, D, ES> Send for NearbyKOptMoveSelector<S, V, D, ES>
impl<S, V, D, ES> Sync for NearbyKOptMoveSelector<S, V, D, ES>
impl<S, V, D, ES> Unpin for NearbyKOptMoveSelector<S, V, D, ES>
impl<S, V, D, ES> UnwindSafe for NearbyKOptMoveSelector<S, V, D, ES>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more