@ Override public SingleSwapMove getRandomMove ( PermutationSolution solution , Random rnd ) { int n = solution . size ( ) ; // check: move possible if ( n < 2 ) { return null ; } // pick two random, distinct positions to swap int i = rnd . nextInt ( n ) ; int j = rnd . nextInt ( n - 1 ) ; if ( j >= i ) { j ++ ; } // generate swap move return new SingleSwapMove ( i , j ) ; }
Create a random single swap move .