- Timestamp:
- 06/10/17 23:19:11 (8 years ago)
- Location:
- branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/CharacteristicCalculator/UpDownWalkCalculator.cs
r13920 r15031 58 58 characteristics = cloner.Clone(original.characteristics); 59 59 } 60 public UpDownWalkCalculator() { 60 public UpDownWalkCalculator() : this(new UpDownWalk()) { } 61 public UpDownWalkCalculator(UpDownWalk walker) { 61 62 Name = ItemName; 62 63 Description = ItemDescription; 63 walker = new UpDownWalk();64 this.walker = walker; 64 65 characteristics = new CheckedItemList<StringValue>( 65 66 new[] { "AutoCorrelation1", "CorrelationLength", "InformationContent", -
branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/ProblemCharacteristicAnalysis/QAP/QAPDirectedWalk.cs
r14691 r15031 79 79 private QAPDirectedWalk(QAPDirectedWalk original, Cloner cloner) : base(original, cloner) { } 80 80 public QAPDirectedWalk() { 81 characteristics.AddRange(new[] { "Swap2.Sharpness", "Swap2.Bumpiness", "Swap2.Flatness" , /*"Swap2.Steadiness"*/}81 characteristics.AddRange(new[] { "Swap2.Sharpness", "Swap2.Bumpiness", "Swap2.Flatness" } 82 82 .Select(x => new StringValue(x)).ToList()); 83 83 Parameters.Add(new FixedValueParameter<IntValue>("Paths", "The number of paths to explore (a path is a set of solutions that connect two randomly chosen solutions).", new IntValue(50))); … … 98 98 IRandom random = Seed.HasValue ? new MersenneTwister((uint)Seed.Value) : new MersenneTwister(); 99 99 var qap = (QuadraticAssignmentProblem)Problem; 100 var pathCount = Paths; 101 100 List<Permutation> permutations = CalculateRelinkingPoints(random, qap, Paths, LocalOptima); 101 102 var trajectories = Run(random, (QuadraticAssignmentProblem)Problem, permutations, BestImprovement).ToList(); 103 var result = PermutationPathAnalysis.GetCharacteristics(trajectories); 104 105 foreach (var chara in characteristics.CheckedItems.Select(x => x.Value.Value)) { 106 if (chara == "Swap2.Sharpness") yield return new Result("Swap2.Sharpness", new DoubleValue(result.Sharpness)); 107 if (chara == "Swap2.Bumpiness") yield return new Result("Swap2.Bumpiness", new DoubleValue(result.Bumpiness)); 108 if (chara == "Swap2.Flatness") yield return new Result("Swap2.Flatness", new DoubleValue(result.Flatness)); 109 } 110 } 111 112 public static List<Permutation> CalculateRelinkingPoints(IRandom random, QuadraticAssignmentProblem qap, int pathCount, bool localOptima) { 102 113 var perm = new Permutation(PermutationTypes.Absolute, qap.Weights.Rows, random); 103 if ( LocalOptima) {114 if (localOptima) { 104 115 var fit = new DoubleValue(QAPEvaluator.Apply(perm, qap.Weights, qap.Distances)); 105 116 QAPExhaustiveSwap2LocalImprovement.ImproveFast(perm, qap.Weights, qap.Distances, fit, new IntValue(0), new IntValue(0), qap.Maximization.Value, int.MaxValue, CancellationToken.None); … … 109 120 perm = (Permutation)permutations.Last().Clone(); 110 121 BiasedShuffle(perm, random); 111 if ( LocalOptima) {122 if (localOptima) { 112 123 var fit = new DoubleValue(QAPEvaluator.Apply(perm, qap.Weights, qap.Distances)); 113 124 QAPExhaustiveSwap2LocalImprovement.ImproveFast(perm, qap.Weights, qap.Distances, fit, new IntValue(0), new IntValue(0), qap.Maximization.Value, int.MaxValue, CancellationToken.None); … … 117 128 } 118 129 119 var trajectories = Run(random, (QuadraticAssignmentProblem)Problem, permutations, BestImprovement).ToList(); 120 var result = PermutationPathAnalysis.GetCharacteristics(trajectories); 121 122 foreach (var chara in characteristics.CheckedItems.Select(x => x.Value.Value)) { 123 if (chara == "Swap2.Sharpness") yield return new Result("Swap2.Sharpness", new DoubleValue(result.Sharpness)); 124 if (chara == "Swap2.Bumpiness") yield return new Result("Swap2.Bumpiness", new DoubleValue(result.Bumpiness)); 125 if (chara == "Swap2.Flatness") yield return new Result("Swap2.Flatness", new DoubleValue(result.Flatness)); 126 } 130 return permutations; 127 131 } 128 132
Note: See TracChangeset
for help on using the changeset viewer.