私は、12 時間にわたってポアソン分布で分散された 200 機の飛行機を使用するプログラムを作成しています。これらの飛行機は、滑走路が 1 つしかない飛行場に着陸する必要があります。指数分布から逆 CDF 法を使用して、到着間隔を決定します。しかし、空中での待ち時間は計算できないようだ。
たとえば、飛行機は 100 秒で到着し、着陸に 75 秒かかり、175 秒で完了します。飛行機 2 は 150 秒で到着し、175-150 = 25 秒待たなければなりません。待機時間も0秒になる可能性があることを考慮して、関数が出力できる変数をプログラムするにはどうすればよいですか?
import math
import random
import numpy as np
def variable(amount_of_planes):
plane_number = []
time_between_planes = []
plane_arrival_time = []
plane_arrival = 0
time_for_landing = np.array(random.choices([15, 45, 75, 105, 135, 165, 195, 225, 255, 285], weights=[0, 8, 16.5, 30.5, 20.5, 12.5, 5, 4, 3, 0], k=amount_of_planes))
waiting_time = []
for i in range(amount_of_planes):
plane_number.append(i)
waiting_time.append(i)
#Take a random value from a uniform spread probability from 0 to 1
n = random.random()
#Generate time between plane arrivals by using the reverse cdf method
time_between_planes = -math.log(1.0 - n) / 0.00462962962
plane_arrival_time.append(time_between_planes)
#Add the inter-event time to the running sum to get the next absolute event time
plane_arrival = plane_arrival + time_between_planes
plane_arrival_time.append(plane_arrival)
#My attemt at determining waiting time
done_with_landing = 0
if done_with_landing > plane_arrival:
plane_waiting_time = done_with_landing - plane_arrival
else:
plane_waiting_time = 0
done_with_landing = plane_arrival + plane_waiting_time + time_for_landing[i]
print(plane_arrival, done_with_landing, abs(plane_waiting_time), time_for_landing[i])
待ち時間が必要な理由は、このシミュレートされた空港が別の滑走路を建設することが理にかなっているのかどうかを議論するためです. このプロジェクトでは、他の飛行機が滑走路から離陸することは気にしません。