pub struct SwapMutation { /* private fields */ }Expand description
Swap mutation for permutation solutions.
Preserves permutation validity by swapping indexes.
Implementations§
Source§impl SwapMutation
impl SwapMutation
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/experiment_hill_climbing_demo.rs (line 21)
10fn main() {
11 let problem = TspProblem::with_distance_matrix(vec![
12 vec![0.0, 10.0, 25.0, 18.0, 12.0],
13 vec![10.0, 0.0, 14.0, 21.0, 17.0],
14 vec![25.0, 14.0, 0.0, 9.0, 16.0],
15 vec![18.0, 21.0, 9.0, 0.0, 11.0],
16 vec![12.0, 17.0, 16.0, 11.0, 0.0],
17 ])
18 .with_open_route();
19
20 let case_a = HillClimbingParameters::new(
21 SwapMutation::new(),
22 0.08,
23 TerminationCriteria::new(vec![TerminationCriterion::MaxIterations(120)]),
24 );
25
26 let case_b = HillClimbingParameters::new(
27 SwapMutation::new(),
28 0.20,
29 TerminationCriteria::new(vec![TerminationCriterion::MaxIterations(120)]),
30 );
31
32 let report = Experiment::new(problem)
33 .with_runs(12)
34 .add_case(case_a)
35 .add_case(case_b)
36 .execute();
37
38 match report {
39 Ok(report) => println!("{}", report.to_text_table()),
40 Err(error) => eprintln!("Experiment execution failed: {}", error),
41 }
42}Trait Implementations§
Source§impl Clone for SwapMutation
impl Clone for SwapMutation
Source§fn clone(&self) -> SwapMutation
fn clone(&self) -> SwapMutation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for SwapMutation
impl Default for SwapMutation
Source§impl MutationOperator<usize> for SwapMutation
impl MutationOperator<usize> for SwapMutation
Auto Trait Implementations§
impl Freeze for SwapMutation
impl RefUnwindSafe for SwapMutation
impl Send for SwapMutation
impl Sync for SwapMutation
impl Unpin for SwapMutation
impl UnsafeUnpin for SwapMutation
impl UnwindSafe for SwapMutation
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