Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28561/b1_ADT/Optimizing/Genetic
Modified Files:
Genome.cs
Log Message:
Method HasGene has been overloaded: added parameters fromGenePosition and toGenePosition in order to perform check only in the given section of the genome
Index: Genome.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/Genome.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Genome.cs 7 Aug 2006 21:03:24 -0000 1.13
--- Genome.cs 22 Aug 2006 19:07:50 -0000 1.14
***************
*** 209,212 ****
--- 209,237 ----
return returnValue;
}
+
+ /// <summary>
+ /// It returns true if the given gene is already stored in the current genome
+ /// </summary>
+ /// <param name="fromGenePosition">First gene position from which the checking
+ /// has to be done, inside the given genome</param>
+ /// <param name="toGenePosition">Last gene position to which the checking
+ /// has to be done, inside the given genome</param>
+ public bool HasGene(int geneValue, int fromGenePosition,
+ int toGenePosition)
+ {
+ if(fromGenePosition < 0 ||
+ toGenePosition < 0 ||
+ fromGenePosition >= this.size ||
+ toGenePosition >= this.size)
+ throw new IndexOutOfRangeException("error in parameters fromGenePosition or toGenePosition!");
+
+ bool returnValue = false;
+ for(int i = fromGenePosition; i <= toGenePosition; i++)
+ {
+ if( geneValue == this.Genes()[i] )
+ returnValue = true;
+ }
+ return returnValue;
+ }
/// <summary>
|