public static double ComputeAverageVelocity(ProblemController controller)
 {
     double sum = 0;
     int cars = 0;
     Dictionary<Route, int> carCount;
     var timeForRoutes = controller.ComputeEachRoute(out carCount);
     foreach (var route in timeForRoutes.Keys)
     {
         sum += carCount[route] * route.Distance / timeForRoutes[route];
         cars += carCount[route];
     }
     return sum / cars;
 }
 private void PerformIteration()
 {
     var simulationResult = new List<double>(phenotypeCount);
     //Console.WriteLine("--- --- ---");
     for (var i = 0; i < phenotypeCount; ++i)
     {
         var controller = new ProblemController(problemInstance);
         controller.SetTrafficLightsConfiguration(phenotypes[i]);
         controller.Start(secondCount);
         var averageVelocity = AlgorithmUtils.ComputeAverageVelocity(controller);
         //Console.Write(averageVelocity + ", ");
         simulationResult.Add(averageVelocity);
     }
     //Console.WriteLine("--- --- ---");
     SetBest(simulationResult);
     PerformEvolution(simulationResult);
 }