Changeset 3297


Ignore:
Timestamp:
04/10/10 11:26:26 (11 years ago)
Author:
gkronber
Message:

Added test classes for crossover and subroutine creater. #290 (Implement ADFs)

Location:
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureAlteringOperators/SubroutineCreater.cs

    r3294 r3297  
    119119      // add new function name to original branch
    120120      selectedBody.AddDynamicSymbol(functionName, argumentBranches.Count);
    121       Debug.Assert(grammar.IsValidExpression(symbolicExpressionTree));
    122121      return true;
    123122    }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Creators/ProbabilisticTreeCreator.cs

    r3294 r3297  
    5757        }
    5858      } while (tree.Root.SubTrees.Count == 0 || tree.Size > maxTreeSize || tree.Height > maxTreeHeight);
    59       System.Diagnostics.Debug.Assert(grammar.IsValidExpression(tree));
    6059      return tree;
    6160    }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Crossovers/SubtreeCrossover.cs

    r3294 r3297  
    7474                            select branch;
    7575
    76       if (allowedBranches.Count() > 0) {
     76      if (allowedBranches.Count() == 0) {
     77        success = false;
     78        return parent0;
     79      } else {
    7780        var selectedBranch = SelectRandomBranch(random, allowedBranches, internalCrossoverPointProbability);
    7881
     
    8487        return parent0;
    8588      }
    86 
    87       success = false;
    88       return parent0;
    8989    }
    9090
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.Tests.csproj

    r3294 r3297  
    3939  </ItemGroup>
    4040  <ItemGroup>
     41    <Compile Include="SubroutineCreaterTest.cs" />
     42    <Compile Include="SubtreeCrossoverTest.cs" />
    4143    <Compile Include="Properties\AssemblyInfo.cs" />
    4244    <Compile Include="ProbabilisticTreeCreaterTest.cs" />
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ProbabilisticTreeCreaterTest.cs

    r3294 r3297  
    66using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    77using HeuristicLab.Random;
     8using System.Diagnostics;
    89
    910namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     
    1819        randomTrees.Add(ProbabilisticTreeCreator.Create(random, grammar, 100, 10));
    1920      }
     21      foreach (var tree in randomTrees)
     22        Assert.IsTrue(grammar.IsValidExpression(tree));
    2023    }
    2124
     
    7780
    7881    [TestMethod()]
    79     public void SizeDistributionTest() {
     82    public void ProbabilisticTreeCreaterSizeDistributionTest() {
    8083      int[] histogram = new int[105 / 5];
    8184      for (int i = 0; i < randomTrees.Count; i++) {
     
    9295
    9396    [TestMethod()]
    94     public void FunctionDistributionTest() {
     97    public void ProbabilisticTreeCreaterFunctionDistributionTest() {
    9598      Dictionary<Symbol, int> occurances = new Dictionary<Symbol, int>();
    9699      double n = 0.0;
     
    115118
    116119    [TestMethod()]
    117     public void NumberOfSubTreesDistributionTest() {
     120    public void ProbabilisticTreeCreaterNumberOfSubTreesDistributionTest() {
    118121      Dictionary<int, int> occurances = new Dictionary<int, int>();
    119122      double n = 0.0;
     
    137140
    138141    [TestMethod()]
    139     public void TerminalDistributionTest() {
     142    public void ProbabilisticTreeCreaterTerminalDistributionTest() {
    140143      Dictionary<Symbol, int> occurances = new Dictionary<Symbol, int>();
    141144      double n = 0.0;
Note: See TracChangeset for help on using the changeset viewer.