void solver_NewFittest(Individual <MaxTimeSolution, MaxTimeProblem, Fitness> solution)
        {
            long ticks_after = DateTime.Now.Ticks;

            MaxTimeSolution routes = solution.Genomes;

            if (output_each)
            {
                StringBuilder sizes = new StringBuilder();
                foreach (int size in routes.Sizes)
                {
                    sizes.Append(size);
                    sizes.Append(" ");
                }

                StringBuilder weights = new StringBuilder();
                foreach (double weight in solution.Fitness.Weights)
                {
                    weights.Append(weight.ToString(CultureInfo.InvariantCulture));
                    weights.Append(" ");
                }

                StringBuilder probalities = new StringBuilder();
                foreach (double prod in _probabilities)
                {
                    probalities.Append(prod.ToString(CultureInfo.InvariantCulture));
                    probalities.Append(";");
                }


                string settings_string = string.Format("{0};{1};{2};{3};{4};{5};{6};{7};",
                                                       _customers.Count, this.Max.Value,
                                                       _stagnation, _population, _max_generations, _elitism_percentage, _cross_percentage, _mutation_percentage);

                //output.Close();
                //output.Dispose();
                //output_file = null;
            }

            //Genome routes = individual.Genomes[0];
            // TODO: convert solution.
            int[][] result = new int[routes.Count][];
            for (int idx = 0; idx < routes.Count; idx++)
            {
                IRoute route = routes.Route(idx);
                result[idx] = route.ToArray();
            }

            this.RaiseIntermidiateResult(result);
        }
        /// <summary>
        /// Builds an OsmSharRoute.
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="points"></param>
        /// <param name="tspSolution"></param>
        /// <param name="weight"></param>
        /// <returns></returns>
        public Route BuildRoute(Vehicle vehicle, RouterPoint[] points, IRoute tspSolution, double weight)
        {
            int[] solution = tspSolution.ToArray();

            Route tsp = null;
            Route route;

            for (int idx = 0; idx < solution.Length - 1; idx++)
            {
                route = _router.Calculate(Vehicle.Car, points[solution[idx]],
                                          points[solution[idx + 1]]);
                if (tsp == null)
                { // first route = start
                    tsp = route;
                }
                else
                { // concatenate.
                    tsp = Route.Concatenate(tsp, route);
                }
            }
            if (tspSolution.IsRound)
            {
                // concatenate the route from the last to the first point again.
                route = _router.Calculate(Vehicle.Car, points[solution[solution.Length - 1]],
                                          points[solution[0]]);
                tsp = Route.Concatenate(tsp, route);
            }

            if (tsp != null)
            {
                tsp.Vehicle = vehicle; // set the correct vehicle type.

                if (_interpreter != null)
                { // there is an interpreter set: calculate time/distance.
                    // calculate metrics.
                    var calculator = new TimeCalculator(_interpreter);
                    Dictionary <string, double> metrics = calculator.Calculate(tsp);
                    tsp.TotalDistance = metrics[TimeCalculator.DISTANCE_KEY];
                    tsp.TotalTime     = metrics[TimeCalculator.TIME_KEY];
                }

                tsp.Tags          = new RouteTags[1];
                tsp.Tags[0]       = new RouteTags();
                tsp.Tags[0].Key   = "internal_weight";
                tsp.Tags[0].Value = weight.ToString(System.Globalization.CultureInfo.InvariantCulture);
            }

            return(tsp);
        }
        /// <summary>
        /// Builds a route along all the given point in the order given by the tsp solution.
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="resolved"></param>
        /// <param name="coordinates"></param>
        /// <param name="tspSolution"></param>
        /// <param name="isRound"></param>
        /// <returns></returns>
        public Route BuildRoute(Vehicle vehicle, RouterPoint[] resolved, GeoCoordinate[] coordinates, IRoute tspSolution, bool isRound)
        {
            // sort resolved and coordinates.
            var solution = tspSolution.ToArray();
            var size = isRound ? solution.Length + 1 : solution.Length;
            var sortedResolved = new RouterPoint[size];
            var sortedCoordinates = new GeoCoordinate[size];
            for (int idx = 0; idx < solution.Length; idx++)
            {
                sortedResolved[idx] = resolved[solution[idx]];
                sortedCoordinates[idx] = coordinates[solution[idx]];
            }

            // make round if needed.
            if (isRound)
            {
                sortedResolved[size - 1] = sortedResolved[0];
                sortedCoordinates[size - 1] = sortedCoordinates[0];
            }

            // build the route.
            return this.BuildRoute(vehicle, sortedResolved, sortedCoordinates);
        }