[Quantproject-developers] QuantProject/b1_ADT/Optimizing/Genetic Genome.cs, 1.19, 1.20
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2007-08-31 23:19:43
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv9981/b1_ADT/Optimizing/Genetic Modified Files: Genome.cs Log Message: Fixed very critical bug !!! After changing Fitness and Meaning property access, I forgot to reset the private fields when single genes are changed, in order to force a new fitness and meaning calculation. These kinds of error should be avoided through a more object oriented organization of the GeneticOptimizer, but I think that would slow down scripts' execution. Now the GeneticOptimizer has turned to work properly Index: Genome.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/Genome.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Genome.cs 21 Aug 2007 21:52:24 -0000 1.19 --- Genome.cs 31 Aug 2007 23:19:34 -0000 1.20 *************** *** 200,205 **** throw new IndexOutOfRangeException("Gene value not valid for the gene at" + " the given position!"); ! this.genes[genePosition] = geneValue; //whenever at least one gene has been written, //the current generation number is stored --- 200,212 ---- throw new IndexOutOfRangeException("Gene value not valid for the gene at" + " the given position!"); + if( geneValue != this.GetGeneValue(genePosition) ) + // if a new value is stored in the given position, then + // fitness has to be calculated again, and so meaning + { + this.hasFitnessBeenAssigned = false; + this.meaning = null; + } ! this.genes[genePosition] = geneValue; //whenever at least one gene has been written, //the current generation number is stored |