예제 #1
0
        public void WriteParamValues(int iteration, double fitness, Gene gene)
        {
            Write(iteration + ",");

            for (var index = 0; index < gene.Chromosomes.Count; index++)
            {
                Write(gene.Chromosomes[index] + ",");
            }

            WriteLine(fitness.ToString("N3"));
        }
예제 #2
0
        public bool Valid(Gene gene)
        {
            var valid = !_seenGenes.ContainsKey(gene);

            if (valid)
            {
                _seenGenes.Add(gene, true);
            }

            return(valid);
        }
예제 #3
0
        public bool Valid(Gene gene)
        {
            var valid = !_seenGenes.ContainsKey(gene);

            if (valid)
            {
                _seenGenes.Add(gene, true);
            }

            return valid;
        }
예제 #4
0
        public bool Valid(Gene gene)
        {
            foreach (var validator in _geneValidators)
            {
                if (!validator.Valid(gene))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #5
0
        public GeneScore Evaluate(Gene gene)
        {
            for (var i = 0; i < gene.Chromosomes.Count; i++)
            {
                // NT needs everything to be doubles
                _strategy.Parameters[_strategyParameterIndices[i]].Value = Convert.ToDouble(gene.Chromosomes[i]);
            }

            _strategy.RunIteration();

            return new GeneScore(gene, FitnessFunctionWrapper.LastPerformanceValue);
        }
예제 #6
0
        public bool Valid(Gene gene)
        {
            foreach (var validator in _geneValidators)
            {
                if (!validator.Valid(gene))
                {
                    return false;
                }
            }

            return true;
        }
예제 #7
0
파일: Evolver.cs 프로젝트: minhpascal/MoGo
        private Gene Reproduce(double mutationRate, params Gene[] parents)
        {
            var child = new Gene();

            for (var i = 0; i < _chromosomeTypes.Count; i++)
            {
                var chromosome = parents[_random.Next(parents.Length)].Chromosomes[i];

                if (_random.NextDouble() < mutationRate)
                {
                    chromosome = _chromosomeTypes[i].Mutate(chromosome, _random);
                }

                child.Chromosomes.Add(chromosome);
            }

            return(child);
        }
예제 #8
0
파일: Evolver.cs 프로젝트: redrhino/MoGo
        private Gene Reproduce(double mutationRate, params Gene[] parents)
        {
            var child = new Gene();

            for (var i = 0; i < _chromosomeTypes.Count; i++)
            {
                var chromosome = parents[_random.Next(parents.Length)].Chromosomes[i];

                if (_random.NextDouble() < mutationRate)
                {
                    chromosome = _chromosomeTypes[i].Mutate(chromosome, _random);
                }

                child.Chromosomes.Add(chromosome);
            }

            return child;
        }
예제 #9
0
파일: Evolver.cs 프로젝트: redrhino/MoGo
        private Gene CreateNew()
        {
            var gene = new Gene();

            foreach (var chromosomeType in _chromosomeTypes)
            {
                gene.Chromosomes.Add(chromosomeType.GetRandomValue(_random));
            }

            return gene;
        }