Changeset 11812
- Timestamp:
- 01/21/15 11:23:56 (10 years ago)
- Location:
- branches/ProgrammableProblem/HeuristicLab.Optimization/3.3
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs
r11171 r11812 227 227 public virtual void CollectResultValues(IDictionary<string, IItem> values) { 228 228 values.Add("Execution Time", new TimeSpanValue(ExecutionTime)); 229 CollectResultsRecursively("", Results, values); 230 } 231 232 private void CollectResultsRecursively(string path, ResultCollection results, IDictionary<string, IItem> values) { 233 foreach (IResult result in results) { 234 values.Add(path + result.Name, result.Value); 235 ResultCollection childCollection = result.Value as ResultCollection; 236 if (childCollection != null) { 237 CollectResultsRecursively(path + result.Name + ".", childCollection, values); 238 } 239 } 229 Results.CollectResultValues(values); 240 230 } 241 231 -
branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r11645 r11812 152 152 </ItemGroup> 153 153 <ItemGroup> 154 <Compile Include="Algorithms\BasicAlgorithm.cs" /> 154 155 <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" /> 155 156 <Compile Include="Interfaces\ISingleObjectivePathRelinker.cs" /> -
branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/ResultCollection.cs
r11171 r11812 44 44 get { return HeuristicLab.Common.Resources.VSImageLibrary.Object; } 45 45 } 46 47 public virtual void CollectResultValues(IDictionary<string, IItem> values) { 48 CollectResultValues(values, string.Empty); 49 } 50 51 public virtual void CollectResultValues(IDictionary<string, IItem> values, string rootPath) { 52 foreach (IResult result in this) { 53 var children = GetCollectedResults(result); 54 string path = string.Empty; 55 if (!string.IsNullOrWhiteSpace(rootPath)) 56 path = rootPath + "."; 57 foreach (var c in children) { 58 if (string.IsNullOrEmpty(c.Key)) 59 values.Add(path + result.Name, c.Value); 60 else values.Add(path + result.Name + "." + c.Key, c.Value); 61 } 62 } 63 } 64 65 protected virtual IEnumerable<KeyValuePair<string, IItem>> GetCollectedResults(IResult result) { 66 if (result.Value == null) yield break; 67 yield return new KeyValuePair<string, IItem>(string.Empty, result.Value); 68 69 var resultCollection = result.Value as ResultCollection; 70 if (resultCollection != null) { 71 var children = new Dictionary<string, IItem>(); 72 resultCollection.CollectResultValues(children); 73 foreach (var child in children) yield return child; 74 } 75 } 76 46 77 } 47 78 }
Note: See TracChangeset
for help on using the changeset viewer.