def getVehiclesSumoBasic(vehicle_count, route): vehicleList = [] vehicleTypes = VehicleTypes() for i in range(vehicle_count): vehicleType , _ = vehicleTypes.sample() #vehicle = Vehicle(vehicleType, route, int(9920*random.random()), SimpleLaneMovement(), int(30*random.random())) vehicle = Vehicle(vehicleType, route, int(9920*random.random()), nnBasedMovement(), int(30*random.random()), -1, i, vehicleTypes.color[vehicleType]) #vehicle = Vehicle(vehicleType, route, int(9920*random.random()), nnBasedMovement_xy(), int(30*random.random()), -1, i, vehicleTypes.color[vehicleType]) vehicleList.append(vehicle) return vehicleList
def getMixedVehicles(vehicle_count, route, prob): vehicleList = [] vehicleTypes = VehicleTypes() for i in range(vehicle_count): #vehicleType , _ = vehicleTypes.sample() vehicleType = "CAR" #vehicle = Vehicle(vehicleType, route, int(9920*random.random()), SimpleLaneMovement(), int(30*random.random())) if random.random() < prob: vehicle = Vehicle(vehicleType, route, int(9920*random.random()), nnBasedMovement(), int(30*random.random()), -1, i, (0,0,255)) else: vehicle = Vehicle(vehicleType, route, int(9920*random.random()), SimpleLaneMovement(), int(12), -1, i, (255,0,0)) vehicleList.append(vehicle) return vehicleList
def getVehiclesFromFileReal(fileName, route): vehicleList = [] vehicleTypes = VehicleTypes() vehicleMover = nnBasedMovement() for i, line in enumerate(open(fileName)): if line[0] == 'n': continue vehicleType = vehicleTypes.getTypeFromC(line[0]) vehicle = Vehicle(vehicleType, route, i, vehicleMover, int(30 * random.random()), int(line[1]), i, vehicleTypes.color[vehicleType]) vehicleList.append(vehicle) print len(vehicleList) return vehicleList