def step(self, log_name, minute): if dist(self, self.apt)/self.speed + tol >= self.eta: step = self.speed if np.random.rand()<0.1: step *= 5*np.random.rand() if step <= tol + dist(self, self.apt): self.lng, self.lat = self.move_position(step) self.rect = earth2rect(self.lng,self.lat) else: self.rect = self.apt.rect self.lng = self.apt.lng self.lat = self.apt.lat self.landed = True with open(log_name, 'a') as file: file.write(self.name+" has landed\n") #self.lng, self.lat = rect2earth(self.rect) self.id_arr = dist(self, self.apt)/self.speed self.coord_path.append((self.lng, self.lat)) self.delay = 0 else: self.set_delay(dist(self, self.apt) /self.speed - self.eta, log_name)
# File kml = simplekml.Kml() # AKL airport akl = Landmark("Auckland Airport", 174.779962, -37.013383, 4000, kml) plane = loadplane(kml, isManual) sep_t = loadsep(kml) minute = 0 while not all([pl.landed for pl in plane]): with open(log_name, 'a') as file: file.write("Minute " + str(minute) + ": \n") minute += 1 if True: # not (minute % 1): valid = [ pl for pl in plane if not pl.landed and dist(pl, akl) <= 100000000 ] id_arr = [pl.id_arr for pl in valid] delay_cost = [pl.delay_cost for pl in valid] max_delay = [pl.max_delay for pl in valid] class_num = [pl.class_num for pl in valid] id_arr = [pl.id_arr for pl in valid] depends = [valid.index(pl.pred) if pl.pred else 0 for pl in valid] proc_t = [[ sep_t[i.class_num - 1, k.class_num - 1] if i.name != k.name else 0 for k in valid ] for i in valid] names = [pl.name for pl in valid] schedule = solve(id_arr, delay_cost, max_delay, class_num, proc_t,
def get_eta(self): return dist(self,self.apt)/self.speed