Beispiel #1
0
        public GPAbstractNode InternalCreateRandomNode(GPConfig config, bool flagTerminal, GPAbstractNode parent = null, int countLevel = 0)
        {
            GPSemantica    semantica = GetRandomSemantica(flagTerminal);
            GPAbstractNode node      = semantica.InstantiateEmpty();

            if (parent == null)
            {
                parent = node;
            }

            int rndVal = rnd.Next(semantica.minParams, semantica.maxParams);

            for (int i = 0; i < rndVal; i++)
            {
                GPAbstractNode nodeParam = InternalCreateRandomNode(config, countLevel >= config.minLevels, parent, countLevel + 1);
                if (!node.CanAddNode(nodeParam))
                {
                    throw new Exception("Node não permite adicionar nodeParam!");
                }
                node.AddNode(nodeParam);
            }


            return(node);
        }
        public BackTesterSemantica(GPConfig config)
            : base(config)
        {
            InicializaFormulasFinanceiras();

            AddSemanticaToList(GPConsts.LISTA_FORMULA, GetSemantica(GPConsts.BOOL_AND));
            AddSemanticaToList(GPConsts.LISTA_FORMULA, GetSemantica(GPConsts.BOOL_OR));
            AddSemanticaToList(GPConsts.LISTA_FORMULA, GetSemantica(GPConsts.BOOL_XOR));
        }
Beispiel #3
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);
        }
        private static GPTemplate CreateTestTemplate(GPConfig config, SemanticaList listaFormulas, SemanticaList listaNumerica)
        {
            GPTemplate template = new GPTemplate(config);

            template.AddProperty("prop1", listaFormulas);
            Assert.IsTrue(template.GetProperty("prop1") == listaFormulas);
            template.AddProperty("prop2", listaFormulas);
            template.AddProperty("prop3", listaFormulas);
            template.AddProperty("prop4", listaFormulas);

            template.AddProperty("number1", listaNumerica);
            template.AddProperty("number2", listaNumerica);
            return(template);
        }
        public GPSolutionDefinition(GPConfig config)
        {
            listOfSemantics = new Dictionary <string, SemanticaList>();
            allSemantics    = new Dictionary <string, GPSemantica>();
            this.config     = config;

            InitDefaultSemantics();

            CreateListByName(GPConsts.LISTA_FORMULA, config.minLevels, config.maxLevels);
            CreateListByName(GPConsts.LISTA_NUMEROS, 0, 0);
            CreateListByName(GPConsts.LISTA_NUMEROS_BOOLEANOS, 0, 0);
            CreateListByName(GPConsts.LISTA_NUMEROS_PERCENTUAIS, 0, 0);
            CreateListByName(GPConsts.LISTA_NUMEROS_GRANDES, 0, 0);


            AddSemanticaToList(GPConsts.LISTA_FORMULA, GetSemantica(GPConsts.NUMBER_DEFAULT));
            AddSemanticaToList(GPConsts.LISTA_NUMEROS, GetSemantica(GPConsts.NUMBER_DEFAULT));
            AddSemanticaToList(GPConsts.LISTA_NUMEROS_BOOLEANOS, GetSemantica(GPConsts.NUMBER_BOOLEAN));
            AddSemanticaToList(GPConsts.LISTA_NUMEROS_GRANDES, GetSemantica(GPConsts.NUMBER_GRANDE));
            AddSemanticaToList(GPConsts.LISTA_NUMEROS_PERCENTUAIS, GetSemantica(GPConsts.NUMBER_PERCENTUAL));
        }
Beispiel #6
0
 public GPTemplate(GPConfig config)
 {
     properties  = new Dictionary <string, SemanticaList>();
     this.config = config;
 }
Beispiel #7
0
 private static GPConfig LoadGPConfig()
 {
     return(GPConfig.LoadSaved());
 }