Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/31/17 18:59:39 (7 years ago)
Author:
pkimmesw
Message:

#2665 Fixed Lexicase

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Evaluator/PushBenchmarkSuiteEvaluator.cs

    r15344 r15345  
    149149        case ProblemType.Smallest:
    150150        case ProblemType.Median: return PrintedStringRight(interpreter, example);
     151        case ProblemType.MedianIntegerError: return MedianIntegerError(interpreter, example);
    151152
    152153        // boolean error
     
    214215    }
    215216
     217    private double MedianIntegerError(IPushInterpreter interpreter, Example example) {
     218      var printResult = interpreter.PrintStack.ToString();
     219
     220      long result;
     221      if (long.TryParse(printResult, out result)) {
     222        var diff = Math.Abs(result - example.OutputInteger[0]);
     223
     224        return Math.Min(Data.WorstResult, diff);
     225      }
     226
     227      return Data.WorstResult;
     228    }
     229
    216230    private double NumberIo(IPushInterpreter interpreter, Example example) {
    217231      if (!string.IsNullOrEmpty(example.OutputPrint) && interpreter.PrintStack.IsEmpty)
     
    289303      var printLines = interpreter.PrintStack.AsStrings().ToArray();
    290304      var lineCountWithCorrectFormat = printLines.Count(line => line.IsNumeric());
    291       var lineCountWithInvalidFormat = example.OutputPrintLineCount - lineCountWithCorrectFormat;
     305      var lineCountWithInvalidFormat = Math.Max(0, example.OutputPrintLineCount - lineCountWithCorrectFormat);
    292306
    293307      lineCountWithInvalidFormat = Math.Abs(Math.Min(lineCountWithInvalidFormat, example.OutputPrintLineCount));
Note: See TracChangeset for help on using the changeset viewer.