pub struct KOptMove<S, V> { /* private fields */ }Expand description
A k-opt move that removes k edges and reconnects segments.
This is the generalized k-opt move supporting k=2,3,4,5. For k=2, this is equivalent to a 2-opt (segment reversal).
§Zero-Erasure Design
- Fixed array
[CutPoint; 5]for up to 5 cuts (5-opt) - Reference to static
&'static KOptReconnection - Typed function pointers for list operations
§Type Parameters
S- The planning solution typeV- The list element value type
Implementations§
Source§impl<S, V> KOptMove<S, V>
impl<S, V> KOptMove<S, V>
Sourcepub fn new(
cuts: &[CutPoint],
reconnection: &'static KOptReconnection,
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( cuts: &[CutPoint], reconnection: &'static KOptReconnection, 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 k-opt move.
§Arguments
cuts- Slice of cut points (must be sorted by position for intra-route)reconnection- How to reconnect the segmentslist_len- Function to get list lengthsublist_remove- Function to remove a rangesublist_insert- Function to insert elementsvariable_name- Name of the list variabledescriptor_index- Entity descriptor index
§Panics
Panics if cuts is empty or has more than 5 elements.
Sourcepub fn is_intra_route(&self) -> bool
pub fn is_intra_route(&self) -> bool
Returns true if this is an intra-route move (all cuts on same entity).
Trait Implementations§
Source§impl<S, V> Move<S> for KOptMove<S, V>
impl<S, V> Move<S> for KOptMove<S, V>
Source§fn is_doable<D: ScoreDirector<S>>(&self, score_director: &D) -> bool
fn is_doable<D: ScoreDirector<S>>(&self, score_director: &D) -> bool
Returns true if this move can be executed in the current state. Read more
Source§fn do_move<D: ScoreDirector<S>>(&self, score_director: &mut D)
fn do_move<D: ScoreDirector<S>>(&self, score_director: &mut D)
Executes this move, modifying the working solution. Read more
Source§fn descriptor_index(&self) -> usize
fn descriptor_index(&self) -> usize
Returns the descriptor index of the entity type this move affects.
Source§fn entity_indices(&self) -> &[usize]
fn entity_indices(&self) -> &[usize]
Returns the entity indices involved in this move.
Source§fn variable_name(&self) -> &str
fn variable_name(&self) -> &str
Returns the variable name this move affects.
Source§impl<S, V, ES> MoveSelector<S, KOptMove<S, V>> for KOptMoveSelector<S, V, ES>
impl<S, V, ES> MoveSelector<S, KOptMove<S, V>> for KOptMoveSelector<S, V, ES>
Source§fn iter_moves<'a, D: ScoreDirector<S>>(
&'a self,
score_director: &'a D,
) -> Box<dyn Iterator<Item = KOptMove<S, V>> + 'a>
fn iter_moves<'a, D: ScoreDirector<S>>( &'a self, score_director: &'a D, ) -> Box<dyn Iterator<Item = KOptMove<S, V>> + 'a>
Returns an iterator over typed moves.
Source§fn size<D: ScoreDirector<S>>(&self, score_director: &D) -> usize
fn size<D: ScoreDirector<S>>(&self, score_director: &D) -> 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.
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> Freeze for KOptMove<S, V>
impl<S, V> RefUnwindSafe for KOptMove<S, V>where
V: RefUnwindSafe,
impl<S, V> Send for KOptMove<S, V>where
V: Send,
impl<S, V> Sync for KOptMove<S, V>where
V: Sync,
impl<S, V> Unpin for KOptMove<S, V>where
V: Unpin,
impl<S, V> UnwindSafe for KOptMove<S, V>where
V: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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