Example #1
0
        public static void Recombine(T[] lhs, T[] rhs, T[][] result, RecombinationAlgorithm algorithm)
        {
            if (lhs.Length != rhs.Length)
            {
                throw new ArgumentException("The arrays to be recombined must both be of the same length.");
            }
            if (result.Length != 2)
            {
                throw new ArgumentException("The result array must have a length of 2.");
            }

            switch (algorithm)
            {
            case RecombinationAlgorithm.OnePointCrossover:
                RecombineOnePoint(lhs, rhs, result); break;

            case RecombinationAlgorithm.MultiPointCrossover:
                RecombineMultiPoint(lhs, rhs, result); break;

            case RecombinationAlgorithm.UniformCrossover:
                RecombineUniform(lhs, rhs, result); break;

            default: RecombineOnePoint(lhs, rhs, result); break;
            }
        }
Example #2
0
 public SimulationSettings(Objective objective)
 {
     this.Objective              = objective;
     this.KeepBestCreatures      = Default.KeepBestCreatures;
     this.SimulationTime         = Default.SimulationTime;
     this.PopulationSize         = Default.PopulationSize;
     this.SimulateInBatches      = Default.SimulateInBatches;
     this.BatchSize              = Default.BatchSize;
     this.MutationRate           = Default.MutationRate;
     this.SelectionAlgorithm     = Default.SelectionAlgorithm;
     this.RecombinationAlgorithm = Default.RecombinationAlgorithm;
     this.MutationAlgorithm      = Default.MutationAlgorithm;
 }