本文整理汇总了C#中Chromosome.Fitness方法的典型用法代码示例。如果您正苦于以下问题:C# Chromosome.Fitness方法的具体用法?C# Chromosome.Fitness怎么用?C# Chromosome.Fitness使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chromosome
的用法示例。
在下文中一共展示了Chromosome.Fitness方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Chromosome_Calculate_Fitness
public void Chromosome_Calculate_Fitness()
{
List<City> cities = new List<City>();
cities.Add(new City(1, 2, "A"));
cities.Add(new City(5, 5, "B"));
Chromosome c = new Chromosome(cities);
Assert.AreEqual<double>(5, c.Fitness());
}
示例2: Chromosome_Calculate_Fitness_5Nodes
public void Chromosome_Calculate_Fitness_5Nodes()
{
List<City> cities = new List<City>();
cities.Add(new City(1, 1, "A"));
cities.Add(new City(5, 5, "B"));
cities.Add(new City(10, 10, "C"));
cities.Add(new City(20, 20, "D"));
cities.Add(new City(30, 30, "E"));
Chromosome c = new Chromosome(cities);
Assert.AreEqual<double>(41.01219331, Math.Round(c.Fitness(), 8));
}
示例3: Chromosome_CreateRandomChromosome
public void Chromosome_CreateRandomChromosome()
{
List<City> cities = new List<City>();
cities.Add(new City(1, 1, "A"));
cities.Add(new City(5, 5, "B"));
cities.Add(new City(3, 3, "C"));
cities.Add(new City(4, 4, "D"));
cities.Add(new City(2, 2, "E"));
Chromosome c = new Chromosome(cities);
Chromosome randomC = Chromosome.CreateRandomChromosome(cities);
Assert.AreNotEqual<double>(c.Fitness(), randomC.Fitness());
}