Exemple #1
0
print("tc2:")
print(busIncomeDataFrame[(busIncomeDataFrame["time"] %
                          (24 * 60) > 2 * 60) & (busIncomeDataFrame["time"] %
                                                 (24 * 60) < 5 * 60)].sum() /
      60 / 7 / 20)
print("tc3:")
print(busIncomeDataFrame[(busIncomeDataFrame["time"] %
                          (24 * 60) > 5 * 60) & (busIncomeDataFrame["time"] %
                                                 (24 * 60) < 18 * 60)].sum() /
      60 / 7 / 20)
print("tc4:")
print(busIncomeDataFrame[(busIncomeDataFrame["time"] % (24 * 60) > 21 * 60) |
                         (busIncomeDataFrame["time"] %
                          (24 * 60) < 2 * 60)].sum() / 60 / 7 / 20)

taxiSwappingStation = BatterySwappingStation(5, 30)
taxiFleet = []
for i in range(100):
    newTaxi = Taxi()
    newTaxi.useSwapping = 1
    taxiFleet.append(newTaxi)

busSwappingStation = BatterySwappingStation(5, 324)
busFleet = []
for i in range(20):
    newBus = Bus()
    newBus.useSwapping = 1
    busFleet.append(newBus)

time = 0
taxiIncome = []
Exemple #2
0
def simulateTaxiSwapperIncome(numberOfSlot, numberOfTaxis):
    swapperInitCost = 2.5 * (10**6)
    swapperSlotCost = 5000 * (numberOfSlot - 1)
    totalSwapperCost = swapperInitCost + swapperSlotCost
    # totalSwapperCost = 0
    taxiSwappingStation = BatterySwappingStation(numberOfSlot, 30)
    taxiFleet = []
    for i in range(numberOfTaxis):
        newTaxi = Taxi()
        newTaxi.useSwapping = 1
        taxiFleet.append(newTaxi)

    time = 0
    taxiIncome = []
    taxiSwapperIncome = []
    while time < 24 * 60 * 30 * 6:
        tempTaxiFleet = []
        todayTaxiIncome = 0
        for runningTaxi in taxiFleet:
            runningTaxi.decideChargeMode(time)
            if runningTaxi.chargingMode == 1:
                result = taxiSwappingStation.addVehicle(runningTaxi)
                if result > 0:
                    runningTaxi.charge(time, result, 0)
                    # print("get into queue:" + str(time))
                    taxiSwappingStation.swappingVehicles.append(runningTaxi)
            else:
                runningTaxi.getTravelSpeed(time)
                tempTaxiFleet.append(runningTaxi)
        taxiFleet = tempTaxiFleet

        tempSwappingVehicles = []
        for swappingTaxi in taxiSwappingStation.swappingVehicles:
            swappingTaxi.charge(time, 0, 0)
            if swappingTaxi.chargingMode == 0:
                swappingTaxi.getTravelSpeed(time)
                taxiFleet.append(swappingTaxi)
            else:
                tempSwappingVehicles.append(swappingTaxi)
        taxiSwappingStation.swappingVehicles = tempSwappingVehicles

        while len(taxiSwappingStation.pendingVehicles):
            if len(taxiSwappingStation.swappingVehicles
                   ) < taxiSwappingStation.numberOfSlot:
                newTaxi = taxiSwappingStation.pendingVehicles.pop(0)
                result = taxiSwappingStation.swap(newTaxi.remainingBatterykWh)
                newTaxi.charge(time, result, 0)
                # print("bump from pending to swap:" + str(time))
                taxiSwappingStation.swappingVehicles.append(newTaxi)
            else:
                break

        for taxi in taxiFleet + taxiSwappingStation.swappingVehicles + taxiSwappingStation.pendingVehicles:
            todayTaxiIncome += taxi.income
        taxiIncome.append([time, todayTaxiIncome, len(taxiFleet), len(taxiSwappingStation.swappingVehicles),
                           len(taxiSwappingStation.pendingVehicles), \
                           len(taxiFleet) + len(taxiSwappingStation.swappingVehicles) + len(
                               taxiSwappingStation.pendingVehicles)])

        taxiSwapperIncome.append([time, taxiSwappingStation.income])

        time += 1
    return taxiIncome[-1][1], taxiSwapperIncome[-1][1] - totalSwapperCost
Exemple #3
0
def simulateBusSwapperIncome(numberOfSlot, numberOfBuses, batteryCapacity):
    swapperInitCost = 2.5 * (10**6)
    swapperSlotCost = 5000 * (numberOfSlot - 1)
    totalSwapperCost = swapperInitCost + swapperSlotCost
    totalSwapperCost = 0

    busSwappingStation = BatterySwappingStation(numberOfSlot, batteryCapacity)
    busFleet = []
    for i in range(numberOfBuses):
        newBus = Bus()
        newBus.useSwapping = 1
        newBus.batteryCapacity = batteryCapacity
        newBus.remainingBatterykWh = batteryCapacity
        newBus.maxTrip = batteryCapacity / newBus.travelConsumption * 0.9
        busFleet.append(newBus)

    time = 0
    busIncome = []
    busSwapperIncome = []
    while time < 24 * 60 * 30:
        todayBusIncome = 0
        tempBusFleet = []
        for runningBus in busFleet:
            runningBus.decideChargeMode(time)
            if runningBus.chargingMode == 1:
                result = busSwappingStation.addVehicle(runningBus)
                if result > 0:
                    runningBus.charge(time, result, 0)
                    busSwappingStation.swappingVehicles.append(runningBus)
            else:
                runningBus.getTravelSpeed(time)
                tempBusFleet.append(runningBus)
        busFleet = tempBusFleet

        tempSwappingVehicles = []
        for swappingBus in busSwappingStation.swappingVehicles:
            swappingBus.charge(time, 0, 0)
            if swappingBus.chargingMode == 0:
                swappingBus.getTravelSpeed(time)
                busFleet.append(swappingBus)
            else:
                tempSwappingVehicles.append(swappingBus)
        busSwappingStation.swappingVehicles = tempSwappingVehicles

        while len(busSwappingStation.pendingVehicles) > 0:
            if len(busSwappingStation.swappingVehicles
                   ) < busSwappingStation.numberOfSlot:
                newBus = busSwappingStation.pendingVehicles.pop(0)
                result = busSwappingStation.swap(newBus.remainingBatterykWh)
                newBus.charge(time, result, 0)
                busSwappingStation.swappingVehicles.append(newBus)
            else:
                break

        for bus in busFleet + busSwappingStation.swappingVehicles + busSwappingStation.pendingVehicles:
            todayBusIncome += bus.income

        busIncome.append([time, todayBusIncome, len(busFleet), len(busSwappingStation.swappingVehicles),
                          len(busSwappingStation.pendingVehicles), \
                          len(busFleet) + len(busSwappingStation.swappingVehicles) + len(
                              busSwappingStation.pendingVehicles)])
        busSwapperIncome.append([time, busSwappingStation.income])

        time += 1
    return busIncome[-1][1] * 6, busSwapperIncome[-1][1] * 6 - totalSwapperCost
def simulateBusSwapperIncome(numberOfSlot, numberOfBuses):
    swapperInitCost = 2.5 * (10**6)
    swapperSlotCost = 5000 * (numberOfSlot - 1)
    totalSwapperCost = swapperInitCost + swapperSlotCost
    # totalSwapperCost = 0

    busSwappingStation = BatterySwappingStation(numberOfSlot, 324)
    busFleet = []
    for i in range(numberOfBuses):
        newBus = Bus()
        newBus.useSwapping = 1
        busFleet.append(newBus)

    time = 0
    busIncome = []
    busSwapperIncome = []
    noOfSwap = 0
    paidkWh = []
    while time < 24 * 60 * 30:
        todayBusIncome = 0
        tempBusFleet = []
        for runningBus in busFleet:
            runningBus.decideChargeMode(time)
            if runningBus.chargingMode == 1:
                result = busSwappingStation.addVehicle(runningBus)
                if result > 0:
                    noOfSwap += 1
                    paidkWh.append(324 - runningBus.remainingBatterykWh)
                    runningBus.charge(time, result, 0)
                    busSwappingStation.swappingVehicles.append(runningBus)
            else:
                runningBus.getTravelSpeed(time)
                tempBusFleet.append(runningBus)
        busFleet = tempBusFleet

        tempSwappingVehicles = []
        for swappingBus in busSwappingStation.swappingVehicles:
            swappingBus.charge(time, 0, 0)
            if swappingBus.chargingMode == 0:
                swappingBus.getTravelSpeed(time)
                busFleet.append(swappingBus)
            else:
                tempSwappingVehicles.append(swappingBus)
        busSwappingStation.swappingVehicles = tempSwappingVehicles

        while len(busSwappingStation.pendingVehicles) > 0:
            if len(busSwappingStation.swappingVehicles
                   ) < busSwappingStation.numberOfSlot:
                newBus = busSwappingStation.pendingVehicles.pop(0)
                result = busSwappingStation.swap(newBus.remainingBatterykWh)
                noOfSwap += 1
                paidkWh.append(324 - newBus.remainingBatterykWh)
                newBus.charge(time, result, 0)
                busSwappingStation.swappingVehicles.append(newBus)
            else:
                break

        for bus in busFleet + busSwappingStation.swappingVehicles + busSwappingStation.pendingVehicles:
            todayBusIncome += bus.income

        busIncome.append([time, todayBusIncome, len(busFleet), len(busSwappingStation.swappingVehicles),
                          len(busSwappingStation.pendingVehicles), \
                          len(busFleet) + len(busSwappingStation.swappingVehicles) + len(
                              busSwappingStation.pendingVehicles)])
        busSwapperIncome.append([time, busSwappingStation.income])

        time += 1
    averagePaidkWh = sum(paidkWh) / len(paidkWh)
    averageChargeTime = averagePaidkWh / 6.6 * 60
    swapPerMin = noOfSwap / 30 / 60 / 24
    numberOfBattery = averageChargeTime * swapPerMin
    totalSwapperCost += 324 * 227 * numberOfBattery
    return busIncome[-1][1] * 6, busSwapperIncome[-1][
        1] * 6 - totalSwapperCost, numberOfBattery, noOfSwap