Changeset 15341 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Evaluator/PushBenchmarkSuiteEvaluator.cs
- Timestamp:
- 08/28/17 09:03:34 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Evaluator/PushBenchmarkSuiteEvaluator.cs
r15334 r15341 156 156 157 157 // float error 158 case ProblemType.VectorAverage: return GetDiff(example.OutputFloat, interpreter.FloatStack, Data.WorstResult, (a, b) => FloatDiffer(a, b, example.OutputFloatPrecision ));158 case ProblemType.VectorAverage: return GetDiff(example.OutputFloat, interpreter.FloatStack, Data.WorstResult, (a, b) => FloatDiffer(a, b, example.OutputFloatPrecision, Data.WorstResult)); 159 159 160 160 // integer error … … 184 184 private double Default(IPushInterpreter interpreter, Example example) { 185 185 var integerDiff = GetDiff(example.OutputInteger, interpreter.IntegerStack, Data.WorstResult, IntegerDiffer); 186 var floatDiff = GetDiff(example.OutputFloat, interpreter.FloatStack, Data.WorstResult, (a, b) => FloatDiffer(a, b, example.OutputFloatPrecision ));186 var floatDiff = GetDiff(example.OutputFloat, interpreter.FloatStack, Data.WorstResult, (a, b) => FloatDiffer(a, b, example.OutputFloatPrecision, Data.WorstResult)); 187 187 var booleanDiff = GetDiff(example.OutputBoolean, interpreter.BooleanStack, Data.WorstResult, BooleanDiffer); 188 188 var stringDiff = GetDiff(example.OutputString, interpreter.StringStack, Data.WorstResult, StringDiffer); … … 190 190 var printDiff = GetPrintDiffer(example.OutputPrint, interpreter.PrintStack, Data.WorstResult); 191 191 var integerVectorDiff = GetVectorDiff(example.OutputIntegerVector, interpreter.IntegerVectorStack, Data.WorstResult, (a, b) => VectorDiffer(a, b, IntegerDiffer)); 192 var floatVectorDiff = GetVectorDiff(example.OutputFloatVector, interpreter.FloatVectorStack, Data.WorstResult, (a, b) => VectorDiffer(a, b, (x, y) => FloatDiffer(x, y, example.OutputFloatVectorPrecision )));192 var floatVectorDiff = GetVectorDiff(example.OutputFloatVector, interpreter.FloatVectorStack, Data.WorstResult, (a, b) => VectorDiffer(a, b, (x, y) => FloatDiffer(x, y, example.OutputFloatVectorPrecision, Data.WorstResult))); 193 193 var stringVectorDiff = GetVectorDiff(example.OutputStringVector, interpreter.StringVectorStack, Data.WorstResult, (a, b) => VectorDiffer(a, b, StringDiffer)); 194 194 … … 315 315 return Data.WorstResult; 316 316 317 var floatDiff = GetDiff(example.OutputFloat, interpreter.FloatStack, Data.WorstResult, (a, b) => FloatDiffer(a, b, example.OutputFloatPrecision ));317 var floatDiff = GetDiff(example.OutputFloat, interpreter.FloatStack, Data.WorstResult, (a, b) => FloatDiffer(a, b, example.OutputFloatPrecision, Data.WorstResult)); 318 318 var expectedStr = example.OutputFloat[0].ToString(Data.FloatStringFormat, CultureInfo.CurrentCulture); 319 319 var resultStr = interpreter.FloatStack.TopOrDefault.ToString(Data.FloatStringFormat, CultureInfo.CurrentCulture); … … 480 480 } 481 481 482 private static double FloatDiffer(double a, double b, int digits ) {482 private static double FloatDiffer(double a, double b, int digits, double worst) { 483 483 var result = Math.Round(a, digits) - Math.Round(b, digits); 484 484 485 485 // ReSharper disable once CompareOfFloatsByEqualityOperator 486 if (result == double.MinValue || double.IsPositiveInfinity(result) || double.IsNaN(result)) 487 return double.MaxValue; 488 489 // ReSharper disable once CompareOfFloatsByEqualityOperator 490 if (result == double.MaxValue || double.IsNegativeInfinity(result)) 491 return double.MinValue; 486 if (result == double.MinValue || double.IsPositiveInfinity(result) || 487 double.IsNaN(result) || 488 result == double.MaxValue || double.IsNegativeInfinity(result)) 489 return worst; 492 490 493 491 return Math.Abs(result); … … 545 543 where T : IComparable { 546 544 if (estimated.Count == 0) return 0d; 545 if (resultStack.IsEmpty && estimated.Count > 0) return worstResult; 547 546 548 547 var diff = 0d; … … 551 550 if (!resultStack.IsEmpty) { 552 551 553 for (var i = 0; i < comparableLength ; i++) {554 diff += Math.Min(differ(estimated[i], resultStack[i]), worstResult);552 for (var i = 0; i < comparableLength && diff < worstResult; i++) { 553 diff += differ(estimated[i], resultStack[i]); 555 554 } 556 555 } 557 556 558 557 var emptyTArray = new T[0]; 559 for (var i = comparableLength; i < estimated.Count - comparableLength ; i++) {558 for (var i = comparableLength; i < estimated.Count - comparableLength && diff < worstResult; i++) { 560 559 diff += differ(estimated[i], emptyTArray); 561 560 } … … 567 566 where T : IComparable { 568 567 if (estimated.Count == 0) return 0d; 568 if (resultStack.IsEmpty && estimated.Count > 0) return worstResult; 569 569 570 570 var diff = 0d; … … 572 572 573 573 if (!resultStack.IsEmpty) { 574 for (var i = 0; i < comparableLength ; i++) {575 diff += Math.Min(differ(estimated[i], resultStack[i]), worstResult);574 for (var i = 0; i < comparableLength && diff < worstResult; i++) { 575 diff += differ(estimated[i], resultStack[i]); 576 576 } 577 577 } 578 578 579 for (var i = comparableLength; i < estimated.Count - comparableLength ; i++) {579 for (var i = comparableLength; i < estimated.Count - comparableLength && diff < worstResult; i++) { 580 580 diff += differ(estimated[i], default(T)); 581 581 }
Note: See TracChangeset
for help on using the changeset viewer.