[Quantproject-developers] QuantProject/b1_ADT/Optimizing/Genetic Genome.cs,1.8,1.9
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2005-09-18 21:07:33
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2235/b1_ADT/Optimizing/Genetic Modified Files: Genome.cs Log Message: Added SharesNoGeneWith method. Index: Genome.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/Genome.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Genome.cs 28 Aug 2005 09:59:36 -0000 1.8 --- Genome.cs 18 Sep 2005 21:07:21 -0000 1.9 *************** *** 43,48 **** private bool hasBeenChanged; ! IGenomeManager genomeManager; ! public bool HasBeenCloned { --- 43,49 ---- private bool hasBeenChanged; ! private IGenomeManager genomeManager; ! private int generation; ! public bool HasBeenCloned { *************** *** 94,98 **** public int Generation { ! get{return this.genomeManager.CurrentGeneticOptimizer.GenerationCounter;} } --- 95,100 ---- public int Generation { ! get{return this.generation;} ! //set{this.generation = value;} } *************** *** 130,133 **** --- 132,138 ---- for (int i = 0 ; i < this.size ; i++) this.genes[i] = this.genomeManager.GetNewGeneValue(this); + //whenever at least one gene has been written, + //the current generation number is stored + this.generation = this.genomeManager.CurrentGeneticOptimizer.GenerationCounter; } *************** *** 161,164 **** --- 166,172 ---- for (int i = 0 ; i < this.size ; i++) this.genes[i] = valuesToBeCopied[i]; + //whenever at least one gene has been written, + //the current generation number is stored + this.generation = this.genomeManager.CurrentGeneticOptimizer.GenerationCounter; } *************** *** 169,172 **** --- 177,183 ---- this.genes[genePosition] = geneValue; + //whenever at least one gene has been written, + //the current generation number is stored + this.generation = this.genomeManager.CurrentGeneticOptimizer.GenerationCounter; this.hasBeenChanged = true; } *************** *** 195,198 **** --- 206,224 ---- /// <summary> + /// It returns true if the current instance shares no gene with the given + /// genome + /// </summary> + public bool SharesNoGeneWith(Genome genomeToBeCompared) + { + bool returnValue = true; + foreach(int gene in this.Genes()) + { + if( genomeToBeCompared.HasGene(gene) ) + return false; + } + return returnValue; + } + + /// <summary> /// It returns true if the current instance of genome has some duplicate /// values in genes |