Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Candidate newChild(Candidate c1, Candidate c2, int pivot) {
- Candidate newCandidate = new Candidate(cubeSize);
- Set<Integer> usedGenes = new HashSet<Integer>(pivot);
- int pivotPointPos = pivot;
- for(int i=0; i<=pivotPointPos; i++) {
- newCandidate.genotype[i] = c1.genotype[i];
- usedGenes.add(c1.genotype[i]);
- }
- for(int i=0; i<numElements; i++) {
- if(!usedGenes.contains(c2.genotype[i])) {
- newCandidate.genotype[++pivotPointPos] = c2.genotype[i];
- }
- }
- return newCandidate;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement