Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void run(I ind) {
- /** Scramble Mutation
- Scramble mutation is also popular with permutation representations.
- In this, from the entire chromosome, a subset of genes is chosen
- and their values are scrambled or shuffled randomly.
- **/
- if(GeneticAlgorithm.random.nextDouble()<=probability) {
- int p1 = GeneticAlgorithm.random.nextInt(ind.getGenome().length+1-0)-0;
- int p2= GeneticAlgorithm.random.nextInt(p1+1-0)-0;
- System.out.println(p2+"-"+p1);
- for (int i = p2; i < p1; i++) {
- int pos1=GeneticAlgorithm.random.nextInt(p1-i)+i;
- System.out.println(pos1+" "+i);
- ind.swapGenesMutation(ind, i, pos1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement