/// <summary> /// Configures and instantiates the initialization evolutionary algorithm. /// </summary> /// <param name="parallelOptions">Synchronous/Asynchronous execution settings.</param> /// <param name="genomeList">The initial population of genomes.</param> /// <param name="genomeFactory">The genome factory initialized by the main evolution thread.</param> /// <param name="mazeEnvironment">The maze on which to evaluate the navigators.</param> /// <param name="genomeDecoder">The decoder to translate genomes into phenotypes.</param> /// <param name="startingEvaluations"> /// The number of evaluations that preceeded this from which this process will pick up /// (this is used in the case where we're restarting a run because it failed to find a solution in the allotted time). /// </param> public override void InitializeAlgorithm(ParallelOptions parallelOptions, List <NeatGenome> genomeList, IGenomeFactory <NeatGenome> genomeFactory, MazeStructure mazeEnvironment, IGenomeDecoder <NeatGenome, IBlackBox> genomeDecoder, ulong startingEvaluations) { // Set the boiler plate algorithm parameters base.InitializeAlgorithm(parallelOptions, genomeList, genomeDecoder, startingEvaluations); // Create the initialization evolution algorithm. InitializationEa = new GenerationalComplexifyingEvolutionAlgorithm <NeatGenome>(SpeciationStrategy, ComplexityRegulationStrategy, RunPhase.Initialization); // Create IBlackBox evaluator. MazeNavigatorFitnessInitializationEvaluator mazeNavigatorEvaluator = new MazeNavigatorFitnessInitializationEvaluator(MinSuccessDistance, MaxDistanceToTarget, mazeEnvironment, startingEvaluations); // Create the genome evaluator IGenomeEvaluator <NeatGenome> fitnessEvaluator = new ParallelGenomeFitnessEvaluator <NeatGenome, IBlackBox>( genomeDecoder, mazeNavigatorEvaluator, parallelOptions); // Only pull the number of genomes from the list equivalent to the initialization algorithm population size // (this is to handle the case where the list was created in accordance with the primary algorithm // population size, which is quite likely larger) genomeList = genomeList.Take(PopulationSize).ToList(); // Replace genome factory primary NEAT parameters with initialization parameters ((NeatGenomeFactory)genomeFactory).ResetNeatGenomeParameters(NeatGenomeParameters); // Initialize the evolution algorithm InitializationEa.Initialize(fitnessEvaluator, genomeFactory, genomeList, null, null); }
/// <summary> /// Configures and instantiates the initialization evolutionary algorithm. /// </summary> /// <param name="parallelOptions">Synchronous/Asynchronous execution settings.</param> /// <param name="genomeList">The initial population of genomes.</param> /// <param name="genomeFactory">The genome factory initialized by the main evolution thread.</param> /// <param name="mazeEnvironment">The maze on which to evaluate the navigators.</param> /// <param name="genomeDecoder">The decoder to translate genomes into phenotypes.</param> /// <param name="startingEvaluations"> /// The number of evaluations that preceeded this from which this process will pick up /// (this is used in the case where we're restarting a run because it failed to find a solution in the allotted time). /// </param> public override void InitializeAlgorithm(ParallelOptions parallelOptions, List<NeatGenome> genomeList, IGenomeFactory<NeatGenome> genomeFactory, MazeStructure mazeEnvironment, IGenomeDecoder<NeatGenome, IBlackBox> genomeDecoder, ulong startingEvaluations) { // Set the boiler plate algorithm parameters base.InitializeAlgorithm(parallelOptions, genomeList, genomeDecoder, startingEvaluations); // Create the initialization evolution algorithm. InitializationEa = new GenerationalNeatEvolutionAlgorithm<NeatGenome>(SpeciationStrategy, ComplexityRegulationStrategy, RunPhase.Initialization); // Create IBlackBox evaluator. MazeNavigatorFitnessInitializationEvaluator mazeNavigatorEvaluator = new MazeNavigatorFitnessInitializationEvaluator(MaxTimesteps, MinSuccessDistance, MaxDistanceToTarget, mazeEnvironment, startingEvaluations); // Create the genome evaluator IGenomeEvaluator<NeatGenome> fitnessEvaluator = new ParallelGenomeFitnessEvaluator<NeatGenome, IBlackBox>( genomeDecoder, mazeNavigatorEvaluator, parallelOptions); // Only pull the number of genomes from the list equivalent to the initialization algorithm population size // (this is to handle the case where the list was created in accordance with the primary algorithm // population size, which is quite likely larger) genomeList = genomeList.Take(PopulationSize).ToList(); // Replace genome factory primary NEAT parameters with initialization parameters ((NeatGenomeFactory) genomeFactory).ResetNeatGenomeParameters(NeatGenomeParameters); // Initialize the evolution algorithm InitializationEa.Initialize(fitnessEvaluator, genomeFactory, genomeList, null, null); }