def solve(self): # get the store list, make sure all stores are visited stores_list = self.maps.get_store_list() visited_stores = [0] schedule = Schedule() # while there is still store to visit # outer loop is to iterate over the routes while (len(stores_list) > 0): route = Route() have_time = True # inner loop is to build a route while have_time and len(stores_list) > 0: curr_store_id = route.get_curr_store() next_store_id = self.maps.get_next_nearest_store( curr_store_id, visited_stores) # check if the closest store is feasible # to be visited have_time = route.add_next_store( next_store_id, self.maps ) # if it is visited if have_time: visited_stores.append(next_store_id) stores_list.remove(next_store_id) # finish route by going back to HQ dist_to_hq = self.maps.get_distance(route.get_curr_store(), 0) route.end_day(dist_to_hq) schedule.add(route) return schedule