public void TestGPInicial()
        {
            GPSolutionDefinition sh            = new GPSolutionDefinition(config);
            SemanticaList        listaFormulas = CriaListaDefault(sh);
            SemanticaList        listaNumerica = CriaListaNumerica(sh);

            GPTemplate template = CreateTestTemplate(config, listaFormulas, listaNumerica);
            GPPool     pool     = new GPPool(config);

            Assert.IsTrue(config.poolSize > 0);
            Assert.IsTrue(config.elitismRange > 0);
            Assert.IsTrue(config.mutationRatePerc > 0);
            Assert.IsTrue(config.mutationRange > 0);
            Assert.IsTrue(config.poolSize > 0);

            pool.InitPool(template);


            Assert.IsTrue(pool.solutions.Count > 0);

            //randomizo valores iniciais para fazer ordenação
            Random rnd = new Random();

            for (int i = 0; i < pool.solutions.Count; i++)
            {
                GPSolution solution = pool.solutions[i];
                solution.fitnessResult = rnd.Next(1, 10000);
            }


            pool.SortFitness();
            for (int i = 1; i < pool.solutions.Count; i++)
            {
                Assert.IsTrue(pool.solutions[i - 1].fitnessResult >= pool.solutions[i].fitnessResult);
            }

            GPSolution sol1 = pool.solutions[1];
            GPSolution sol2 = pool.solutions[2];

            string splicedKey = sol1.SpliceWith(sol2);

            Assert.IsNotNull(splicedKey);

            string strOriginal = sol1.GetValue(splicedKey).ToString();

            sol1.Mutate(sol1.GetValue(splicedKey), splicedKey);
            string strMutated = sol1.GetValue(splicedKey).ToString();
            //Assert.IsFalse(strOriginal == strMutated,"Não mutou: "+strOriginal);

            GPSolution badSolution = pool.solutions[pool.solutions.Count - 1];

            pool.Mutate();
            Assert.IsFalse(pool.solutions.Contains(badSolution));
            Assert.IsTrue(pool.solutions.Count == config.poolSize, pool.solutions.Count + "<>" + config.poolSize);
        }
        public void TestGPTemplate()
        {
            GPSolutionDefinition holder = new GPSolutionDefinition(config);

            /*
             * vou simular um template com 4 formulas(nodes) e 2 variaveis numéricas
             * f1(NODE,NUMBER)
             * F2(NODE,NODE)
             * F3
             * F4(NUMBER)
             */
            SemanticaList listaFormulas = CriaListaDefault(holder);

            //Lista Numerica
            SemanticaList listaNumerica = CriaListaNumerica(holder);

            //Templates: possuem propriedades evolutivas, cada uma apontando para uma lista de semantica
            GPTemplate template = CreateTestTemplate(config, listaFormulas, listaNumerica);

            GPSolution solution = template.CreateRandomSolution();

            Assert.IsNotNull(solution);
            GPAbstractNode p1 = solution.GetValue("prop1");

            Assert.IsNotNull(p1);
            GPAbstractNode p2 = solution.GetValue("prop2");

            Assert.IsNotNull(p2);
            GPAbstractNode p3 = solution.GetValue("prop3");

            Assert.IsNotNull(p3);
            GPAbstractNode p4 = solution.GetValue("prop4");

            Assert.IsNotNull(p4);

            GPAbstractNode n1 = solution.GetValue("number1");

            Assert.IsNotNull(n1);
            GPAbstractNode n2 = solution.GetValue("number2");

            Assert.IsNotNull(n2);


            GPAbstractNode clonep1 = p1.Clone();

            Assert.IsNotNull(clonep1);
            Assert.IsFalse(clonep1 == p1);
            Assert.IsTrue(clonep1.ToString() == p1.ToString());

            GPSolution cloneSolution = solution.Clone();
            GPSolution solution2     = template.CreateRandomSolution();

            GPSolution childSolution2 = null;
            GPSolution childSolution  = solution.CreateChildWith(solution2, out childSolution2);

            Assert.IsNotNull(childSolution);
            Assert.IsNotNull(childSolution2);
        }