Exemple #1
0
        public RoutePlanInternal GetRoutePlan(IEnumerable <int> addressesIds, int destinationId, IEnumerable <int> carPlan)
        {
            RoutePlanInternal routePlan = new RoutePlanInternal();

            var routes = new List <RouteInternal>();

            foreach (var car in carPlan)
            {
                var matrixByDescendingDistanceFromDestination = _matrixRepository
                                                                .GetList(a => a.DestinationId == destinationId &&
                                                                         addressesIds.Contains(a.OriginId))
                                                                .OrderByDescending(info => info.Value)
                                                                .ToList();


                var optimalVariation = GetOptimizedPickupVariation(matrixByDescendingDistanceFromDestination, destinationId, car);

                routes.Add(optimalVariation);

                //Remove before iteration
                matrixByDescendingDistanceFromDestination
                .RemoveAll(ai => optimalVariation.Legs.Select(leg => leg.StartAddressId).Contains(ai.OriginId));
            }

            return(routePlan);
        }
        public RoutePlanInternal GetRoutePlan(IEnumerable<int> addressesIds, int destinationId, IEnumerable<int> carPlan)
        {
            RoutePlanInternal routePlan = new RoutePlanInternal();

            var routes = new List<RouteInternal>();

            foreach (var car in carPlan)
            {
                var matrixByDescendingDistanceFromDestination = _matrixRepository
                                                                .GetList(a => a.DestinationId == destinationId
                                                                        && addressesIds.Contains(a.OriginId))
                                                                .OrderByDescending(info => info.Value)
                                                                .ToList();


                var optimalVariation = GetOptimizedPickupVariation(matrixByDescendingDistanceFromDestination, destinationId, car);

                routes.Add(optimalVariation);

                //Remove before iteration
                matrixByDescendingDistanceFromDestination
                    .RemoveAll(ai => optimalVariation.Legs.Select(leg => leg.StartAddressId).Contains(ai.OriginId));
            }

            return routePlan;
        }