Changeset 8237 for branches/HeuristicLab.Analysis.AlgorithmBehavior
- Timestamp:
- 07/05/12 16:21:23 (12 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/AlgorithmBehaviorHelpers.cs
r8229 r8237 63 63 if (filteredDescendants.Any()) { 64 64 foreach (var descendant in filteredDescendants) { 65 generations.Add((int)descendant.Rank); 65 foreach (var rank in descendant.Rank) { 66 generations.Add((int)rank); 67 } 66 68 } 67 69 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/BestIndividualQualityAnalyzer.cs
r8234 r8237 129 129 SchemaEqualityComparer comparer = new SchemaEqualityComparer(); 130 130 131 var lastGen = graph.Values.Where(x => x.Rank == GenerationsParameter.ActualValue.Value);131 var lastGen = graph.Values.Where(x => x.Rank.Contains(GenerationsParameter.ActualValue.Value)); 132 132 var parents = lastGen.Where(x => comparer.Equals((IntArray)x.Data, parent)); 133 133 var ancestors = parents.First().Ancestors().Where(x => AlgorithmBehaviorHelpers.IsSubtour(schema, (Permutation)x.Data)); 134 134 135 135 StringBuilder sb = new StringBuilder(); 136 double curGen = GenerationsParameter.ActualValue.Value; 136 137 foreach (var a in ancestors) { 137 sb.Append(a.Rank + ", "); 138 if (a.Rank.Contains(curGen)) 139 sb.Append(curGen + ", "); 140 else { 141 for (int i = 0; i < GenerationsParameter.ActualValue.Value; i++) { 142 if (a.Rank.Contains(curGen - i)) { 143 curGen = curGen - i; 144 break; 145 } else if (a.Rank.Contains(curGen - i + 0.5)) { 146 curGen = curGen - i + 0.5; 147 break; 148 } 149 } 150 sb.Append(curGen + ", "); 151 } 138 152 } 139 153 return sb.ToString(); -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/BrokenInheritanceWildcardAnalyzer.cs
r8227 r8237 77 77 var graph = (GenealogyGraph<Permutation>)Results[PopulationGraphResultName].Value; 78 78 var wildcards = (ItemArray<IntArray>)Results[WildcardsResultName].Value; 79 var generationZero = graph.Values.Where(x => x.Rank == 0);79 var generationZero = graph.Values.Where(x => x.Rank.Contains(0)); 80 80 81 81 var buildingBlockMatrix = new StringMatrix(wildcards.Count(), generationZero.Count()); -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/BrokenInteritanceSchemaAnalyzer.cs
r8227 r8237 77 77 var graph = (GenealogyGraph<Permutation>)Results[PopulationGraphResultName].Value; 78 78 var schemata = (ItemArray<IntArray>)Results[SchemataResultName].Value; 79 var generationZero = graph.Values.Where(x => x.Rank == 0);79 var generationZero = graph.Values.Where(x => x.Rank.Contains(0)); 80 80 81 81 var brokenInteritanceSchemaOccurrenceMatrix = new StringMatrix(schemata.Count(), generationZero.Count()); -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/GenealogyAnalyzer.cs
r8216 r8237 32 32 33 33 namespace HeuristicLab.Analysis.AlgorithmBehavior { 34 using System.Collections.Generic; 34 35 using CloneMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItem>; 35 36 using TraceMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItemList<HeuristicLab.Core.IItem>>; … … 182 183 for (int i = 0; i < population.Count; i++) { 183 184 var solutionEntry = population.ElementAt(i); 184 var node = new GenealogyGraphNode(solutionEntry.Key) { Quality = solutionEntry.Value, Label = label, Rank = generation, IsElite = i < Elites.Value }; 185 var rank = new List<double>(); 186 rank.Add(generation); 187 var node = new GenealogyGraphNode(solutionEntry.Key) { Quality = solutionEntry.Value, Label = label, Rank = rank, IsElite = i < Elites.Value }; 185 188 graph.AddNode(node); 186 189 } … … 192 195 var solutionEntry = population.ElementAt(i); 193 196 if (!graph.HasNode(solutionEntry.Key)) { 194 var node = new GenealogyGraphNode(solutionEntry.Key) { Quality = solutionEntry.Value, Label = label, Rank = generation, IsElite = i < Elites.Value }; 197 var rank = new List<double>(); 198 rank.Add(generation); 199 var node = new GenealogyGraphNode(solutionEntry.Key) { Quality = solutionEntry.Value, Label = label, Rank = rank, IsElite = i < Elites.Value }; 195 200 graph.AddNode(node); 196 201 } … … 204 209 // handle mutation 205 210 double quality = Evaluate(parent); 206 var node = new GenealogyGraphNode(parent) { Quality = quality, Label = label, Rank = generation - 0.5 }; 211 var rank = new List<double>(); 212 rank.Add(generation - 0.5); 213 var node = new GenealogyGraphNode(parent) { Quality = quality, Label = label, Rank = rank }; 207 214 graph.AddNode(node); 208 215 var parentParents = GlobalTraceMap[parent].Cast<Permutation>().ToArray(); -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/SchemaOccurenceInGenerationsAnalyzer.cs
r8227 r8237 126 126 foreach (var individual in graph.Values) { 127 127 if (AlgorithmBehaviorHelpers.IsSubtour(schema, (Permutation)individual.Data)) { 128 occurences[(int)individual.Rank]++; 128 foreach (var rank in individual.Rank) { 129 occurences[(int)rank]++; 130 } 129 131 } 130 132 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/SchemaQualityAnalyzer.cs
r8227 r8237 136 136 foreach (var individual in graph.Values) { 137 137 if (AlgorithmBehaviorHelpers.IsSubtour(schema, (Permutation)individual.Data)) { 138 occurences[(int)individual.Rank]++; 138 foreach (var rank in individual.Rank) { 139 occurences[(int)rank]++; 140 } 139 141 } 140 142 } … … 166 168 double pQuality = TSPDistanceMatrixEvaluator.Apply(DistanceMatrix, p); 167 169 168 if (Qualities.Rows["CurrentAverageQuality"].Values[(int)individual.Rank] > pQuality) { 170 //TODO: fix that 171 /*if (Qualities.Rows["CurrentAverageQuality"].Values[(int)individual.Rank] > pQuality) { 169 172 qualityPoint += 1; 170 173 } else { 171 174 worstQualityPoint += 1; 172 } 175 } */ 173 176 } 174 177 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Creators/SchemataCreator.cs
r8229 r8237 85 85 public override IOperation Apply() { 86 86 var graph = (GenealogyGraph<Permutation>)Results[PopulationGraphResultParameterName].Value; 87 var generationZero = graph.Values.Where(x => x.Rank == 0);87 var generationZero = graph.Values.Where(x => x.Rank.Contains(0)); 88 88 89 89 // extract all subtours for each individual in generation zero -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/GenealogyGraph.cs
r8234 r8237 73 73 public void AddNode(T t) { 74 74 if (HasNode(t)) return; 75 _nodes[t] = new GenealogyGraphNode(t) { Quality = 0.0, Label = "", IsElite = false, Rank = 0.0};75 _nodes[t] = new GenealogyGraphNode(t) { Quality = 0.0, Label = "", IsElite = false, Rank = new List<double>() }; 76 76 } 77 77 … … 166 166 public bool IsElite { get; set; } 167 167 public double Quality { get; set; } 168 public doubleRank { get; set; }168 public List<double> Rank { get; set; } 169 169 public List<GenealogyGraphArc> InEdges { get; set; } 170 170 public List<GenealogyGraphArc> OutEdges { get; set; } … … 193 193 public GenealogyGraphNode(GenealogyGraphNode node) { 194 194 Id = Guid.NewGuid().ToString(); 195 Rank = n ode.Rank;195 Rank = new List<double>(node.Rank); 196 196 Quality = node.Quality; 197 197 IsElite = node.IsElite;
Note: See TracChangeset
for help on using the changeset viewer.