/// <summary> /// Create and return a SteadyStateNeatEvolutionAlgorithm object (specific to fitness-based evaluations) ready for /// running the /// NEAT algorithm/search based on the given genome factory and genome list. Various sub-parts of the algorithm are /// also constructed and connected up. /// </summary> /// <param name="genomeFactory">The genome factory from which to generate new genomes</param> /// <param name="genomeList">The current genome population</param> /// <param name="startingEvaluations">The number of evaluations that have been executed prior to the current run.</param> /// <returns>Constructed evolutionary algorithm</returns> public override INeatEvolutionAlgorithm<NeatGenome> CreateEvolutionAlgorithm( IGenomeFactory<NeatGenome> genomeFactory, List<NeatGenome> genomeList, ulong startingEvaluations) { FileDataLogger logger = null; // Create distance metric. Mismatched genes have a fixed distance of 10; for matched genes the distance is their weigth difference. IDistanceMetric distanceMetric = new ManhattanDistanceMetric(1.0, 0.0, 10.0); ISpeciationStrategy<NeatGenome> speciationStrategy = new ParallelKMeansClusteringStrategy<NeatGenome>(distanceMetric, ParallelOptions); // Create complexity regulation strategy. var complexityRegulationStrategy = ExperimentUtils.CreateComplexityRegulationStrategy(ComplexityRegulationStrategy, Complexitythreshold); // Initialize the logger if (_generationalLogFile != null) { logger = new FileDataLogger(_generationalLogFile); } // Create the evolution algorithm. var ea = new SteadyStateNeatEvolutionAlgorithm<NeatGenome>(NeatEvolutionAlgorithmParameters, speciationStrategy, complexityRegulationStrategy, _batchSize, _populationEvaluationFrequency, RunPhase.Primary, logger); // Create IBlackBox evaluator. var mazeNavigationEvaluator = new MazeNavigationRandomEvaluator(MaxDistanceToTarget, MaxTimesteps, MazeVariant, MinSuccessDistance); // Create genome decoder. var genomeDecoder = CreateGenomeDecoder(); IGenomeEvaluator<NeatGenome> fitnessEvaluator = new ParallelGenomeFitnessEvaluator<NeatGenome, IBlackBox>(genomeDecoder, mazeNavigationEvaluator, ParallelOptions); // Initialize the evolution algorithm. ea.Initialize(fitnessEvaluator, genomeFactory, genomeList, null, MaxEvaluations); // Finished. Return the evolution algorithm return ea; }
/// <summary> /// Create and return a SteadyStateNeatEvolutionAlgorithm object (specific to fitness-based evaluations) ready for /// running the /// NEAT algorithm/search based on the given genome factory and genome list. Various sub-parts of the algorithm are /// also constructed and connected up. /// </summary> /// <param name="genomeFactory">The genome factory from which to generate new genomes</param> /// <param name="genomeList">The current genome population</param> /// <param name="startingEvaluations">The number of evaluations that have been executed prior to the current run.</param> /// <returns>Constructed evolutionary algorithm</returns> public override INeatEvolutionAlgorithm<NeatGenome> CreateEvolutionAlgorithm( IGenomeFactory<NeatGenome> genomeFactory, List<NeatGenome> genomeList, ulong startingEvaluations) { // Create complexity regulation strategy. var complexityRegulationStrategy = ExperimentUtils.CreateComplexityRegulationStrategy(ComplexityRegulationStrategy, Complexitythreshold); // Create the evolution algorithm. AbstractNeatEvolutionAlgorithm<NeatGenome> ea = new QueueingNeatEvolutionAlgorithm<NeatGenome>(NeatEvolutionAlgorithmParameters, new ParallelKMeansClusteringStrategy<NeatGenome>(new ManhattanDistanceMetric(1.0, 0.0, 10.0), ParallelOptions), complexityRegulationStrategy, _batchSize, RunPhase.Primary); // Create IBlackBox evaluator. IPhenomeEvaluator<IBlackBox, FitnessInfo> mazeNavigationEvaluator = new MazeNavigationRandomEvaluator(MaxDistanceToTarget, MaxTimesteps, MazeVariant, MinSuccessDistance); // Create genome decoder. IGenomeDecoder<NeatGenome, IBlackBox> genomeDecoder = CreateGenomeDecoder(); IGenomeEvaluator<NeatGenome> fitnessEvaluator = new SerialGenomeFitnessEvaluator<NeatGenome, IBlackBox>(genomeDecoder, mazeNavigationEvaluator, _evaluationDataLogger); // IGenomeEvaluator<NeatGenome> fitnessEvaluator = // new ParallelGenomeFitnessEvaluator<NeatGenome, IBlackBox>(genomeDecoder, mazeNavigationEvaluator, // _evaluationDataLogger, SerializeGenomeToXml); // Initialize the evolution algorithm. ea.Initialize(fitnessEvaluator, genomeFactory, genomeList, DefaultPopulationSize, null, MaxEvaluations); // Finished. Return the evolution algorithm return ea; }