Exemplo n.º 1
0
        public void CrossoverTest()
        {
            var obj = new SimpleClass();
            var generator = new Generator<SimpleClass>();
            CodeExpression<SimpleClass> leftTree = generator.BuildRandomExpressionTree();
            CodeExpression<SimpleClass> rightTree = generator.BuildRandomExpressionTree();

            Trace.WriteLine("Vor dem Crossover");
            Trace.WriteLine("-----------------");
            Trace.WriteLine("");
            Trace.WriteLine("Tree links:");
            Trace.WriteLine(leftTree);

            Trace.WriteLine("");
            Trace.WriteLine("Tree rechts:");
            Trace.WriteLine(rightTree);

            generator.Crossover(ref leftTree, ref rightTree);

            Trace.WriteLine("");
            Trace.WriteLine("Nach dem Crossover");
            Trace.WriteLine("------------------");
            Trace.WriteLine("");
            Trace.WriteLine("Tree links:");
            Trace.WriteLine(leftTree);

            Trace.WriteLine("");
            Trace.WriteLine("Tree rechts:");
            Trace.WriteLine(rightTree);
        }
Exemplo n.º 2
0
        public void GenerateExpressionTree()
        {
            var obj = new SimpleClass();
            var generator = new Generator<SimpleClass>();
            var func = generator.BuildRandomExpressionTree();
            Trace.WriteLine(func);

            func.Execute(obj);
        }
Exemplo n.º 3
0
        public void MutationTest()
        {
            var obj = new SimpleClass();
            var generator = new Generator<SimpleClass>();
            CodeExpression<SimpleClass> tree = generator.BuildRandomExpressionTree();

            Trace.WriteLine("Vor der Mutation");
            Trace.WriteLine("----------------");
            Trace.WriteLine("");
            Trace.WriteLine(tree);

            generator.Mutate(ref tree);

            Trace.WriteLine("");
            Trace.WriteLine("Nach der Mutation");
            Trace.WriteLine("-----------------");
            Trace.WriteLine("");
            Trace.WriteLine(tree);
        }