if len( sys.argv ) != 2: print 'Wrong Number of Arguments you sent', sys.argv , " .. just interval" sys.exit() interval = int( sys.argv[ 1 ] ) common.setInterval(interval) simulationData = [] arrivalRate = 5 poissonGen.setArrivalRate( arrivalRate ) simulationInterval = poissonGen.simulateInterval() # <---- FCFS ----> #print fcfs.simulateFCFS( simulationInterval ) print fcfs_AC.simulate( simulationInterval ) # <---- EDF ----> #print edf.simulateEDF( simulationInterval ) #print edf_AC_Basic.simulateEDFACB( simulationInterval ) #print edf_AC_Pro.simulateEDFPro( simulationInterval ) # <---- LLFSimple ----> # print llfSimple.simulateLLFSimple( simulationInterval ) # print llfSimple_AC_Basic.simulateLLFSimpleACB( simulationInterval ) # print llfSimple_AC_Pro.simulateLLFSimpleACPro( simulationInterval )
def simulateArrivalChargePorts(): arrivalRate = 3 initialChargePorts = 1 arrivalRateStep = 0 chargePortStep = 5 chargePortCycles = 5 arrivalRateCycles = 1 numRunsPerIteration = 3 heatMap = [] # gen 1st row of heatMap # for now just write the name of the algorithm in by hand for cell (0,0) row1 = ["DSAC"] numChargePorts = initialChargePorts for a in range(1, chargePortCycles + 1): row1.append(numChargePorts) numChargePorts += chargePortStep heatMap.append(row1) for i in range(arrivalRateCycles): poissonGen.setArrivalRate(arrivalRate) numChargePorts = initialChargePorts heatMapRow = [arrivalRate] for j in range(chargePortCycles): chargePorts.setNumChargePorts(numChargePorts) averageProfit = 0 for k in range(numRunsPerIteration): gc.collect() # print "--------------------------" simulationInterval = poissonGen.simulateInterval() # test one algorithm at a time singleTestData = dsac.simulate(simulationInterval) # increment profit in spot averageProfit += singleTestData[0] # get average averageProfit /= (1.0 * numRunsPerIteration) heatMapRow.append(averageProfit) numChargePorts += chargePortStep heatMap.append(heatMapRow) arrivalRate += arrivalRateStep return heatMap
def simulateArrivalChargePorts(): arrivalRate = 3 initialChargePorts = 1 arrivalRateStep = 0 chargePortStep = 5 chargePortCycles = 5 arrivalRateCycles = 1 numRunsPerIteration = 3 heatMap = [ ] # gen 1st row of heatMap # for now just write the name of the algorithm in by hand for cell (0,0) row1 = [ "DSAC" ] numChargePorts = initialChargePorts for a in range( 1, chargePortCycles + 1 ): row1.append( numChargePorts ) numChargePorts += chargePortStep heatMap.append( row1 ) for i in range( arrivalRateCycles ): poissonGen.setArrivalRate( arrivalRate ) numChargePorts = initialChargePorts heatMapRow = [ arrivalRate ] for j in range( chargePortCycles ): chargePorts.setNumChargePorts( numChargePorts ) averageProfit = 0 for k in range( numRunsPerIteration ): gc.collect() # print "--------------------------" simulationInterval = poissonGen.simulateInterval() # test one algorithm at a time singleTestData = dsac.simulate( simulationInterval ) # increment profit in spot averageProfit += singleTestData[ 0 ] # get average averageProfit /= ( 1.0 * numRunsPerIteration ) heatMapRow.append( averageProfit ) numChargePorts += chargePortStep heatMap.append( heatMapRow ) arrivalRate += arrivalRateStep return heatMap
for i in range(numIterations): averageRates = [0] * 11 # a spot for every algo averageRatesWithDeclined = [0] * 11 averageProfits = [0] * 11 averageElapsedTimes = [0] * 11 for k in range(numRunsPerIteration): gc.collect() #print"--------------------------" poissonGen.setArrivalRate(arrivalRate) simulationInterval = poissonGen.simulateInterval() # don't want a simulation with no cars while common.numberOfVehiclesInSimulation == 0: simulationInterval = poissonGen.simulateInterval() # common.vehicleIdsIn2DList( simulationInterval ) #----------------fcfs---------------- fcfsData = fcfs.simulate(simulationInterval) fcfsACData = fcfs_AC.simulate(simulationInterval) #----------------edf---------------- edfData = edf.simulate(simulationInterval)