Changeset 14690 for branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/ProblemCharacteristicAnalysis
- Timestamp:
- 02/20/17 20:41:33 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/ProblemCharacteristicAnalysis/QAP/QAPDirectedWalk.cs
r14678 r14690 32 32 using System.Collections.Generic; 33 33 using System.Linq; 34 using System.Threading; 34 35 35 36 namespace HeuristicLab.Analysis.FitnessLandscape { … … 50 51 } 51 52 53 public IFixedValueParameter<BoolValue> LocalOptimaParameter { 54 get { return (IFixedValueParameter<BoolValue>)Parameters["LocalOptima"]; } 55 } 56 52 57 public int Paths { 53 58 get { return PathsParameter.Value.Value; } … … 63 68 get { return SeedParameter.Value != null ? SeedParameter.Value.Value : (int?)null; } 64 69 set { SeedParameter.Value = value.HasValue ? new IntValue(value.Value) : null; } 70 } 71 72 public bool LocalOptima { 73 get { return LocalOptimaParameter.Value.Value; } 74 set { LocalOptimaParameter.Value.Value = value; } 65 75 } 66 76 … … 74 84 Parameters.Add(new FixedValueParameter<BoolValue>("BestImprovement", "Whether the best of all alternatives should be chosen for each step in the path or just the first improving (least degrading) move should be made.", new BoolValue(true))); 75 85 Parameters.Add(new OptionalValueParameter<IntValue>("Seed", "The seed for the random number generator.")); 86 Parameters.Add(new FixedValueParameter<BoolValue>("LocalOptima", "Whether to perform walks between local optima.", new BoolValue(false))); 76 87 } 77 88 … … 90 101 91 102 var perm = new Permutation(PermutationTypes.Absolute, qap.Weights.Rows, random); 103 if (LocalOptima) { 104 var fit = new DoubleValue(QAPEvaluator.Apply(perm, qap.Weights, qap.Distances)); 105 QAPExhaustiveSwap2LocalImprovement.ImproveFast(perm, qap.Weights, qap.Distances, fit, new IntValue(0), new IntValue(0), qap.Maximization.Value, int.MaxValue, CancellationToken.None); 106 } 92 107 var permutations = new List<Permutation> { perm }; 93 108 while (permutations.Count < pathCount + 1) { 94 109 perm = (Permutation)permutations.Last().Clone(); 95 110 BiasedShuffle(perm, random); 96 permutations.Add(perm); 111 if (LocalOptima) { 112 var fit = new DoubleValue(QAPEvaluator.Apply(perm, qap.Weights, qap.Distances)); 113 QAPExhaustiveSwap2LocalImprovement.ImproveFast(perm, qap.Weights, qap.Distances, fit, new IntValue(0), new IntValue(0), qap.Maximization.Value, int.MaxValue, CancellationToken.None); 114 } 115 if (HammingSimilarityCalculator.CalculateSimilarity(permutations.Last(), perm) < 0.75) 116 permutations.Add(perm); 97 117 } 98 118 … … 151 171 152 172 for (var p = 0; p < f2.Count; p++) { 173 if (f2[p].Count <= 2) continue; 153 174 var bump = 0; 154 175 var flat = 0; … … 266 287 } 267 288 289 // Center-of-Mass 268 290 private static double ComBelowZero(IEnumerable<Tuple<Permutation, double>> path) { 269 291 var area = 0.0;
Note: See TracChangeset
for help on using the changeset viewer.