Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ArgumentCreaterTest.cs @ 3634

Last change on this file since 3634 was 3539, checked in by gkronber, 15 years ago

Cosmetic name-space rename. #937 (Data types and operators for symbolic expression tree encoding)

File size: 3.0 KB
RevLine 
[3360]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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;
[3338]23using System.Text;
24using System.Collections.Generic;
25using System.Linq;
26using Microsoft.VisualStudio.TestTools.UnitTesting;
27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
28using HeuristicLab.Random;
29using System.Diagnostics;
[3539]30using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
[3462]31using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
[3338]32
33namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
34  [TestClass]
35  public class ArgumentCreaterTest {
36    private const int POPULATION_SIZE = 1000;
37    private const int MAX_TREE_SIZE = 100;
38    private const int MAX_TREE_HEIGHT = 10;
39    private TestContext testContextInstance;
40
41    /// <summary>
42    ///Gets or sets the test context which provides
43    ///information about and functionality for the current test run.
44    ///</summary>
45    public TestContext TestContext {
46      get {
47        return testContextInstance;
48      }
49      set {
50        testContextInstance = value;
51      }
52    }
53
54    [TestMethod()]
55    public void ArgumentCreaterDistributionsTest() {
56      var trees = new List<SymbolicExpressionTree>();
57      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
[3360]58      var random = new MersenneTwister(31415);
59      int failedEvents = 0;
[3338]60      for (int i = 0; i < POPULATION_SIZE; i++) {
61        var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
[3360]62        if (!ArgumentCreater.CreateNewArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3))
63          failedEvents++;
64        Util.IsValid(tree);
[3338]65        trees.Add(tree);
66      }
67      Assert.Inconclusive("ArgumentCreator: " + Environment.NewLine +
[3360]68        "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine +
69        Util.GetSizeDistributionString(trees, 200, 20) + Environment.NewLine +
[3338]70        Util.GetFunctionDistributionString(trees) + Environment.NewLine +
71        Util.GetNumberOfSubTreesDistributionString(trees) + Environment.NewLine +
72        Util.GetTerminalDistributionString(trees) + Environment.NewLine
73        );
74    }
75  }
76}
Note: See TracBrowser for help on using the repository browser.