123456789101112131415161718192021222324252627282930313233343536373839 |
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- from entity import *
- def create_data():
- # 区域内当前司机数目
- driver_num = np.random.randint(3,100)
- # 区域内当前订单数
- order_num = np.random.randint(3,100)
- # if driver_num > order_num:
- # # 价值高的优先
- # pass
- # elif driver_num <= order_num:
- # # 取前order_num个价值高的司机,进行二分图的KM算法求解
- # pass
- # 司机 与 乘客 的距离
- distances = []
- for i in range(driver_num):
- distance = np.random.normal(3,1,order_num)
- # print(distance)
- distances.append(distance)
- # plt.plot(sorted(distance))
- # plt.show()
- # 行程距离
- travel_distance = np.random.normal(15,6,order_num)
- # 订单的价格
- rand = np.random.uniform(0.75,0.95,order_num)
- price = travel_distance * rand
- price = [2 * (i-8) + 10 if i>8 else 10 for i in price]
- price = np.array(price) * np.random.uniform(0.88,0.94,order_num)
- # print(price)
- return list(distances),list(travel_distance),list(price)
- if __name__ == '__main__':
- create_data()
|