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")); }
public bool Valid(Gene gene) { var valid = !_seenGenes.ContainsKey(gene); if (valid) { _seenGenes.Add(gene, true); } return(valid); }
public bool Valid(Gene gene) { var valid = !_seenGenes.ContainsKey(gene); if (valid) { _seenGenes.Add(gene, true); } return valid; }
public bool Valid(Gene gene) { foreach (var validator in _geneValidators) { if (!validator.Valid(gene)) { return(false); } } return(true); }
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); }
public bool Valid(Gene gene) { foreach (var validator in _geneValidators) { if (!validator.Valid(gene)) { return false; } } return true; }
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); }
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; }
private Gene CreateNew() { var gene = new Gene(); foreach (var chromosomeType in _chromosomeTypes) { gene.Chromosomes.Add(chromosomeType.GetRandomValue(_random)); } return gene; }