Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Candidate mutate(Candidate c) {
- int swapPos1, swapPos2;
- swapPos1 = rnd.nextInt(numElements);
- swapPos2 = rnd.nextInt(numElements);
- while(swapPos1 == swapPos2) {
- swapPos2 = rnd.nextInt(numElements);
- }
- int temp = c.genotype[swapPos1];
- c.genotype[swapPos1] = c.genotype[swapPos2];
- c.genotype[swapPos2] = temp;
- return c;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement