/// <summary>
        ///     Construct the generator.
        /// </summary>
        /// <param name="theContext">The context that is to be used for generation.</param>
        /// <param name="theMaxDepth">The maximum depth to generate to.</param>
        protected AbstractPrgGenerator(EncogProgramContext theContext,
                                    int theMaxDepth)
        {
            if (theContext.Functions.Count == 0)
            {
                throw new EncogError("There are no opcodes defined");
            }

            _context = theContext;
            _maxDepth = theMaxDepth;
            _hasEnum = _context.HasEnum;
            Score = new ZeroEvalScoreFunction();
            MinConst = -10;
            MaxConst = 10;
            RandomFactory = EncogFramework.Instance.RandomFactory.FactorFactory();
            MaxGenerationErrors = 500;
        }
        public void Eval(String start, String expect)
        {
            EncogProgramContext context = new EncogProgramContext();
            StandardExtensions.CreateNumericOperators(context);
            PrgPopulation pop = new PrgPopulation(context, 1);
            ICalculateScore score = new ZeroEvalScoreFunction();

            TrainEA genetic = new TrainEA(pop, score);
            genetic.ValidationMode = true;
            genetic.CODEC = new PrgCODEC();
            genetic.AddOperation(0.95, new SubtreeCrossover());
            genetic.AddOperation(0.05, new SubtreeMutation(context, 4));
            genetic.AddScoreAdjuster(new ComplexityAdjustedScore());
            genetic.Rules.AddRewriteRule(new RewriteConstants());
            genetic.Rules.AddRewriteRule(new RewriteAlgebraic());

            EncogProgram expression = new EncogProgram(context);
            expression.CompileExpression(start);
            RenderCommonExpression render = new RenderCommonExpression();
            genetic.Rules.Rewrite(expression);
            Assert.AreEqual(expect, render.Render(expression));
        }