~alexreg/darwindotnet/0.1

« back to all changes in this revision

Viewing changes to Samples/SymbolicRegression/Genetics.cs

  • Committer: Alex Regueiro
  • Date: 2009-03-27 19:00:22 UTC
  • Revision ID: alexreg@gmail.com-20090327190022-f571a7jsdwv3dny5
Updated XML comments for documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
        {
19
19
            var exprChromsome = (ExpressionChromosome<MathSymbol>)chromosome;
20
20
            if (index < exprChromsome.HeadLength)
21
 
                return _rand.Next(0, (int)MathSymbol.Max);
 
21
                return rand.Next(0, (int)MathSymbol.Max);
22
22
            else
23
 
                return _rand.Next((int)MathSymbol.FunctionMax, (int)MathSymbol.Max);
 
23
                return rand.Next((int)MathSymbol.FunctionMax, (int)MathSymbol.Max);
24
24
        }
25
25
    }
26
26
 
34
34
        public override void Transpose(Chromosome chromosome, out int startIndex, out int destinationIndex,
35
35
            out int length, out bool insert)
36
36
        {
37
 
            length = _rand.Next(1, 4);
38
 
            startIndex = _rand.Next(0, chromosome.Length - length);
39
 
            destinationIndex = _rand.Next(1, chromosome.Length - length);
 
37
            length = rand.Next(1, 4);
 
38
            startIndex = rand.Next(0, chromosome.Length - length);
 
39
            destinationIndex = rand.Next(1, chromosome.Length - length);
40
40
            insert = false;
41
41
        }
42
42
    }
54
54
            var minLength = Math.Min(chromosomeA.Length, chromosomeB.Length);
55
55
 
56
56
            // Double-point crossover
57
 
            length = _rand.Next(1, minLength);
58
 
            index = _rand.Next(0, minLength - length);
 
57
            length = rand.Next(1, minLength);
 
58
            index = rand.Next(0, minLength - length);
59
59
        }
60
60
    }
61
61