Re: [jgap-users] Need help understanding odd behavior
Brought to you by:
klausikm
From: Klaus M. <jg...@kl...> - 2009-02-07 14:56:15
|
Michael, as discussed and verified, the problem was insufficient cloning of chromosomes. Here, alleles were not cloned correctly. This does not seem to be a problem in case of IntegerGen, DoubleGene etc., but in case non-primitive object types, like custom ones, are used. I fixed the code in Chromosome.clone() and checked in the changes. Best Klaus www.klaus-meffert.com <http://www.klaus-meffert.com/> _____ From: Michael Grove [mailto:mh...@ho...] Sent: Tuesday, February 03, 2009 4:45 PM To: jga...@li... Subject: [jgap-users] Need help understanding odd behavior Hi, I'm new to JGAP and Genetic algorithms in general, and I'm seeing some behavior in JGAP that I don't understand. I'm sure this is a bug in my understanding of how things work rather than the API, so I hope someone can clarify for me what I'm doing wrong. First, a quick explanation of what I'm trying to do. I have a set of data, and each data point has some known properties (the values are doubles). Each of these data points has a particular property that is known, but there is also a known, but not very accurate, equation for estimating what it will be based on the other properties of the data point. Ideally I'd like to set up a chromosome that represents an equation, and see if I can evolve a better estimating equation. But I wanted to start simple. I figured this would require a custom Gene implementation, so I just wanted to start with a simple example first, and this is where I ran into some stuff I didnt quite understand. My simple test program to learn JGAP was first to create a default configuration, and implement a fitness function which calculates how close the numerical representation of a chromosome is to some predetermined value. So to start, each Chromosome had one DoubleGene. The fitness function just calculated how close that value was to the value I was looking for. When I created a population, looped 1000 times calling evolve on the population, and printed out the fittest individual at each step, I saw exactly what I expected, the fitness value of the best individual kept getting closer to zero; I was using the DeltaFitnessEvaluator since that's how the fitness function was implemented. So obviously, that worked great, so I started on my custom gene, whose expression was a double value. I took the same program & configuration as before, but this time instead of using a chromosome with a single double gene, it had a single gene of my new custom type. I ran the test program to evolve the population with my new custom gene, and here's where I started seeing things I didnt understand. The fitness values of the best chromosome decreased as expected, but my toString() function printed the double value of the single gene in the chromosome, and I was able to see that the fitness value for the chromosome was incorrect. I thought that maybe it was getting cached (a cursory examination of some jgap code led me to believe this was possible, ie getFitnessValue and getFitnessValueDirectly on a Chromosome), and some looking through the docs lead me to the setAlwaysCalcuateFitness function on the configuration. So I set that to true and ran the test program again. This time, the fitness values were correct, but the fitness value of the best individual no longer decreased, it looked like a random one was getting selected, or the whole population was getting thrown away each time or something, but there was no evolution going on. If a good solution was found, it was totally luck. So thinking that maybe there was a problem using this function, I reverted my test program back to using DoubleGene's to see if I'd see the same behavior, but with setAlwaysCalcuateFitness to true I had the same (correct) results as the initial run. So there's obviously some subtle interation between this setting and using a custom gene, I'm hoping someone can shed some light on this. Cheers, Mike _____ Windows LiveT: E-mail. Chat. Share. Get more ways to connect. Check it out. <http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_allup_explore_012009> |