Ejemplo n.º 1
0
 internal Worker(T[] vector, int fromIndex, int toIndex, Func <T[], Gene, double> f, Gene gene)
 {
     _vector = vector;
     //_fromIndex = fromIndex; //(fromIndex == 0) ? fromIndex: fromIndex - 2;
     //_toIndex = toIndex; //(toIndex == vector.Length-1) ? toIndex: toIndex+2;
     //int length = _toIndex - _fromIndex + 1;
     //_vector = new T[length];
     _f    = f;
     _Gene = gene;
     //for(int i = _fromIndex; i < length; i++) {
     //	_vector[i] = vector[i];
     //}
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Search the specified array.
        /// </summary>
        /// <returns>The search.</returns>
        /// <param name="array">Array.</param>
        public static double Search(char[] array, Gene gene)
        {
            // The number of appearances of genes.
            var result = 0;

            int i          = 0;
            int _ChunkSize = 2;

            while (!(i == array.Length - 2 && _ChunkSize == 3))
            {
                //Console.WriteLine(1);

                var _Chunk = array.SubArray(i, _ChunkSize);

                //Console.WriteLine(2);

                if (gene.Is(_Chunk))
                {
                    result++;
                }

                //Console.WriteLine(3);

                if (_ChunkSize == 2)
                {
                    _ChunkSize = 3;
                }
                else
                {
                    _ChunkSize = 2;
                    i++;
                }

                //Console.WriteLine(4);
            }

            return(result);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:examples.genetics.Processor"/> class.
 /// </summary>
 /// <param name="vector">Vector.</param>
 /// <param name="gene">Gene.</param>
 public Processor(char[] vector, Gene gene)
 {
     _vector = vector;
     _gene   = gene;
 }