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(&self, score_director: &dyn ScoreDirector<S>) -> bool
fn is_doable(&self, score_director: &dyn ScoreDirector<S>) -> bool
Returns true if this move can be executed in the current state. Read more
Source§fn do_move(&self, score_director: &mut dyn ScoreDirector<S>)
fn do_move(&self, score_director: &mut dyn ScoreDirector<S>)
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> MoveSelector<S, KOptMove<S, V>> for KOptMoveSelector<S, V>
impl<S, V> MoveSelector<S, KOptMove<S, V>> for KOptMoveSelector<S, V>
Source§fn iter_moves<'a>(
&'a self,
score_director: &'a dyn ScoreDirector<S>,
) -> Box<dyn Iterator<Item = KOptMove<S, V>> + 'a>
fn iter_moves<'a>( &'a self, score_director: &'a dyn ScoreDirector<S>, ) -> Box<dyn Iterator<Item = KOptMove<S, V>> + 'a>
Returns an iterator over typed moves.
Source§fn size(&self, score_director: &dyn ScoreDirector<S>) -> usize
fn size(&self, score_director: &dyn ScoreDirector<S>) -> 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, D> MoveSelector<S, KOptMove<S, V>> for NearbyKOptMoveSelector<S, V, D>where
S: PlanningSolution,
V: Clone + Send + Sync + Debug + 'static,
D: ListPositionDistanceMeter<S> + 'static,
impl<S, V, D> MoveSelector<S, KOptMove<S, V>> for NearbyKOptMoveSelector<S, V, D>where
S: PlanningSolution,
V: Clone + Send + Sync + Debug + 'static,
D: ListPositionDistanceMeter<S> + 'static,
Source§fn iter_moves<'a>(
&'a self,
score_director: &'a dyn ScoreDirector<S>,
) -> Box<dyn Iterator<Item = KOptMove<S, V>> + 'a>
fn iter_moves<'a>( &'a self, score_director: &'a dyn ScoreDirector<S>, ) -> Box<dyn Iterator<Item = KOptMove<S, V>> + 'a>
Returns an iterator over typed moves.
Source§fn size(&self, score_director: &dyn ScoreDirector<S>) -> usize
fn size(&self, score_director: &dyn ScoreDirector<S>) -> 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