// In the GECCO paper, Figure 1
        private double iterate()
        {
            // Create a random solution
            BinaryVector solution = new BinaryVector(tracker.Length);

            for (int i = 0; i < solution.Length; i++)
            {
                solution[i] = random.Next(2) == 1;
            }
            double fitness = tracker.Evaluate(solution, random);

            fitness = HillClimber.ImproveToLocalOptimum(tracker, solution, fitness, random);
            AddIfUnique(solution, 0);

            for (int level = 0; level < pyramid.Count; level++)
            {
                var    current    = pyramid[level];
                double newFitness = LinkageCrossover.ImproveUsingTree(current.Tree, current.Solutions, solution, fitness, tracker, random);
                // add it to the next level if its a strict fitness improvement
                if (tracker.IsBetter(newFitness, fitness))
                {
                    fitness = newFitness;
                    AddIfUnique(solution, level + 1);
                }
            }
            return(fitness);
        }
示例#2
0
 protected HillClimber(HillClimber original, Cloner cloner)
     : base(original, cloner)
 {
 }
示例#3
0
 protected HillClimber(HillClimber original, Cloner cloner)
   : base(original, cloner) {
 }