Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5367 for trunk


Ignore:
Timestamp:
01/24/11 19:04:27 (14 years ago)
Author:
gkronber
Message:

#1136 Fixed test cases for symbolic expression tree encoding operators (+ minor bug fixes in symbolic expression tree operators).

Location:
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureManipulators/ArgumentCreater.cs

    r4722 r5367  
    8484      // this operation potentially creates very big trees so the access to the size property might throw overflow exception
    8585      try {
    86         if (CreateNewArgumentForDefun(random, clonedTree, selectedDefunBranch, newArgumentNode) && clonedTree.Size < maxTreeSize && clonedTree.Height < maxTreeHeight) {
     86        if (CreateNewArgumentForDefun(random, clonedTree, selectedDefunBranch, newArgumentNode) && clonedTree.Size <= maxTreeSize && clonedTree.Height <= maxTreeHeight) {
    8787
    8888          // size constraints are fulfilled
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Crossovers/SubtreeCrossover.cs

    r5014 r5367  
    7474      List<SymbolicExpressionTreeNode> allowedBranches = new List<SymbolicExpressionTreeNode>();
    7575      parent1.Root.ForEachNodePostfix((n) => {
    76         if (n.GetSize() < maxInsertedBranchSize &&
    77           n.GetHeight() < maxInsertedBranchHeight &&
     76        if (n.GetSize() <= maxInsertedBranchSize &&
     77          n.GetHeight() <= maxInsertedBranchHeight &&
    7878          IsMatchingPointType(crossoverPoint0, replacedSubtreeIndex, n))
    7979          allowedBranches.Add(n);
     
    117117      List<CrossoverPoint> leafCrossoverPoints = new List<CrossoverPoint>();
    118118      parent0.Root.ForEachNodePostfix((n) => {
    119         if (n.SubTrees.Count > 0 &&
    120           n.GetSize() < maxBranchSize &&
    121           n.GetHeight() < maxBranchHeight &&
    122           n != parent0.Root
    123           ) {
     119        if (n.SubTrees.Count > 0 && n != parent0.Root) {
    124120          foreach (var child in n.SubTrees) {
    125             if (child.SubTrees.Count > 0)
    126               internalCrossoverPoints.Add(new CrossoverPoint(n, child));
    127             else
    128               leafCrossoverPoints.Add(new CrossoverPoint(n, child));
     121            if (child.GetSize() <= maxBranchSize &&
     122                child.GetHeight() <= maxBranchHeight) {
     123              if (child.SubTrees.Count > 0)
     124                internalCrossoverPoints.Add(new CrossoverPoint(n, child));
     125              else
     126                leafCrossoverPoints.Add(new CrossoverPoint(n, child));
     127            }
    129128          }
    130129        }
    131130      });
     131
    132132      if (random.NextDouble() < internalNodeProbability) {
    133133        // select from internal node if possible
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/ChangeNodeTypeManipulation.cs

    r4722 r5367  
    5959                           select symbol;
    6060
    61       if (allowedSymbols.Count() <= 1) {
     61      if (allowedSymbols.Count() == 0) {
    6262        success = false;
    6363        return;
     
    7272                               where disallowedSubtrees.Count() == 0
    7373                               select symbol;
    74       if (constrainedSymbols.Count() <= 1) {
     74      if (constrainedSymbols.Count() == 0) {
    7575        success = false;
    7676        return;
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/ReplaceBranchManipulation.cs

    r5015 r5367  
    6161                           where manipulationPoint.Node.Grammar.GetMinExpressionLength(symbol) <= maxSize
    6262                           select symbol;
    63       if (allowedSymbols.Count() <= 1) return;
     63      if (allowedSymbols.Count() == 0) return;
    6464
    6565      var seedSymbol = SelectRandomSymbol(random, allowedSymbols);  // replace the old node with the new node
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/AllArchitectureAlteringOperatorsTest.cs

    r4068 r5367  
    5959      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    6060      var random = new MersenneTwister(31415);
    61       int failedEvents = 0;
    62       IntValue maxTreeSize = new IntValue(100);
    63       IntValue maxTreeHeigth = new IntValue(10);
     61      IntValue maxTreeSize = new IntValue(MAX_TREE_SIZE);
     62      IntValue maxTreeHeigth = new IntValue(MAX_TREE_HEIGHT);
    6463      IntValue maxDefuns = new IntValue(3);
    6564      IntValue maxArgs = new IntValue(3);
     
    7271      stopwatch.Start();
    7372      var combinedAAOperator = new MultiSymbolicExpressionTreeArchitectureManipulator();
     73      int failedEvents = 0;
    7474      for (int g = 0; g < N_ITERATIONS; g++) {
    7575        for (int i = 0; i < POPULATION_SIZE; i++) {
     
    8585          } else {
    8686            // crossover
    87             var par0 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone();
    88             var par1 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone();
     87            SymbolicExpressionTree par0 = null;
     88            SymbolicExpressionTree par1 = null;
     89            do {
     90              par0 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone();
     91              par1 = (SymbolicExpressionTree)trees.SelectRandom(random).Clone();
     92            } while (par0.Size > MAX_TREE_SIZE || par1.Size > MAX_TREE_SIZE);
    8993            bool success;
    90             newTrees.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, 100, 10, out success));
    91             if (!success) failedEvents++;
     94            newTrees.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, MAX_TREE_SIZE, MAX_TREE_HEIGHT, out success));
     95            Assert.IsTrue(success);
    9296          }
    9397        }
     
    96100      stopwatch.Stop();
    97101      var msPerOperation = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE / (double)N_ITERATIONS;
    98       Assert.Inconclusive("AllArchitectureAlteringOperators: " + Environment.NewLine +
    99         "Failed events: " + failedEvents / (double)POPULATION_SIZE / N_ITERATIONS * 100 + " %" + Environment.NewLine +
     102      Console.WriteLine("AllArchitectureAlteringOperators: " + Environment.NewLine +
    100103        "Operations / s: ~" + Math.Round(1000.0 / (msPerOperation)) + "operations / s)" + Environment.NewLine +
     104        "Failed events: " + failedEvents / (double)(POPULATION_SIZE * N_ITERATIONS) + "%" + Environment.NewLine +
    101105        Util.GetSizeDistributionString(trees, 200, 5) + Environment.NewLine +
    102106        Util.GetFunctionDistributionString(trees) + Environment.NewLine +
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ArgumentCreaterTest.cs

    r4068 r5367  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Collections.Generic;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    2728using HeuristicLab.Random;
    2829using Microsoft.VisualStudio.TestTools.UnitTesting;
     30using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2931
    3032namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     
    5456      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5557      var random = new MersenneTwister(31415);
    56       int failedEvents = 0;
    5758      for (int i = 0; i < POPULATION_SIZE; i++) {
    58         var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
    59         if (!ArgumentCreater.CreateNewArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3))
    60           failedEvents++;
     59        SymbolicExpressionTree tree;
     60        do {
     61          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     62        } while (!TreeHasAdfWithParameter(tree, 3));
     63        var success = ArgumentCreater.CreateNewArgument(random, tree, grammar, 10000, 100, 3, 3);
     64        Assert.IsTrue(success);
    6165        Util.IsValid(tree);
    6266        trees.Add(tree);
    6367      }
    64       Assert.Inconclusive("ArgumentCreator: " + Environment.NewLine +
    65         "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine +
     68      Console.WriteLine("ArgumentCreator: " + Environment.NewLine +
    6669        Util.GetSizeDistributionString(trees, 200, 20) + Environment.NewLine +
    6770        Util.GetFunctionDistributionString(trees) + Environment.NewLine +
     
    7073        );
    7174    }
     75
     76    private bool TreeHasAdfWithParameter(SymbolicExpressionTree tree, int maxParameters) {
     77      return tree.Root.SubTrees.Count == 2 &&
     78      tree.Root.SubTrees[1].GetAllowedSymbols(0).Where(x => x is Argument).Count() < maxParameters;
     79    }
    7280  }
    7381}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ArgumentDeleterTest.cs

    r4068 r5367  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Collections.Generic;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    2728using HeuristicLab.Random;
    2829using Microsoft.VisualStudio.TestTools.UnitTesting;
     30using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2931
    3032namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     
    5456      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5557      var random = new MersenneTwister(31415);
    56       int failedEvents = 0;
    5758      for (int i = 0; i < POPULATION_SIZE; i++) {
    58         var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
    59         if (!ArgumentDeleter.DeleteArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3))
    60           failedEvents++;
     59        SymbolicExpressionTree tree = null;
     60        do {
     61          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     62        } while (!TreeHasAdfWithArguments(tree));
     63        var success = ArgumentDeleter.DeleteArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     64        Assert.IsTrue(success);
    6165        Util.IsValid(tree);
    6266        trees.Add(tree);
    6367      }
    64       Assert.Inconclusive("ArgumentDeleter: " + Environment.NewLine +
    65         "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine +
     68      Console.WriteLine("ArgumentDeleter: " + Environment.NewLine +
    6669        Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine +
    6770        Util.GetFunctionDistributionString(trees) + Environment.NewLine +
     
    7073        );
    7174    }
     75    private bool TreeHasAdfWithArguments(SymbolicExpressionTree tree) {
     76      return tree.Root.SubTrees.Count == 2 &&
     77        tree.Root.SubTrees[1].GetAllowedSymbols(0).Where(x => x is Argument).Count() >= 2;
     78    }
    7279  }
    7380}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ArgumentDuplicaterTest.cs

    r4068 r5367  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Collections.Generic;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    2728using HeuristicLab.Random;
    2829using Microsoft.VisualStudio.TestTools.UnitTesting;
     30using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2931
    3032namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._3.Tests {
     
    5355      var trees = new List<SymbolicExpressionTree>();
    5456      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    55       var random = new MersenneTwister();
    56       int failedEvents = 0;
     57      var random = new MersenneTwister(31415);
    5758      for (int i = 0; i < POPULATION_SIZE; i++) {
    58         var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
    59         if (!ArgumentDuplicater.DuplicateArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3))
    60           failedEvents++;
     59        SymbolicExpressionTree tree = null;
     60        do {
     61          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     62        } while(!HasAdfWithArguments(tree));
     63        var success = ArgumentDuplicater.DuplicateArgument(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     64        Assert.IsTrue(success);
    6165        Util.IsValid(tree);
    6266        trees.Add(tree);
    6367      }
    64       Assert.Inconclusive("ArgumentDuplicater: " + Environment.NewLine +
    65         "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine +
     68      Console.WriteLine("ArgumentDuplicater: " + Environment.NewLine +
    6669        Util.GetSizeDistributionString(trees, 200, 5) + Environment.NewLine +
    6770        Util.GetFunctionDistributionString(trees) + Environment.NewLine +
     
    7073        );
    7174    }
     75
     76    private bool HasAdfWithArguments(SymbolicExpressionTree tree) {
     77      return tree.Root.SubTrees.Count == 2 &&
     78        tree.Root.SubTrees[1].GetAllowedSymbols(0).Where(x => x is Argument).Count() == 1;
     79    }
    7280  }
    7381}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ChangeNodeTypeManipulationTest.cs

    r4722 r5367  
    5353      var trees = new List<SymbolicExpressionTree>();
    5454      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    55       var random = new MersenneTwister();
    56       int failedEvents = 0;
     55      var random = new MersenneTwister(31415);
    5756      for (int i = 0; i < POPULATION_SIZE; i++) {
    5857        var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
    5958        bool success;
    6059        ChangeNodeTypeManipulation.ChangeNodeType(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, out success);
    61         if (!success)
    62           failedEvents++;
     60        Assert.IsTrue(success);
    6361        Util.IsValid(tree);
    6462        trees.Add(tree);
    6563      }
    66       Assert.Inconclusive("ChangeNodeTypeManipulation: " + Environment.NewLine +
    67         "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine +
     64      Console.WriteLine("ChangeNodeTypeManipulation: " + Environment.NewLine +
    6865        Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine +
    6966        Util.GetFunctionDistributionString(trees) + Environment.NewLine +
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ProbabilisticTreeCreaterTest.cs

    r4106 r5367  
    6060        Util.IsValid(tree);
    6161      }
    62       Assert.Inconclusive("ProbabilisticTreeCreator: " + Environment.NewLine +
     62      Console.WriteLine("ProbabilisticTreeCreator: " + Environment.NewLine +
    6363        Util.GetSizeDistributionString(randomTrees, 105, 5) + Environment.NewLine +
    6464        Util.GetFunctionDistributionString(randomTrees) + Environment.NewLine +
     
    7979        randomTrees.Add(tree);
    8080      }
    81       Assert.Inconclusive("ProbabilisticTreeCreator: " + Environment.NewLine +
     81      Console.WriteLine("ProbabilisticTreeCreator: " + Environment.NewLine +
    8282        Util.GetSizeDistributionString(randomTrees, 105, 5) + Environment.NewLine +
    8383        Util.GetFunctionDistributionString(randomTrees) + Environment.NewLine +
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/ReplaceBranchManipulationTest.cs

    r4722 r5367  
    5454      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5555      var random = new MersenneTwister(31415);
    56       int failedEvents = 0;
    5756      for (int i = 0; i < POPULATION_SIZE; i++) {
    5857        var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
    5958        bool success;
    6059        ReplaceBranchManipulation.ReplaceRandomBranch(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, out success);
    61         if (!success) {
    62           failedEvents++;
    63         } else {
    64           Util.IsValid(tree);
    65           trees.Add(tree);
    66         }
     60        Assert.IsTrue(success);
     61        Util.IsValid(tree);
     62        trees.Add(tree);
    6763      }
    68       Assert.Inconclusive("ReplaceBranchManipulation: " + Environment.NewLine +
    69         "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine +
     64      Console.WriteLine("ReplaceBranchManipulation: " + Environment.NewLine +
    7065        Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine +
    7166        Util.GetFunctionDistributionString(trees) + Environment.NewLine +
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/SubroutineCreaterTest.cs

    r4068 r5367  
    5454      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5555      var random = new MersenneTwister(31415);
    56       int failedEvents = 0;
    5756      for (int i = 0; i < POPULATION_SIZE; i++) {
    58         var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
    59         if (!SubroutineCreater.CreateSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3))
    60           failedEvents++;
     57        SymbolicExpressionTree tree = null;
     58        do {
     59          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     60        } while ( !OneMoreAdfAllowed(tree));
     61        var success = SubroutineCreater.CreateSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     62        Assert.IsTrue(success);
    6163        Util.IsValid(tree);
    6264        trees.Add(tree);
    6365      }
    64       Assert.Inconclusive("SubroutineCreator: " + Environment.NewLine +
    65         "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine +
     66      Console.WriteLine("SubroutineCreator: " + Environment.NewLine +
    6667        Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine +
    6768        Util.GetFunctionDistributionString(trees) + Environment.NewLine +
     
    7071        );
    7172    }
     73
     74    private bool OneMoreAdfAllowed(SymbolicExpressionTree tree) {
     75      return tree.Size < 80 && tree.Root.SubTrees.Count < 4;
     76    }
    7277  }
    7378}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/SubroutineDeleterTest.cs

    r4068 r5367  
    5454      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5555      var random = new MersenneTwister(31415);
    56       int failedEvents = 0;
    5756      for (int i = 0; i < POPULATION_SIZE; i++) {
    58         var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
    59         if (!SubroutineDeleter.DeleteSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3))
    60           failedEvents++;
     57        SymbolicExpressionTree tree = null;
     58        do {
     59          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     60        } while (!HasAtLeastOneAdf(tree));
     61        var success = SubroutineDeleter.DeleteSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     62        Assert.IsTrue(success);
    6163        Util.IsValid(tree);
    6264        trees.Add(tree);
    6365      }
    64       Assert.Inconclusive("SubroutineDeleter: " + Environment.NewLine +
    65         "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine +
     66      Console.WriteLine("SubroutineDeleter: " + Environment.NewLine +
    6667        Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine +
    6768        Util.GetFunctionDistributionString(trees) + Environment.NewLine +
     
    7071        );
    7172    }
     73
     74    private bool HasAtLeastOneAdf(SymbolicExpressionTree tree) {
     75      return tree.Root.SubTrees.Count > 1;
     76    }
    7277  }
    7378}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/SubroutineDuplicaterTest.cs

    r4068 r5367  
    5454      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    5555      var random = new MersenneTwister();
    56       int failedEvents = 0;
    5756      for (int i = 0; i < POPULATION_SIZE; i++) {
    58         var tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
    59         if (!SubroutineDuplicater.DuplicateSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3))
    60           failedEvents++;
     57        SymbolicExpressionTree tree = null;
     58        do {
     59          tree = ProbabilisticTreeCreator.Create(random, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     60        } while (!HasOneAdf(tree));
     61        var success = SubroutineDuplicater.DuplicateSubroutine(random, tree, grammar, MAX_TREE_SIZE, MAX_TREE_HEIGHT, 3, 3);
     62        Assert.IsTrue(success);
    6163        Util.IsValid(tree);
    6264        trees.Add(tree);
    6365      }
    64       Assert.Inconclusive("SubroutineDuplicater: " + Environment.NewLine +
    65         "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine +
     66      Console.WriteLine("SubroutineDuplicater: " + Environment.NewLine +
    6667        Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine +
    6768        Util.GetFunctionDistributionString(trees) + Environment.NewLine +
     
    7071        );
    7172    }
     73
     74    private bool HasOneAdf(SymbolicExpressionTree tree) {
     75      return tree.Root.SubTrees.Count == 2;
     76    }
    7277  }
    7378}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/SubtreeCrossoverTest.cs

    r4068 r5367  
    5353      var trees = new List<SymbolicExpressionTree>();
    5454      var grammar = Grammars.CreateArithmeticAndAdfGrammar();
    55       var random = new MersenneTwister();
    56       int failedEvents = 0;
     55      var random = new MersenneTwister(31415);
    5756      List<SymbolicExpressionTree> crossoverTrees;
    5857      double msPerCrossoverEvent;
     
    7069          bool success;
    7170          newPopulation.Add(SubtreeCrossover.Cross(random, par0, par1, 0.9, 100, 10, out success));
    72           if (!success) failedEvents++;
     71          Assert.IsTrue(success);
    7372        }
    7473        crossoverTrees = newPopulation;
     
    8079      msPerCrossoverEvent = stopwatch.ElapsedMilliseconds / (double)POPULATION_SIZE / (double)generations;
    8180
    82       Assert.Inconclusive("SubtreeCrossover: " + Environment.NewLine +
    83         "Failed events: " + failedEvents / (double)POPULATION_SIZE * 100 + " %" + Environment.NewLine +
     81      Console.WriteLine("SubtreeCrossover: " + Environment.NewLine +
    8482        msPerCrossoverEvent + " ms per crossover event (~" + Math.Round(1000.0 / (msPerCrossoverEvent)) + "crossovers / s)" + Environment.NewLine +
    8583        Util.GetSizeDistributionString(trees, 105, 5) + Environment.NewLine +
Note: See TracChangeset for help on using the changeset viewer.