Ejemplo n.º 1
0
        public double Evaluate(IEnumerable <int> solution)
        {
            var problem     = _problemGenerator.GetProblem().ToDictionary(k => k.OrderId);
            var totalLength = 0.0;

            Coord?lastLocation = null;

            foreach (var stepOrderId in solution)
            {
                var step = problem[stepOrderId];

                if (lastLocation.HasValue)
                {
                    totalLength += _distanceCalculator.GetDistanceInKm(lastLocation.Value, step.RestaurantLocation);
                }

                totalLength += _distanceCalculator.GetDistanceInKm(step.CustomerLocation, step.RestaurantLocation);
                lastLocation = step.CustomerLocation;
            }

            return(totalLength);
        }