Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GPDL/HeuristicLab.Grammars/3.3/Test.cs @ 12230

Last change on this file since 12230 was 10063, checked in by gkronber, 11 years ago

#2026 removed reference to HeuristicLab.PluginInfrastructure (and set svn:ignore properties)

File size: 2.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Diagnostics;
24using System.Linq;
25
26namespace HeuristicLab.Grammars {
27  public class Test {
28    public static void Main(string[] args) {
29      var gStr =
30        @"S -> a B | b A
31          A-> a | a S | b A A
32          B -> b | b S | a B B
33         ";
34      var g = HeuristicLab.Grammars.Grammar.FromString(gStr);
35      var l = new Language(g);
36      var s2 = new string[][]
37        {
38          new string[] {"a", "b"},
39          new string[] {"b", "a"}
40        };
41      var s4 = new string[][]
42        {
43          new string[] {"a", "a", "b", "b"},
44          new string[] {"a", "b", "a", "b"},
45          new string[] {"a", "b", "b", "a"},
46          new string[] {"b", "b", "a", "a"},
47          new string[] {"b", "a", "b", "a"},
48          new string[] {"b", "a", "a", "b"}
49        };
50
51      var watch = new Stopwatch();
52      watch.Start();
53      var lPrime = l.Take(100000);
54      int s = 0;
55      foreach (var c in lPrime) {
56        s++;
57        /*
58        foreach (var symb in c)
59          Console.Write(symb);
60        Console.WriteLine();
61        */
62      }
63      watch.Stop();
64      Console.WriteLine(s);
65      Console.WriteLine("Generating 10000 sentences: {0}ms", watch.ElapsedMilliseconds);
66    }
67  }
68}
Note: See TracBrowser for help on using the repository browser.