本文整理汇总了C#中Individual.CalculateFitness方法的典型用法代码示例。如果您正苦于以下问题:C# Individual.CalculateFitness方法的具体用法?C# Individual.CalculateFitness怎么用?C# Individual.CalculateFitness使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Individual
的用法示例。
在下文中一共展示了Individual.CalculateFitness方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateBestPlacementInIndividual
/// <summary>
/// Places a city into an idividual.
/// </summary>
/// <param name="problem"></param>
/// <param name="calculator"></param>
/// <param name="round_idx"></param>
/// <param name="individual"></param>
/// <param name="city_to_place"></param>
/// <returns></returns>
internal static BestPlacementResult CalculateBestPlacementInIndividual(
Problem problem,
FitnessCalculator calculator,
int round_idx,
Individual<List<Genome>, Problem, Fitness> individual,
int city_to_place)
{
// if the target round is empty best placement is impossible.
Genome round = individual.Genomes[round_idx];
// do best placement in the genome/round.
BestPlacementResult result =
BestPlacementHelper.CalculateBestPlacementInGenome(problem, calculator, round, city_to_place);
// set the round index.
result.RoundIdx = round_idx;
if (!individual.FitnessCalculated)
{
individual.CalculateFitness(
problem, calculator);
}
result.Fitness = calculator.Adjust(
problem,
individual.Fitness,
round_idx,
result.Increase);
// return the result.
return result;
}