public Solution Get() { SetInputData(); var routes = new List <Route>(); while (_unRoutedCustomers.Count > 0) { var route = new InsertionHeuristics(_depot, _unRoutedCustomers, _routeCapacity).Generate(); route.Id = routes.Count; route.Capacity = _routeCapacity; routes.Add(route); _unRoutedCustomers = _unRoutedCustomers.Except(route.Customers).ToList(); } var numberOfRemainingVehicles = _dataset.Vehicles.Count - routes.Count; for (var i = 0; i < numberOfRemainingVehicles; i++) { var customers = new List <Customer> { _depot, Helpers.Clone(_depot) }; var route = new Route() { Id = routes.Count, Customers = customers, Capacity = _routeCapacity, Load = 0.0, Distance = 0.0 }; routes.Add(route); } ResetReturningDepotName(routes); var solution = new Solution() { Routes = routes, Cost = routes.Sum(d => d.Distance) }; return(solution); }
public Solution Run() { SetInputData(); var routes = new List <Route>(); while (_unRoutedCustomers.Count > 0) { var route = new InsertionHeuristics(_depot, _unRoutedCustomers, _routeCapacity).Generate(); route.Id = routes.Count; route.Capacity = _routeCapacity; routes.Add(route); _unRoutedCustomers = _unRoutedCustomers.Except(route.Customers).ToList(); } ResetReturningDepotName(routes); var solution = new Solution() { Routes = routes, Cost = routes.Sum(d => d.Distance) }; return(solution); }