Hi, I have a question to crossover probability. On JGAP web site we can
read that: * *Natural selection in JGAP is statistical, so chromosomes that are more fit have a better statistical chance of being selected over chromosomes that are less fit, but it's not guaranteed. So I assumed, that probability of choosing chromosome to crossover depending on fitness value of this chromosome. But when in studied the CrossOverOperator i have noticed something like that: public void operate(final Population a_population, final List a_candidateChromosomes) { // Work out the number of crossovers that should be performed. // ----------------------------------------------------------- int size = Math.min(getConfiguration().getPopulationSize(), a_population.size()); int numCrossovers = 0; if (m_crossoverRate >= 0) { numCrossovers = size / m_crossoverRate; } else if (m_crossoverRateCalc != null) { numCrossovers = size / m_crossoverRateCalc.calculateCurrentRate(); } else { numCrossovers = (int) (size * m_crossoverRatePercent); } Where calculateCurrentRate() return int. So: 1. The fitness value of chromosome does not impact on the probability of choosing this chromosome to crossover right?? The only place where the fitness value is used is in NaturalSelector where we choose "n" best chromosomes, yes? 2. Even if I wrote my own UniversalRateCalc, the rate(probability) of crossover is the same for every chromosome in this evolution, yes? So what should I do if I want that probability of crossover of particular chromosome is an individual value for each chromosome in this population and depends of fitness value of this chromosome? ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev _______________________________________________ jgap-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/jgap-users |
Hi,
I was also pondering about this a bit - I'll have to write my own crossover operator anyway and will need the same kind of logic as you, so I may just as well share my thoughts here... Krzysztof Chmielewski schrieb: > Hi, I have a question to crossover probability. On JGAP web site we can > read that: * > > *Natural selection in JGAP is statistical, so chromosomes that are more > fit have a better statistical chance of being selected over chromosomes > that are less fit, but it's not guaranteed. > Well, this basically says what it says: the probability of *selection* (i.e. the chance of actually making it into the next generation) depends on the fitness, but in a stochastic manner. It does not state anything about the crossover procedure, so technically, this is correct. > So I assumed, that probability of choosing chromosome to crossover > depending on fitness value of this chromosome. As said above, not exactly. Crossover is just another genetic operator that happens before selection. You may want to have the mating chromosomes chosen in a "more intelligent" way than randomly, but the default approach obviously is to do it randomly. > But when in studied the > CrossOverOperator i have noticed something like that: > > public void operate(final Population a_population, > final List a_candidateChromosomes) { > // Work out the number of crossovers that should be performed. > // ----------------------------------------------------------- > int size = Math.min(getConfiguration().getPopulationSize(), > a_population.size()); > int numCrossovers = 0; > if (m_crossoverRate >= 0) { > numCrossovers = size / m_crossoverRate; > } > else if (m_crossoverRateCalc != null) { > numCrossovers = size / m_crossoverRateCalc.calculateCurrentRate(); > } > else { > numCrossovers = (int) (size * m_crossoverRatePercent); > } > > Where calculateCurrentRate() return int. > > So: > 1. The fitness value of chromosome does not impact on the probability of > choosing this chromosome to crossover right?? The only place where the > fitness value is used is in NaturalSelector where we choose "n" best > chromosomes, yes? > 2. Even if I wrote my own UniversalRateCalc, the rate(probability) of > crossover is the same for every chromosome in this evolution, yes? > > So what should I do if I want that probability of crossover of > particular chromosome is an individual value for each chromosome in this > population and depends of fitness value of this chromosome? > the code ;-) What you described is the calculation of *how many* crossovers will take place at all. However, what you're really interested in is: for each of the eventual crossovers, *who* will be mating? That's just a few lines down the code, in the following block: for (int i=0; i < numCrossovers; i++) { index1 = generator.nextInt(size); index2 = generator.nextInt(size); IChromosome chrom1 = a_population.getChromosome(index1); IChromosome chrom2 = a_population.getChromosome(index1); [...] } This is where you want to change things. Essentially what you want is something like this: for (int i=0; i < numCrossovers; i++) { IChromosome chrom1 = wheelOfFortuneChromosome(generator.nextDouble()); [...] } or so. The implementation is up to you then, but basically you'll need to write your own CrossoverOperator that chooses the chromosomes you want. Hope that helps, cheers, Chris ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev _______________________________________________ jgap-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/jgap-users smime.p7s (9K) Download Attachment |
In reply to this post by Krzysztof Chmielewski
Krzysztof,
the JGAP documentation refers to the probability of selecting individuals into the next generation, NOT to the probability of crossing over. So your understanding in 1) is correct Regarding your point 2): This is not correct, I think: You can write your own implementation that controls the probability of crossing over dependent on the individuals' fitness . In general: It only makes sense to crossover individuals that are selected beforehand. Best Klaus www.klaus-meffert.com > -----Original Message----- > From: Krzysztof Chmielewski [mailto:[hidden email]] > Sent: Friday, December 04, 2009 1:50 AM > To: [hidden email] > Subject: [jgap-users] crossover probability > > Hi, I have a question to crossover probability. On JGAP web > site we can read that: * > > *Natural selection in JGAP is statistical, so chromosomes > that are more fit have a better statistical chance of being > selected over chromosomes that are less fit, but it's not guaranteed. > > So I assumed, that probability of choosing chromosome to > crossover depending on fitness value of this chromosome. But > when in studied the CrossOverOperator i have noticed > something like that: > > public void operate(final Population a_population, > final List a_candidateChromosomes) { > // Work out the number of crossovers that should be performed. > // ----------------------------------------------------------- > int size = Math.min(getConfiguration().getPopulationSize(), > a_population.size()); > int numCrossovers = 0; > if (m_crossoverRate >= 0) { > numCrossovers = size / m_crossoverRate; > } > else if (m_crossoverRateCalc != null) { > numCrossovers = size / > m_crossoverRateCalc.calculateCurrentRate(); > } > else { > numCrossovers = (int) (size * m_crossoverRatePercent); > } > > Where calculateCurrentRate() return int. > > So: > 1. The fitness value of chromosome does not impact on the > probability of choosing this chromosome to crossover right?? > The only place where the fitness value is used is in > NaturalSelector where we choose "n" best chromosomes, yes? > 2. Even if I wrote my own UniversalRateCalc, the > rate(probability) of crossover is the same for every > chromosome in this evolution, yes? > > So what should I do if I want that probability of crossover > of particular chromosome is an individual value for each > chromosome in this population and depends of fitness value of > this chromosome? > > > > -------------------------------------------------------------- > ---------------- > Join us December 9, 2009 for the Red Hat Virtual Experience, > a free event focused on virtualization and cloud computing. > Attend in-depth sessions from your desk. Your couch. Anywhere. > http://p.sf.net/sfu/redhat-sfdev2dev > _______________________________________________ > jgap-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/jgap-users ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev _______________________________________________ jgap-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/jgap-users |
Free forum by Nabble | Edit this page |