Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/13/15 15:00:15 (10 years ago)
Author:
abeham
Message:

#2174, #2282: merged revisions r11961,r11963,r11967,r11970,r11971,r11982,r11984,r11998,r12001,r12002,r12003,r12004,r11939,r11945,r11956,r11958,r11959,r11960,r11983,r11987,r11988,r11990,r11993,r11994,r11996,r11999,r12000 to stable

Location:
stable
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageCrossover.cs

    r11838 r12005  
    2020 */
    2121#endregion
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
    25 using System.Text;
    26 using System.Threading.Tasks;
    2724using HeuristicLab.Core;
     25using HeuristicLab.Encodings.BinaryVectorEncoding;
     26using HeuristicLab.Problems.Binary;
    2827using HeuristicLab.Random;
    2928
     
    3433  public static class LinkageCrossover {
    3534    // In the GECCO paper, Figure 3
    36     public static double ImproveUsingTree(LinkageTree tree, IList<bool[]> donors, bool[] solution, double fitness, IBinaryVectorProblem problem, IRandom rand) {
     35    public static double ImproveUsingTree(LinkageTree tree, IList<BinaryVector> donors, BinaryVector solution, double fitness, BinaryProblem problem, IRandom rand) {
    3736      var options = Enumerable.Range(0, donors.Count).ToArray();
    3837      foreach (var cluster in tree.Clusters) {
     
    4241        foreach (var donorIndex in options.ShuffleList(rand)) {
    4342          // Attempt the donation
    44           fitness = Donate(solution, fitness, donors[donorIndex], cluster, problem, out donorFound);
     43          fitness = Donate(solution, fitness, donors[donorIndex], cluster, problem, rand, out donorFound);
    4544          if (donorFound) break;
    4645        }
     
    4948    }
    5049
    51     private static double Donate(bool[] solution, double fitness, bool[] source, IEnumerable<int> cluster, IBinaryVectorProblem problem, out bool changed) {
     50    private static double Donate(BinaryVector solution, double fitness, BinaryVector source, IEnumerable<int> cluster, BinaryProblem problem, IRandom rand, out bool changed) {
    5251      // keep track of which bits flipped to make the donation
    5352      List<int> flipped = new List<int>();
     
    6059      changed = flipped.Count > 0;
    6160      if (changed) {
    62         double newFitness = problem.Evaluate(solution);
     61        double newFitness = problem.Evaluate(solution, rand);
    6362        // if the original is strictly better, revert the change
    6463        if (problem.IsBetter(fitness, newFitness)) {
Note: See TracChangeset for help on using the changeset viewer.