public NeuralGeneticAlgorithm(BasicNetwork network, IRandomizer randomizer, ICalculateScore calculateScore, int populationSize, double mutationPercent, double percentToMate)
: base(TrainingImplementationType.Iterative)
{
NeuralGeneticAlgorithmHelper helper;
Label_012F:
helper = new NeuralGeneticAlgorithmHelper();
helper.CalculateScore = new GeneticScoreAdapter(calculateScore);
this.Genetic = helper;
IPopulation population = new BasicPopulation(populationSize);
this.Genetic.MutationPercent = mutationPercent;
this.Genetic.MatingPopulation = percentToMate * 2.0;
this.Genetic.PercentToMate = percentToMate;
this.Genetic.Crossover = new Splice(network.Structure.CalculateSize() / 3);
this.Genetic.Mutate = new MutatePerturb(4.0);
this.Genetic.Population = population;
int num = 0;
while (true)
{
NeuralGenome genome2;
if (num < population.PopulationSize)
{
BasicNetwork network2 = (BasicNetwork) network.Clone();
randomizer.Randomize(network2);
if ((((uint) percentToMate) + ((uint) populationSize)) >= 0)
{
genome2 = new NeuralGenome(network2) {
GA = this.Genetic
};
}
}
else
{
population.Sort();
if (((uint) populationSize) <= uint.MaxValue)
{
return;
}
goto Label_012F;
}
if ((((uint) num) + ((uint) populationSize)) >= 0)
{
NeuralGenome g = genome2;
this.Genetic.PerformCalculateScore(g);
if (((uint) populationSize) > uint.MaxValue)
{
goto Label_012F;
}
this.Genetic.Population.Add(g);
num++;
}
}
}