- Timestamp:
- 09/06/12 14:13:36 (12 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization (trunk integration)/HeuristicLab.Problems.MetaOptimization/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization (trunk integration)/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/AlgorithmRunsAnalyzer.cs
r8576 r8589 182 182 run.Name = string.Format("{0} Problem {1} Run {2}", parameterConfiguration.ParameterInfoString, problemIndex, repetitionIndex); 183 183 184 qualities[problemIndex][repetitionIndex] = GetResultValue<DoubleValue>(run.Results, qualityMeasureName).Value; 185 executionTimes[problemIndex][repetitionIndex] = (((TimeSpanValue)run.Results["Execution Time"]).Value); 186 if (run.Results.ContainsKey("EvaluatedSolutions")) { 187 evaluatedSolutions[problemIndex][repetitionIndex] = (((IntValue)run.Results["EvaluatedSolutions"]).Value); 188 } else { 189 evaluatedSolutions[problemIndex][repetitionIndex] = 1; 190 } 184 DoubleValue quality; 185 if (TryGetResultValue(run.Results, qualityMeasureName, out quality)) 186 qualities[problemIndex][repetitionIndex] = quality.Value; 187 188 TimeSpanValue execTime; 189 if (TryGetResultValue(run.Results, "Execution Time", out execTime)) 190 executionTimes[problemIndex][repetitionIndex] = execTime.Value; 191 192 IntValue evalSolutions; 193 if (TryGetResultValue(run.Results, "EvaluatedSolutions", out evalSolutions)) 194 evaluatedSolutions[problemIndex][repetitionIndex] = evalSolutions.Value; 195 191 196 runs.Add(run); 192 197 } … … 236 241 237 242 // in OSGA there are more subscopes, so be careful which to delete 238 CurrentScope.SubScopes.RemoveAll(x => x.Variables.Count( (v)=> (v.Name == "RepetitionCount")) == 1);243 CurrentScope.SubScopes.RemoveAll(x => x.Variables.Count(v => (v.Name == "RepetitionCount")) == 1); 239 244 240 245 return base.Apply(); 241 246 } 242 247 243 private T1 GetResultValue<T1>(IDictionary<string, IItem> results, string resultName) { 244 return (T1)results[resultName]; 245 246 //string separator = "."; 247 //string[] tokens = resultName.Split(separator.ToCharArray()); 248 249 //IDictionary<string, IItem> currentResults = results; 250 //IItem currentResult = null; 251 //for (int i = 0; i < tokens.Length; i++) { 252 // if(currentResults == null) 253 // throw new KeyNotFoundException("Result value " + resultName + " was not found"); 254 // if (currentResults.ContainsKey(tokens[i])) { 255 // currentResult = currentResults[tokens[i]]; 256 // currentResults = currentResult as IDictionary<string, IItem>; 257 // } else { 258 // throw new KeyNotFoundException("Result value " + resultName + " was not found"); 259 // } 260 //} 261 //return (T1)currentResult; 248 private bool TryGetResultValue<T>(IDictionary<string, IItem> results, string resultName, out T resultValue) { 249 IDictionary<string, IItem> currentResults = results; 250 string[] tokens = resultName.Split('.'); 251 T currentResultValue = default(T); 252 bool found = true; 253 254 foreach (var token in tokens) { 255 if (currentResults != null && currentResults.ContainsKey(token)) { 256 currentResultValue = (T)currentResults[token]; 257 currentResults = currentResultValue as IDictionary<string, IItem>; 258 } else { 259 found = false; 260 break; 261 } 262 } 263 264 resultValue = found ? currentResultValue : default(T); 265 return found; 262 266 } 263 267 -
branches/HeuristicLab.MetaOptimization (trunk integration)/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationUtil.cs
r8576 r8589 74 74 qualityDeviationsNormalized[i] = parameterConfigurationTree.QualityStandardDeviations[i] / referenceQualityDeviations[i]; 75 75 evaluatedSolutionAveragesNormalized[i] = parameterConfigurationTree.AverageEvaluatedSolutions[i] / referenceEvaluatedSolutionAverages[i]; 76 if (double.IsNaN(evaluatedSolutionAveragesNormalized[i])) evaluatedSolutionAveragesNormalized[i] = 0.0; 76 77 } 77 78 parameterConfigurationTree.NormalizedQualityAverages = new DoubleArray(qualityAveragesNormalized);
Note: See TracChangeset
for help on using the changeset viewer.