예제 #1
0
 public EvolvingParticleSwarm(ConsoleLogger logger, Evolution evolution, int iterationCount, double cognitiveAttraction, double socialAttraction)
 {
     _logger              = logger;
     _evolution           = evolution;
     _iterationCount      = iterationCount;
     _cognitiveAttraction = cognitiveAttraction;
     _socialAttraction    = socialAttraction;
 }
예제 #2
0
        private static IParticleSwarm GetEvolvingParticleSwarm(ConsoleLogger logger, int iterationCount, double cognitiveAttraction, double socialAttraction)
        {
            var iterationsPerGeneration = Read($"Number of iterations per generation (enter to use default {DefaultIterationsPerGeneration}): ", DefaultIterationsPerGeneration, int.Parse);
            var mutationProbability     = Read($"Probability of mutation (enter to use default {DefaultMutationProbability}): ", DefaultMutationProbability, double.Parse);
            var k = Read($"Tournament size (enter to use default {DefaultK}): ", DefaultK, int.Parse);

            var evolution = new Evolution(iterationsPerGeneration, k, mutationProbability);

            return(new EvolvingParticleSwarm(logger, evolution, iterationCount, cognitiveAttraction, socialAttraction));
        }