本文整理汇总了C#中Chromosome.GetFitness方法的典型用法代码示例。如果您正苦于以下问题:C# Chromosome.GetFitness方法的具体用法?C# Chromosome.GetFitness怎么用?C# Chromosome.GetFitness使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chromosome
的用法示例。
在下文中一共展示了Chromosome.GetFitness方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_CompareTo
public void Test_CompareTo()
{
Chromosome c1 = new Chromosome("Hello, world!");
Assert.AreEqual(0, c1.GetFitness());
Chromosome c2 = new Chromosome("H5p&J;!l<X\\7l");
Assert.AreEqual(399, c2.GetFitness());
Chromosome c3 = new Chromosome("Vc;fx#QRP8V\\$");
Assert.AreEqual(297, c3.GetFitness());
Chromosome c4 = new Chromosome("t\\O`E_Jx$n=NF");
Assert.AreEqual(415, c4.GetFitness());
Assert.AreEqual(0, c1.CompareTo(c1));
Assert.IsTrue(c1.CompareTo(c2) < 0);
Assert.IsTrue(c1.CompareTo(c3) < 0);
Assert.IsTrue(c1.CompareTo(c4) < 0);
Assert.AreEqual(0, c2.CompareTo(c2));
Assert.IsTrue(c2.CompareTo(c1) > 0);
Assert.IsTrue(c2.CompareTo(c3) > 0);
Assert.IsTrue(c2.CompareTo(c4) < 0);
Assert.AreEqual(0, c3.CompareTo(c3));
Assert.IsTrue(c3.CompareTo(c1) > 0);
Assert.IsTrue(c3.CompareTo(c2) < 0);
Assert.IsTrue(c3.CompareTo(c4) < 0);
Assert.AreEqual(0, c4.CompareTo(c4));
Assert.IsTrue(c4.CompareTo(c1) > 0);
Assert.IsTrue(c4.CompareTo(c2) > 0);
Assert.IsTrue(c4.CompareTo(c3) > 0);
}
示例2: Test_GetFitness
public void Test_GetFitness()
{
Chromosome c1 = new Chromosome("Hello, world!");
Assert.AreEqual(0, c1.GetFitness());
Chromosome c2 = new Chromosome("H5p&J;!l<X\\7l");
Assert.AreEqual(399, c2.GetFitness());
Chromosome c3 = new Chromosome("Vc;fx#QRP8V\\$");
Assert.AreEqual(297, c3.GetFitness());
Chromosome c4 = new Chromosome("t\\O`E_Jx$n=NF");
Assert.AreEqual(415, c4.GetFitness());
}