Skip to content

Question about crossover #1

@kossolax

Description

@kossolax

Hello,

I've read your article on medium and I've question. In the crossover function, wouldn't be better to swap value randomly from left or right? With this implementation first genre is more prone to change than last gene of an individual. Is this intentional ?

void crossover() {
Random rn = new Random();
//Select a random crossover point
int crossOverPoint = rn.nextInt(this.numberOfGenes);
//Swap values among parents
for (int i = 0; i < crossOverPoint; i++) {
int temp = fittest.getGenes()[i];
fittest.getGenes()[i] = secondFittest.getGenes()[i];
secondFittest.getGenes()[i] = temp;
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions