def GetBestRouteInOrbits(self, source, destination, orbits): routes = list() for orbit in orbits: route = GlobalFunctions.GetRouteNameByProblem(orbit, self) speed = orbit.Speed if self.Speed < orbit.Speed: speed = self.Speed time = orbit.Distance / speed routeObject = Route(route, source, destination, orbit.Name, self, time) routes.extend([routeObject]) routes.sort(key=lambda x: x.Time) return routes[0]
def GetBestRoute(self): self.Routes.clear() orbits = list([ orbit for orbit in self.Orbits if ((orbit.Source == self.Source and orbit.Destination == self.Destination) or (orbit.Destination == self.Source and orbit.Source == self.Destination)) ]) for orbit in orbits: for vehicle in GlobalVariables.vehicleswithWeather: if self.Weather not in vehicle.Weathers: continue route = GlobalFunctions.GetRouteNameByProblem(orbit, vehicle) speed = orbit.Speed if vehicle.Speed < orbit.Speed: speed = vehicle.Speed time = orbit.Distance / speed routeObject = Route(route, self.Source, self.Destination, orbit.Name, vehicle, time) self.Routes.extend([routeObject]) self.Routes.sort(key=lambda x: x.Time) return self.Routes[0]