Exemplo n.º 1
0
        public void simple_test(string expression)
        {
            var theoreticalNode      = new NodeAnalyzer().Parse(expression);
            var theoreticalResultSet = new double[_bound.StepCount + 1, _bound.StepCount + 1];

            _inRangeExpressionComputer.Compute(theoreticalNode, theoreticalResultSet, _bound);

            Node best = null;

            _geneticExpressionGenerator
            .Invoking
            (
                sut => best = sut.Generate
                              (
                    theoreticalResultSet,
                    _bound,
                    _bound,
                    Population,
                    GenerationCount,
                    GenerationDepth
                              )
            )
            .Should()
            .NotThrow();
            best.Should().NotBeNull();

            var printer = new PrettyPrintVisitor();

            printer.VisitNode(best);
            Console.WriteLine(printer.Output);
        }
        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);
        }
Exemplo n.º 3
0
        public void pretty_print_visitor(string expression)
        {
            var analyzer       = new NodeAnalyzer();
            var tree           = analyzer.Parse(expression);
            var computeVisitor = new PrettyPrintVisitor();

            computeVisitor.VisitNode(tree);
            var output = computeVisitor.Output;

            computeVisitor.Output.Should().NotBeNullOrEmpty();
            Console.WriteLine(output);
        }