private static double Fitness(IPhenotype p) { var phenotype = (CollectivePhenotype <ParabolicParameters>)p; var x = phenotype.GetValue(); var distributions = GenerateDistributions(x, DistributionResolution).ToArray(); var differences = new Distribution[2]; for (var i = 0; i < differences.Length; i++) { differences[i] = distributions[i] - TestedDistributions[i]; } var average = differences.Select(d => d.Average()).ToArray(); var standardDeviation = differences.Select((d, index) => d.StandardDeviation(average[index])).ToArray(); var fitness = new double[differences.Length]; for (var i = 0; i < differences.Length; i++) { fitness[i] = Math.Abs(average[i]) + Math.Abs(standardDeviation[i]); } return(fitness.Max()); }
public static double Fitness(IPhenotype p) { var phenotype = (CollectivePhenotype <EllipticParameters>)p; var x = phenotype.GetValue(); var ellipsis = new Ellipsis(x, AnalyzedPointSet.Center.Z); if (ellipsis.Eccentricity > EccentricityThreshold) { return(double.MaxValue); } double fitness = 0; var counter = 0; double maxDistance = 0; var offsetFoci1 = x.F1 + AnalyzedPointSet.Center; var offsetFoci2 = x.F2 + AnalyzedPointSet.Center; foreach (var point in AnalyzedPointSet) { // Distance of point from Foci 1 var pf1 = MathUtils.Distance(point, offsetFoci1, MathUtils.EDistanceMetric.Euclidean, MathUtils.EDimension.X, MathUtils.EDimension.Y); // Distance of point from Foci 2 var pf2 = MathUtils.Distance(point, offsetFoci2, MathUtils.EDistanceMetric.Euclidean, MathUtils.EDimension.X, MathUtils.EDimension.Y); // Given two fixed points F1 and F2 called the foci, and a distance 2a, which is greater than the distance between the foci, // the ellipse is the set of points P such that the sum of the distances PF1, PF2 is equal to 2a: var dist = pf1 + pf2 - 2 * x.A; if (double.IsNaN(dist)) { return(double.MaxValue); } var absoluteDistance = Math.Abs(dist); if (absoluteDistance > BufferWidth) { fitness += absoluteDistance; counter++; } if (absoluteDistance > maxDistance) { maxDistance = absoluteDistance; } } fitness /= counter; fitness += maxDistance; fitness /= 2; return(fitness); }
public Individual(IGenotype genotype, IPhenotype phenotype) { Genotype = genotype; Phenotype = phenotype; Phenotype.Genotype = genotype; if (_fitnessFunction != null) { return; } var factory = new TFitnessFunctionFactory(); _fitnessFunction = factory.Make(); }
public BehaviorPhenotypeEntity(RobotEvolutionConfiguration config, int entityIndex) { Phenotypes = new IPhenotype[] { new Phenotype("LookAheadCycles", LookAheadCyclesBits) { MinValue = 0, MaxValue = 254 }, new Phenotype("BehaviorWeight", BehaviorWeightBits) { MinValue = 0, MaxValue = 10 } }; }
private double GetValue(IEnumerable <int> genes, int skip, IPhenotype phenotype) { var representation = string.Join(String.Empty, genes.Skip(skip).Take(phenotype.Length)); var value = (float)BinaryStringRepresentation.ToDouble(representation, 0); if (value < phenotype.MinValue) { return(phenotype.MinValue); } if (value > phenotype.MaxValue) { return(phenotype.MaxValue); } return(value); }
public BrickPhenotypeEntity(Vector3 minPosition, Vector3 maxPosition) { Phenotypes = new IPhenotype[] { new Phenotype("x", 5) { MinValue = minPosition.x, MaxValue = maxPosition.x }, new Phenotype("y", 5) { MinValue = minPosition.y, MaxValue = maxPosition.y }, new Phenotype("z", 5) { MinValue = minPosition.z, MaxValue = maxPosition.z }, }; }
public CarVectorPhenotypeEntity(CarSampleConfig config, int entityIndex) { Phenotypes = new IPhenotype[] { new Phenotype("VectorSize", VectorSizeBits) { MinValue = 1, MaxValue = config.MaxVectorSize }, new Phenotype("VectorAngle", VectorAngleBits) { MinValue = 0, MaxValue = 359 }, new CarWheelIndexPhenotype(config, entityIndex), new CarWheelRadiusPhenotype(config, entityIndex) }; }
public ShootVectorPhenotypeEntity(ShooterSampleConfig config, int entityIndex) { Phenotypes = new IPhenotype[] { new Phenotype("Vector_Y_Shoot", Shoot_Y_VectorBits_Bits) { MinValue = 0, MaxValue = config.Max_VectorAngle }, new Phenotype("Vector_Z_Shoot", Shoot_Z_VectorBits_Bits) { MinValue = 0, MaxValue = config.Max_VectorAngle }, new Phenotype("Vector_Strengh", Shoot_VectorStrengh_Bits) { MinValue = 0, MaxValue = config.MaxStrengh } }; }
public int CompareTo(IPhenotype other) { return(Fitness.CompareTo(other.Fitness)); }
public double GetValue(IPhenotype x) { return(Function(x)); }