public void MutateNodeWithCount(string expression, int expectedCount)
        {
            var node          = new NodeAnalyzer().Parse(expression);
            var optimizedNode = new OptimizationMutator().MutateNodeWithCount(node);

            optimizedNode.Count.Should().Be(expectedCount);
        }
 public GeneticMutator(Random random)
 {
     _random           = random;
     _indexVisitor     = new IndexVisitor(() => _otherIndexLookup);
     _generator        = new RandomNodeGenerator(_random);
     _optimizer        = new OptimizationMutator();
     _otherIndexLookup = -1;
 }
        public void count_with_optimize_mutator(string expression, int expected)
        {
            var tree    = new NodeAnalyzer().Parse(expression);
            var mutator = new OptimizationMutator();

            var(_, count) = mutator.MutateNodeWithCount(tree);
            count.Should().Be(expected);
        }
Exemple #4
0
 public GeneticExpressionGenerator()
 {
     _random         = new Random();
     _computer       = new InRangeExpressionComputer();
     _generator      = new RandomNodeGenerator(_random);
     _optimizer      = new OptimizationMutator();
     _geneticMutator = new GeneticMutator(_random);
 }
        public void optimizer_in_action(string input, string optimized)
        {
            var node          = new NodeAnalyzer().Parse(input);
            var optimizedNode = new OptimizationMutator().MutateNode(node);
            var printer       = new PrettyPrintVisitor();

            printer.VisitNode(optimizedNode);
            printer.ToString().Should().Be(optimized);
        }
Exemple #6
0
 public RandomNodeGenerator(Random random)
 {
     _random = random;
     _optimizationMutator = new OptimizationMutator();
 }