Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/21/17 11:33:53 (7 years ago)
Author:
pkimmesw
Message:

#2665 Testet Problems, Testet error functions, Small fixes, Created HL files

Location:
branches/PushGP/HeuristicLab.PushGP
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP

    • Property svn:ignore
      •  

        old new  
        11*.user
         2packages
         3TestResults
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Checksum.cs

    r15189 r15334  
    1919        Name = Name,
    2020        Description = Description,
     21        ProgramExecutionBudget = 30000000,
    2122        Examples = CloneExamples(),
    2223        BestResult = 0,
    23         WorstResult = char.MaxValue,
     24        WorstResult = 1000,
    2425        InputArgumentTypes = new[] { ExampleArgumentType.String },
    2526        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/CollatzNumbers.cs

    r15017 r15334  
    1717        Name = Name,
    1818        Description = Description,
     19        ProgramExecutionBudget = 60000000,
    1920        Examples = CloneExamples(),
    2021        BestResult = 0,
    21         WorstResult = 300,
     22        WorstResult = 1000000,
    2223        InputArgumentTypes = new[] { ExampleArgumentType.Integer },
    2324        OutputArgumentTypes = new[] { ExampleArgumentType.Integer },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/CompareStringLengths.cs

    r15017 r15334  
    1717        Name = Name,
    1818        Description = Description,
     19        ProgramExecutionBudget = 30000000,
    1920        Examples = CloneExamples(),
    2021        BestResult = 0,
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/CountOdds.cs

    r15017 r15334  
    1717        Name = Name,
    1818        Description = Description,
     19        ProgramExecutionBudget = 60000000,
    1920        Examples = CloneExamples(),
    2021        BestResult = 0,
    21         WorstResult = 50,
     22        WorstResult = 1000,
    2223        InputArgumentTypes = new[] { ExampleArgumentType.IntegerVector },
    2324        OutputArgumentTypes = new[] { ExampleArgumentType.Integer },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Digits.cs

    r15017 r15334  
    1818        Name = Name,
    1919        Description = Description,
     20        ProgramExecutionBudget = 30000000,
    2021        Examples = CloneExamples(),
    2122        BestResult = 0,
    22         WorstResult = 20,
     23        WorstResult = 5000,
    2324        InputArgumentTypes = new[] { ExampleArgumentType.Integer },
    2425        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/DoubleLetters.cs

    r15017 r15334  
    1818        Name = Name,
    1919        Description = Description,
     20        ProgramExecutionBudget = 30000000,
    2021        Examples = CloneExamples(),
    2122        BestResult = 0,
    22         WorstResult = 100,
     23        WorstResult = 5000,
    2324        InputArgumentTypes = new[] { ExampleArgumentType.String },
    2425        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/EvenSquares.cs

    r15017 r15334  
    11namespace HeuristicLab.BenchmarkSuite.Problems {
     2  using System.Linq;
     3
    24  public class EvenSquares : BenchmarkSuiteDataDescriptor {
    35    private const string name = "Even Sqaures - Hard";
     
    1517        Name = Name,
    1618        Description = Description,
     19        ProgramExecutionBudget = 30000000,
    1720        Examples = CloneExamples(),
    1821        BestResult = 0,
    19         WorstResult = 400,
     22        WorstResult = 5000,
    2023        InputArgumentTypes = new[] { ExampleArgumentType.Integer },
    2124        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
     
    3437        InputInteger = ExampleArgumentConverter.ConvertIntegers(input),
    3538        OutputPrint = output[0],
     39
     40        // helper
     41        OutputIntegerVector = new [] { output[0].Split('\n').Select(ExampleArgumentConverter.ConvertInteger).ToArray() }
    3642      };
    3743    }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/ForLoopIndex.cs

    r15017 r15334  
    1919        Name = Name,
    2020        Description = Description,
     21        ProgramExecutionBudget = 30000000,
    2122        Examples = CloneExamples(),
    2223        BestResult = 0,
    23         WorstResult = 1000,
     24        WorstResult = 5000,
    2425        InputArgumentTypes = new[] { ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer },
    2526        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Grades.cs

    r15017 r15334  
    11namespace HeuristicLab.BenchmarkSuite.Problems {
     2  using System;
     3
    24  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Integer;
    35  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.String;
     
    68    private const string name = "Grades - Hard";
    79    private const string fileName = "Grades.csv";
    8     private const string description = "Given 5 integers, the first four represent the lower numeric thresholds for achieving an A, B, C, and D, and will be distinct and in descending order.The fifth represents the student’s numeric grade.The program must print Student has a X grade., where X is A, B, C, D, or F depending on the thresholds and the numeric grade.";
     10    private const string description = "Given 5 integers, the first four represent the lower numeric thresholds for achieving an A, B, C, and D, and will be distinct and in descending order. The fifth represents the student’s numeric grade. The program must print Student has a X grade., where X is A, B, C, D, or F depending on the thresholds and the numeric grade.";
    911
    1012    protected override string FileName { get { return fileName; } }
     
    1820        Name = Name,
    1921        Description = Description,
     22        ProgramExecutionBudget = 60000000,
    2023        Examples = CloneExamples(),
    2124        BestResult = 0,
    22         WorstResult = 25,
     25        WorstResult = 5000,
    2326        InputArgumentTypes = new[] { ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer },
    2427        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
     
    3942
    4043    protected override Example ParseExample(string[] input, string[] output) {
     44      char grade;
     45      if (!GetGrade(output[0], out grade))
     46        throw new InvalidOperationException("Unable to parse grade.");
     47
    4148      return new Example {
    4249        InputArgs = input,
     
    4451        InputInteger = ExampleArgumentConverter.ConvertIntegers(input),
    4552        OutputPrint = output[0],
     53
     54        // help
     55        OutputChar = new[] { grade }
    4656      };
     57    }
     58
     59    public static bool GetGrade(string str, out char grade) {
     60      const string start = "Student has a ";
     61
     62      if (str.StartsWith(start) && str.Length > start.Length) {
     63        grade = str[start.Length];
     64        return true;
     65      }
     66
     67      grade = default(char);
     68      return false;
    4769    }
    4870  }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/LastIndexOfZero.cs

    r15017 r15334  
    1717        Name = Name,
    1818        Description = Description,
     19        ProgramExecutionBudget = 45000000,
    1920        Examples = CloneExamples(),
    2021        BestResult = 0,
    21         WorstResult = 50,
     22        WorstResult = 1000000,
    2223        InputArgumentTypes = new[] { ExampleArgumentType.IntegerVector },
    2324        OutputArgumentTypes = new[] { ExampleArgumentType.Integer },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Median.cs

    r15017 r15334  
    1717        Name = Name,
    1818        Description = Description,
     19        ProgramExecutionBudget = 20000000,
    1920        Examples = CloneExamples(),
    2021        BestResult = 0,
    21         WorstResult = 100,
     22        WorstResult = 1,
    2223        InputArgumentTypes = new[] { ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer },
    2324        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/MirrorImage.cs

    r15017 r15334  
    1717        Name = Name,
    1818        Description = Description,
     19        ProgramExecutionBudget = 30000000,
    1920        Examples = CloneExamples(),
    2021        BestResult = 0,
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/NegativeToZero.cs

    r15017 r15334  
    1818        Name = Name,
    1919        Description = Description,
     20        ProgramExecutionBudget = 60000000,
    2021        Examples = CloneExamples(),
    2122        BestResult = 0,
    22         WorstResult = 50000,
     23        WorstResult = 5000,
    2324        InputArgumentTypes = new[] { ExampleArgumentType.IntegerVector },
    2425        OutputArgumentTypes = new[] { ExampleArgumentType.IntegerVector },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/NumberIo.cs

    r15189 r15334  
    2020        Name = Name,
    2121        Description = Description,
     22        ProgramExecutionBudget = 5000000,
    2223        Examples = CloneExamples(),
    2324        BestResult = 0,
    24         WorstResult = 400,
     25        WorstResult = 5000,
    2526        InputArgumentTypes = new[] { ExampleArgumentType.Float, ExampleArgumentType.Integer },
    2627        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/PigLatin.cs

    r15017 r15334  
    1919        Name = Name,
    2020        Description = Description,
     21        ProgramExecutionBudget = 60000000,
    2122        Examples = CloneExamples(),
    2223        BestResult = 0,
    23         WorstResult = 100,
     24        WorstResult = 5000,
    2425        InputArgumentTypes = new[] { ExampleArgumentType.String },
    2526        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/ReplaceSpaceWithNewline.cs

    r15017 r15334  
    1919        Name = Name,
    2020        Description = Description,
     21        ProgramExecutionBudget = 30000000,
    2122        Examples = CloneExamples(),
    2223        BestResult = 0,
    23         WorstResult = 20,
     24        WorstResult = 5000,
    2425        InputArgumentTypes = new[] { ExampleArgumentType.String },
    2526        OutputArgumentTypes = new[] { ExampleArgumentType.Print, ExampleArgumentType.Integer },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/ScrabbleScore.cs

    r15017 r15334  
    4848        Name = Name,
    4949        Description = Description,
     50        ProgramExecutionBudget = 60000000,
    5051        Examples = CloneExamples(),
    5152        BestResult = 0,
    52         WorstResult = 500,
     53        WorstResult = 1000,
    5354        InputArgumentTypes = new[] { ExampleArgumentType.String },
    5455        OutputArgumentTypes = new[] { ExampleArgumentType.Integer },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/SmallOrLarge.cs

    r15017 r15334  
    1919        Name = Name,
    2020        Description = Description,
     21        ProgramExecutionBudget = 30000000,
    2122        Examples = CloneExamples(),
    2223        BestResult = 0,
    23         WorstResult = 5,
     24        WorstResult = 5000,
    2425        InputArgumentTypes = new[] { ExampleArgumentType.Integer },
    2526        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Smallest.cs

    r15017 r15334  
    1717        Name = Name,
    1818        Description = Description,
     19        ProgramExecutionBudget = 20000000,
    1920        Examples = CloneExamples(),
    2021        BestResult = 0,
    21         WorstResult = 100,
     22        WorstResult = 1,
    2223        InputArgumentTypes = new[] { ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer, ExampleArgumentType.Integer },
    23         OutputArgumentTypes = new[] { ExampleArgumentType.Integer },
     24        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
    2425        TrainingCount = 100,
    2526        TestCount = 1000,
    26         EnabledDataTypes = DataTypes.Exec | DataTypes.Integer | DataTypes.Boolean,
     27        EnabledDataTypes = DataTypes.Exec | DataTypes.Integer | DataTypes.Boolean | DataTypes.Print,
    2728        MaxSize = 200,
    2829        EvalLimit = 200,
     
    4041        OutputArgs = output,
    4142        InputInteger = ExampleArgumentConverter.ConvertIntegers(input),
     43        OutputPrint = output[0],
     44        // Helper
    4245        OutputInteger = ExampleArgumentConverter.ConvertIntegers(output[0]),
    4346      };
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/StringDifferences.cs

    r15017 r15334  
    66    private const string name = "String Differences - Hard";
    77    private const string fileName = "StringDifferences.csv";
    8     private const string description = "Given 2 strings (without whitespace) as input, find the indices at which the strings have different characters, stopping at the end of the shorter one.For each such index, print a line containing the index as well as the character in each string. For example, if the strings are “dealer” and “dollars”, the program should print: 1 e o, 2 a l, 4 e a";
     8    private const string description = "Given 2 strings (without whitespace) as input, find the indices at which the strings have different characters, stopping at the end of the shorter one. For each such index, print a line containing the index as well as the character in each string. For example, if the strings are “dealer” and “dollars”, the program should print: 1 e o, 2 a l, 4 e a";
    99
    1010    protected override string FileName { get { return fileName; } }
     
    1818        Name = Name,
    1919        Description = Description,
     20        ProgramExecutionBudget = 60000000,
    2021        Examples = CloneExamples(),
    2122        BestResult = 0,
    22         WorstResult = 100,
     23        WorstResult = 5000,
    2324        InputArgumentTypes = new[] { ExampleArgumentType.String, ExampleArgumentType.String },
    2425        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/StringLengthsBackwards.cs

    r15017 r15334  
    1414
    1515    public override ProblemData CreateProblemData() {
    16       return new ProblemData(ProblemType.StringDifferences) {
     16      return new ProblemData(ProblemType.StringLengthsBackwards) {
    1717        Name = Name,
    1818        Description = Description,
     19        ProgramExecutionBudget = 30000000,
    1920        Examples = CloneExamples(),
    2021        BestResult = 0,
    21         WorstResult = 200,
     22        WorstResult = 5000,
    2223        InputArgumentTypes = new[] { ExampleArgumentType.StringVector },
    2324        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/SumOfSquares.cs

    r15017 r15334  
    1717        Name = Name,
    1818        Description = Description,
     19        ProgramExecutionBudget = 15000000,
    1920        Examples = CloneExamples(),
    2021        BestResult = 0,
    21         WorstResult = 338350,
     22        WorstResult = 1000000000, // 338350,
    2223        InputArgumentTypes = new[] { ExampleArgumentType.Integer },
    2324        OutputArgumentTypes = new[] { ExampleArgumentType.Integer },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/SuperAnagrams.cs

    r15017 r15334  
    1919        Name = Name,
    2020        Description = Description,
     21        ProgramExecutionBudget = 60000000,
    2122        Examples = CloneExamples(),
    2223        BestResult = 0,
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/Syllables.cs

    r15017 r15334  
    11namespace HeuristicLab.BenchmarkSuite.Problems {
     2  using System;
     3
    24  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Char;
    35  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Integer;
     
    1921        Name = Name,
    2022        Description = Description,
     23        ProgramExecutionBudget = 30000000,
    2124        Examples = CloneExamples(),
    2225        BestResult = 0,
    23         WorstResult = 100,
     26        WorstResult = 5000,
    2427        InputArgumentTypes = new[] { ExampleArgumentType.String },
    2528        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
     
    5053
    5154    protected override Example ParseExample(string[] input, string[] output) {
     55      long numberOfSyllables;
     56      if (!GetNumberOfSyllables(output[0], out numberOfSyllables))
     57        throw new InvalidOperationException("Unable to parse number of syllables.");
     58
    5259      return new Example {
    5360        InputArgs = input,
     
    5562        InputString = input,
    5663        OutputPrint = output[0],
     64
     65        // help
     66        OutputInteger = new[] { numberOfSyllables }
    5767      };
     68    }
     69
     70    public static bool GetNumberOfSyllables(string str, out long numberOfSyllables) {
     71      if (str.Length == 0) {
     72        numberOfSyllables = 0;
     73        return false;
     74      }
     75
     76      var lastIndex = str.Length - 1;
     77      var lastCharStr = str[lastIndex].ToString();
     78
     79      return long.TryParse(lastCharStr, out numberOfSyllables);
    5880    }
    5981  }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/VectorAverage.cs

    r15017 r15334  
    1515        Name = Name,
    1616        Description = Description,
     17        ProgramExecutionBudget = 30000000,
    1718        Examples = CloneExamples(),
    1819        BestResult = 0,
    19         WorstResult = 1000,
     20        WorstResult = 1000000,
    2021        InputArgumentTypes = new[] { ExampleArgumentType.FloatVector },
    2122        OutputArgumentTypes = new[] { ExampleArgumentType.Float },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/VectorSummed.cs

    r15017 r15334  
    1818        Name = Name,
    1919        Description = Description,
     20        ProgramExecutionBudget = 45000000,
    2021        Examples = CloneExamples(),
    2122        BestResult = 0,
    22         WorstResult = 100000,
     23        WorstResult = 1000000000,
    2324        InputArgumentTypes = new[] { ExampleArgumentType.IntegerVector, ExampleArgumentType.IntegerVector },
    2425        OutputArgumentTypes = new[] { ExampleArgumentType.IntegerVector },
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/WallisPi.cs

    r15017 r15334  
    66    private const string name = "Wallis Pi - Hard";
    77    private const string fileName = "WallisPi.csv";
    8     private const string description = " John Wallis gave a infinite product that converges to π/4. Given an integer input n, compute an approximation of this product out to n terms.Results are rounded to 5 decimal place";
     8    private const string description = " John Wallis gave a infinite product that converges to π/4. Given an integer input n, compute an approximation of this product out to n terms. Results are rounded to 5 decimal places.";
    99
    1010    protected override string FileName { get { return fileName; } }
     
    1818        Name = Name,
    1919        Description = Description,
     20        ProgramExecutionBudget = 45000000,
    2021        Examples = CloneExamples(),
    2122        BestResult = 0,
    22         WorstResult = 1,
     23        WorstResult = 1000000,
    2324        InputArgumentTypes = new[] { ExampleArgumentType.Integer },
    2425        OutputArgumentTypes = new[] { ExampleArgumentType.Float },
     
    2829        MaxSize = 600,
    2930        EvalLimit = 8000,
     31        FloatStringFormat = "N5",
    3032        ErcOptions = {
    3133          ErcProbability = 0.05,
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/WordStats.cs

    r15017 r15334  
    11namespace HeuristicLab.BenchmarkSuite.Problems {
     2  using System;
     3  using System.Linq;
     4
    25  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Char;
    36  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Integer;
     
    2023        Name = Name,
    2124        Description = Description,
     25        ProgramExecutionBudget = 30000000,
    2226        Examples = CloneExamples(),
    2327        BestResult = 0,
    24         WorstResult = 1000,
     28        WorstResult = 10000,
    2529        InputArgumentTypes = new[] { ExampleArgumentType.String },
    2630        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
     
    3034        MaxSize = 1000,
    3135        EvalLimit = 6000,
     36        FloatStringFormat = "0.0#########",
    3237        ErcOptions = {
    33           ErcProbability = 0.05,
     38        ErcProbability = 0.05,
    3439          IntegerErcOptions = new IntegerErcOptions(
    3540            new IntegerRangeErc(-100, 100)),
     
    4550
    4651    protected override Example ParseExample(string[] input, string[] output) {
     52      long numberOfSentences;
     53      if (!GetNumberOfSentences(output[0], out numberOfSentences))
     54        throw new InvalidOperationException("Unable to find or parse line with number of sentences.");
     55
     56      double averageSentenceLength;
     57      if (!GetAverageSentenceLength(output[0], out averageSentenceLength))
     58        throw new InvalidOperationException("Unable to find line or parse with average sentence length.");
     59
    4760      return new Example {
    4861        InputArgs = input,
    4962        OutputArgs = output,
    5063        InputString = input,
    51         OutputPrint = output[0]
     64        OutputPrint = output[0],
     65
     66        // help
     67        OutputInteger = new[] { numberOfSentences },
     68        OutputFloat = new[] { averageSentenceLength }
    5269      };
     70    }
     71
     72    public static bool GetNumberOfSentences(string str, out long numberOfSentences) {
     73      var lines = str.Split('\n');
     74      var requiredLineIndex = lines.Length - 2;
     75      numberOfSentences = 0;
     76
     77      if (requiredLineIndex < 0)
     78        return false;
     79
     80      var line = lines[requiredLineIndex];
     81      var numberOfSentencesStr = line.Split(' ').Last();
     82
     83
     84      if (!long.TryParse(numberOfSentencesStr, out numberOfSentences))
     85        return false;
     86
     87      return true;
     88    }
     89
     90    public static bool GetAverageSentenceLength(string str, out double averageSentenceLength) {
     91      var lines = str.Split('\n');
     92      var requiredLineIndex = lines.Length - 1;
     93      averageSentenceLength = 0;
     94
     95      if (requiredLineIndex < 0)
     96        return false;
     97
     98      var line = lines[requiredLineIndex];
     99      var averageSentenceLengthStr = line.Split(' ').Last();
     100
     101      if (!double.TryParse(averageSentenceLengthStr, out averageSentenceLength))
     102        return false;
     103
     104      return true;
    53105    }
    54106  }
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problem.ProgramSynthesis.BenchmarkSuite/Problems/XWordLines.cs

    r15017 r15334  
    11namespace HeuristicLab.BenchmarkSuite.Problems {
     2  using System.Linq;
     3
    24  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Char;
    35  using HeuristicLab.Problems.ProgramSynthesis.Base.Erc.Integer;
     
    68    private const string name = "X-Word Lines - Hard";
    79    private const string fileName = "XWordLines.csv";
    8     private const string description = "Given an integer X and a string that can contain spaces and newlines, print the string with exactly X words per line.The last line may have fewer than X words.";
     10    private const string description = "Given an integer X and a string that can contains spaces and newlines, print the string with exactly X words per line. The last line may have fewer than X words.";
    911
    1012    protected override string FileName { get { return fileName; } }
     
    1820        Name = Name,
    1921        Description = Description,
     22        ProgramExecutionBudget = 45000000,
    2023        Examples = CloneExamples(),
    2124        BestResult = 0,
    22         WorstResult = 100,
     25        WorstResult = 5000,
    2326        InputArgumentTypes = new[] { ExampleArgumentType.Integer, ExampleArgumentType.String },
    2427        OutputArgumentTypes = new[] { ExampleArgumentType.Print },
     
    4346        InputString = new[] { input[0] },
    4447        OutputPrint = output[0],
     48        // Helper
     49        OutputInteger = new[] { input[0].Split(' ', '\n').LongCount(x => !string.IsNullOrWhiteSpace(x)) }
    4550      };
    4651    }
Note: See TracChangeset for help on using the changeset viewer.