// Calculate the path length of hte current genotype. public static double dist(Genotype gt) { // Convert the genotype to the traveling path int[] path = gt.getChromosome().toSeq().stream() .mapToInt(new ToIntFunctionImpl()) .toArray(); // Calculate the path distance. var dist = IntStream.__Methods.range(0, STOPS) .mapToDouble(new IntToDoubleFunctionImpl(path)) .sum(); return dist; }
/// <summary> /// Calculates the fitness for a given genotype. /// </summary> /// <param name="gt">Genotype of BitGene type in Java example</param> /// <returns></returns> private static Integer count(Genotype gt) { return new Integer(((BitChromosome)(gt.getChromosome())).bitCount()); }