def simulateBusDCChargingStationIncome(numberOfDCCharger, numberOfBuses): chargerCost = 15000 * numberOfDCCharger # chargerCost = 0 busChargingStation = DCChargingStations(numberOfDCCharger) busFleet = [] for i in range(numberOfBuses): newBus = Bus() newBus.useSwapping = 0 busFleet.append(newBus) time = 0 busIncome = [] busChargerIncome = [] while time < 24 * 60 * 30 * 6: todayBusIncome = 0 tempBusFleet = [] for runningBus in busFleet: runningBus.decideChargeMode(time) if runningBus.chargingMode == 1: busChargingStation.addCharge(runningBus) else: runningBus.getTravelSpeed(time) tempBusFleet.append(runningBus) busFleet = tempBusFleet tempChargingVehicles = [] for chargingBus in busChargingStation.chargingVehicles: chargingBus.decideChargeMode(time) if chargingBus.chargingMode == 0: chargingBus.getTravelSpeed(time) busFleet.append(chargingBus) else: chargingBus.charge(time, 0, busChargingStation.chargeSpeed) tempChargingVehicles.append(chargingBus) busChargingStation.chargingVehicles = tempChargingVehicles while busChargingStation.numberOfStations - len( busChargingStation.chargingVehicles) > 0: if len(busChargingStation.pendingVehicles) > 0: newChargeBus = busChargingStation.pendingVehicles.pop(0) newChargeBus.charge(time, 0, busChargingStation.chargeSpeed) busChargingStation.chargingVehicles.append(newChargeBus) else: break busChargingStation.charge() for bus in busFleet + busChargingStation.chargingVehicles + busChargingStation.pendingVehicles: todayBusIncome += bus.income busIncome.append([ time, todayBusIncome, len(busFleet), len(busChargingStation.chargingVehicles), len(busChargingStation.pendingVehicles) ]) busChargerIncome.append([time, busChargingStation.income]) time += 1 return busIncome[-1][1], busChargerIncome[-1][1] - chargerCost
"font.serif": ["Times", "Palatino", "serif"], 'grid.color': '.9', 'grid.linestyle': '--', }) taxiChargingStation = DCChargingStations(5) taxiFleet = [] for i in range(100): newTaxi = Taxi() newTaxi.useSwapping = 0 taxiFleet.append(newTaxi) busChargingStation = DCChargingStations(5) busFleet = [] for i in range(20): newBus = Bus() newBus.useSwapping = 0 busFleet.append(newBus) time = 0 taxiIncome = [] busIncome = [] taxiChargerIncome = [] busChargerIncome = [] while time < 24 * 60 * 7: tempTaxiFleet = [] todayTaxiIncome = 0 todayBusIncome = 0 for runningTaxi in taxiFleet: runningTaxi.decideChargeMode(time) if runningTaxi.chargingMode == 1:
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 simulateSwapperIncome(numberOfSlot, numberOfTaxis, numberOfBuses): swapperInitCost = 2.5 * (10**6) swapperSlotCost = 1000 * (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) busSwappingStation = BatterySwappingStation(numberOfSlot, 324) busFleet = [] for i in range(numberOfBuses): newBus = Bus() newBus.useSwapping = 1 busFleet.append(newBus) time = 0 taxiIncome = [] busIncome = [] taxiSwapperIncome = [] busSwapperIncome = [] while time < 24 * 60 * 7: tempTaxiFleet = [] todayTaxiIncome = 0 todayBusIncome = 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 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 taxi in taxiFleet + taxiSwappingStation.swappingVehicles + taxiSwappingStation.pendingVehicles: todayTaxiIncome += taxi.income for bus in busFleet + busSwappingStation.swappingVehicles + busSwappingStation.pendingVehicles: todayBusIncome += bus.income taxiIncome.append([time, todayTaxiIncome, len(taxiFleet), len(taxiSwappingStation.swappingVehicles), len(taxiSwappingStation.pendingVehicles), \ len(taxiFleet) + len(taxiSwappingStation.swappingVehicles) + len( taxiSwappingStation.pendingVehicles)]) busIncome.append([time, todayBusIncome, len(busFleet), len(busSwappingStation.swappingVehicles), len(busSwappingStation.pendingVehicles), \ len(busFleet) + len(busSwappingStation.swappingVehicles) + len( busSwappingStation.pendingVehicles)]) taxiSwapperIncome.append([time, taxiSwappingStation.income]) busSwapperIncome.append([time, busSwappingStation.income]) time += 1 return taxiIncome[-1][1], busIncome[-1][1], taxiSwapperIncome[-1][ 1] - totalSwapperCost, busSwapperIncome[-1][1] - 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