Beispiel #1
0
        public GPAbstractNode CreateRandomNode(GPConfig config, bool flagTerminal, GPAbstractNode parent = null, int countLevel = 0)
        {
            GPAbstractNode ret = null;

            do
            {
                ret = InternalCreateRandomNode(config, flagTerminal, parent, countLevel);
                if (ret.SizeLevel() > maxLevels || ret.SizeLevel() < minLevels)
                {
                    ret = null;
                }
            } while (ret == null);
            return(ret);
        }
        public void TestaGPCriacaoPelaLista()
        {
            GPPool pool = new GPPool(config);

            string listDefault = "default";
            GPSolutionDefinition definition    = CreateSampleDefinition(listDefault);
            SemanticaList        listaFormulas = CriaListaDefault(definition);
            SemanticaList        listSemantic  = definition.GetListByName(listDefault);

            listSemantic.maxLevels = 3;
            listSemantic.minLevels = 2;
            GPAbstractNode nodeRandom = listSemantic.CreateRandomNode(config, false);

            Assert.IsNotNull(nodeRandom);
            string toString = nodeRandom.ToString();

            Assert.IsTrue(nodeRandom.SizeLevel() >= listSemantic.minLevels && nodeRandom.SizeLevel() <= listSemantic.maxLevels, "SizeLevel:" + nodeRandom.SizeLevel());
        }