Ejemplo n.º 1
0
        /// <summary>
        /// Creates the default operators.
        /// </summary>
        private void CreateDefaultOperators()
        {
            //Note: In this method we are dealing with both the GAF.Operators operators AND
            //the Api.Operators namespace. The former is the actual operator as used in the GAF,
            //the latter is the API interface presented to clients (GUIs etc.).
            //The CreateOperatorApi helper function is used to create these combinations.

            //create a set of default operators
            IGeneticOperator elite = new GAF.Operators.Elite(5);

            Elite = CreateOperatorApi <GAF.Api.Operators.Elite> (elite, true);

            IGeneticOperator crossover = new GAF.Operators.Crossover(0.8, true, GAF.Operators.CrossoverType.DoublePoint, GAF.Operators.ReplacementMethod.GenerationalReplacement);

            Crossover = CreateOperatorApi <GAF.Api.Operators.Crossover> (crossover, true);

            IGeneticOperator binaryMutate = new GAF.Operators.BinaryMutate(0.02);

            BinaryMutate = CreateOperatorApi <GAF.Api.Operators.BinaryMutate> (binaryMutate, true);

            IGeneticOperator swapMutate = new GAF.Operators.SwapMutate(0.04);

            SwapMutate = CreateOperatorApi <GAF.Api.Operators.SwapMutate> (swapMutate, false);

            IGeneticOperator randomReplace = new GAF.Operators.RandomReplace(10, true);

            RandomReplace = CreateOperatorApi <GAF.Api.Operators.RandomReplace> (randomReplace, false);

            IGeneticOperator memory = new GAF.Operators.Memory(100, 10);

            Memory = CreateOperatorApi <GAF.Api.Operators.Memory> (memory, false);
        }
Ejemplo n.º 2
0
 private static void SwapMutateCode(ref StringBuilder sourceCode, Api.Operators.SwapMutate geneticOperator)
 {
     if (geneticOperator.Enabled)
     {
         sourceCode.Append(string.Format("  var swapMutate = new SwapMutate(mutationProbability: {0});\r\n\r\n",
                                         geneticOperator.Probability));
     }
 }