示例#1
0
def test_time_dist_fixed_add_another():
    time_dist = TimeDist('fixed', 1, unit='minutes', weight=1.0) \
        + TimeDist('fixed', 2, unit='minutes', weight=1.0) \
        + TimeDist('fixed', 3, unit='minutes', weight=1.0)
    assert time_dist.random_variate() in (timedelta(minutes=1),
                                          timedelta(minutes=2),
                                          timedelta(minutes=3))
示例#2
0
def test_time_dist_fixed_add_with_weight():
    random.seed(0)
    time_dist = TimeDist('fixed', 1, unit='minutes', weight=0.1) \
        + TimeDist('fixed', 2, unit='minutes', weight=0.9)
    counter = Counter([time_dist.random_variate() for i in range(1_000)])
    assert counter[timedelta(minutes=1)] == 114
    assert counter[timedelta(minutes=2)] == 886
示例#3
0
def test_time_dist_fixed():
    time_dist = TimeDist('fixed', 1, unit='minutes')
    assert time_dist.random_variate() == timedelta(minutes=1)
示例#4
0
time_dist = TimeDist('norm', 16.0, 1.0, unit='hours')

restaurants = list([])
for i in range(num_restaurants):
    lat, lng = random_lat_lng(51.5076, -0.0994, radius)
    restaurants.append(Restaurant(f'Restaurant {i}', lat, lng))

customers = list([])
for j in range(num_customers):
    lat, lng = random_lat_lng(lat, lng, radius)
    customers.append(Customer(f'Customer {j}', lat, lng))

sessions = list([])
for customer in customers:
    restaurant = random.choice(restaurants)
    timestamp = time_dist.random_variate()
    sessions.append(Session(customer.id, restaurant.id, timestamp))

couriers = list([])
for k in range(num_couriers):
    lat, lng = random_lat_lng(lat, lng, radius)
    couriers.append(Courier(f'Courier {k}', lat, lng))

assigner = RandomAssigner()
#assigner = MipAssigner()

metrics = [
    DeliveryTime(),
    NumberOfOrdersDelivered(),
    CourierUtilisation(),
    OrdersDeliveredPerHour(),