-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
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 ?
GeneticAlgorithm/src/fr/dieul/lab/geneticalgorithm/SimpleDemoGA.java
Lines 106 to 120 in c61bf2a
| 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
Labels
No labels