コード例 #1
0
        public PopulationCreator(Arguments arguments, int popSize, bool goConvolutionMod, SelectionConfig selectionConfig, SelectionStatus selectionStatus)
        {
            _arguments       = arguments;
            _convolutionMode = goConvolutionMod;
            _selectionConfig = selectionConfig;
            _selectionStatus = selectionStatus;
            _arguments       = arguments;
            _populationSize  = popSize;

            _csharpCompiler = new CsharpCompiler();
            _randomProvider = new RandomProvider(selectionConfig.Operators, selectionConfig.MaxConstantsCount, _arguments.Rows);


            Individual = new Individual[_populationSize];

            if (goConvolutionMod)
            {
                _populationSize = _selectionConfig.MaxConstantsCount * 3 - 3;
            }
            else
            {
                _selectionProvider = new MixSelection(Individual, _selectionStatus.Log, _randomProvider, _selectionConfig.Operators)
                {
                    MutationChance = _selectionConfig.MutationChance,
                    GrowSpeed      = _selectionConfig.GrowSpeed,
                }
            };

            GenotypeKids = new string[_populationSize];
        }
コード例 #2
0
        //private readonly FormMainUi _mainForm;

        public CreatePopulation(List <List <double> > points, int popSize, bool goConvolutionMod)
        {
            _points         = points;
            _argumentsCount = points[0].Count - 1;
            _csharpCompiler = new CsharpCompiler();
            Log             = new Log
            {
                Preparation    = new List <string>(),
                Simplification = new List <string>(),
                CompileErrors  = new List <CompileError>(),
            };
            _randomProvider = new RandomProvider(Operators, _maxLeafs, _argumentsCount);

            _populationSize = popSize;
            _maxLeafs       = MaxConstantsCount;
            Individual      = new Individual[popSize];

            if (goConvolutionMod)
            {
                popSize = _maxLeafs * 3 - 3;
            }
            else
            {
                _selectionProvider = new MixSelection(Individual, Log, _randomProvider, Operators)
                {
                    MutationChance = MutationChance,
                    GrowSpeed      = GrowSpeed,
                }
            };

            GenotypeKids     = new string[popSize];
            _convolutionMode = goConvolutionMod;
        }