Changeset 12005 for stable/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageCrossover.cs
- Timestamp:
- 02/13/15 15:00:15 (10 years ago)
- Location:
- stable
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 11939,11945,11956,11958-11961,11963,11967,11970-11971,11982-11984,11987-11988,11990,11993-11994,11996,11998-12004
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageCrossover.cs
r11838 r12005 20 20 */ 21 21 #endregion 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; 25 using System.Text;26 using System.Threading.Tasks;27 24 using HeuristicLab.Core; 25 using HeuristicLab.Encodings.BinaryVectorEncoding; 26 using HeuristicLab.Problems.Binary; 28 27 using HeuristicLab.Random; 29 28 … … 34 33 public static class LinkageCrossover { 35 34 // 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) { 37 36 var options = Enumerable.Range(0, donors.Count).ToArray(); 38 37 foreach (var cluster in tree.Clusters) { … … 42 41 foreach (var donorIndex in options.ShuffleList(rand)) { 43 42 // 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); 45 44 if (donorFound) break; 46 45 } … … 49 48 } 50 49 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) { 52 51 // keep track of which bits flipped to make the donation 53 52 List<int> flipped = new List<int>(); … … 60 59 changed = flipped.Count > 0; 61 60 if (changed) { 62 double newFitness = problem.Evaluate(solution );61 double newFitness = problem.Evaluate(solution, rand); 63 62 // if the original is strictly better, revert the change 64 63 if (problem.IsBetter(fitness, newFitness)) {
Note: See TracChangeset
for help on using the changeset viewer.