def run(numEpisodes): print("starting experiment") processes = list() # sim.simulations.constants.MINIMUM_BATCH = 1e7 # offloadingOptions = [True, False] results = multiprocessing.Queue() finished = multiprocessing.Queue() # experiments = multiprocessing.Queue() # REPEATS = 1 # localConstants.REPEATS = 10 numEpisodes = int(numEpisodes) agentsToTest = [minimalTableAgent, lazyTableAgent, randomAgent] # localAgent] for agent in agentsToTest: # [minimalAgent, lazyAgent]: for _ in range(localConstants.REPEATS): processes.append( multiprocessing.Process(target=runThread, args=(agent, numEpisodes, results, finished))) results = executeMulti(processes, results, finished, numResults=len(agentsToTest) * numEpisodes * localConstants.REPEATS) # plotting.plotMultiWithErrors("Number of Jobs", results=results, ylabel="Job #", xlabel="Episode #") # , save=True) plotting.plotMulti("Sleep Time", results=results, ylabel="Time Asleep %", xlabel="Episode #") # , save=True)
def run(numEpisodes): print("starting experiment") processes = list() # sim.simulations.constants.MINIMUM_BATCH = 1e7 # offloadingOptions = [True, False] results = multiprocessing.Queue() finished = multiprocessing.Queue() # experiments = multiprocessing.Queue() # REPEATS = 1 numDevices = 2 # localConstants.REPEATS = 10 numEpisodes = int(numEpisodes) # agentsToTest = [minimalTableAgent] #, lazyTableAgent] # tasks = [[EASY], [EASY, HARD]] taskOptions = [EASY, HARD] # taskOptions = [HARD, ALTERNATIVE] for t in range(len(taskOptions)): taskOptions[t].identifier = t print("task", taskOptions[t], taskOptions[t].identifier) # for agent in agentsToTest: # [minimalAgent, lazyAgent]: for _ in range(localConstants.REPEATS): # for taskOptions in tasks: processes.append(multiprocessing.Process(target=runThread, args=(minimalTableAgent, numEpisodes, numDevices, taskOptions, results, finished))) results = executeMulti(processes, results, finished, numResults=len(processes) * numEpisodes * numDevices, assembly=experiment.assembleResultsBasic) # plotting.plotMultiWithErrors("Number of Jobs", results=results, ylabel="Job #", xlabel="Episode #") # , save=True) plotting.plotMulti("Number of Jobs", results=results, ylabel="EASY/HARD", xlabel="Episode #") # , save=True)
def run(): print("starting experiment") debug.settings.enabled = False debug.settings.learnEnabled = False debug.settings.infoEnabled = False processes = list() results = multiprocessing.Queue() finished = multiprocessing.Queue() histories = multiprocessing.Queue() numDevices = 2 numTicks = int(1e1) agentsToTest = [minimalTableAgent] # , lazyAgent] for agent in agentsToTest: # [minimalAgent, lazyAgent]: for _ in range(localConstants.REPEATS): processes.append( multiprocessing.Process(target=runThread, args=(agent, numTicks, numDevices, results, finished, histories))) results = executeMulti(processes, results, finished, assembly=assembleResultsBasic, numResults=localConstants.REPEATS * numTicks * 2) plotting.plotMulti("Device Power", results=results, ylabel="Power (in mW)", xlabel="Tick #") #, ylim=[0, 0.1]) # , save=True)
# for device in exp.devices: # device.agent.printModel() finished.put(True) if __name__ == "__main__": setupMultithreading() results = multiprocessing.Queue() finished = multiprocessing.Queue() results = executeMulti([multiprocessing.Process(target=run, args=(results, finished))], results, finished, numResults=numEpisodes * numDevices) plotting.plotMulti("Competing Agents", results=results, ylabel="Job #", xlabel="Episode #") # , save=True) # <Lazy Agent> Model # energyRemaining = 0 jobsInQueue = 0 currentConfig = 0 [ 0.0015 0.0019 3.7539 ] # energyRemaining = 0 jobsInQueue = 0 currentConfig = 1 [ 25.0000 25.0000 25.0000 ] # energyRemaining = 0 jobsInQueue = 1 currentConfig = 0 [ -5.8986 0.0019 9.6867 ] # energyRemaining = 0 jobsInQueue = 1 currentConfig = 1 [ 25.0000 25.0000 25.0000 ] # energyRemaining = 0 jobsInQueue = 2 currentConfig = 0 [ -0.1022 0.0019 16.4031 ] # energyRemaining = 0 jobsInQueue = 2 currentConfig = 1 [ 25.0000 25.0000 25.0000 ] # energyRemaining = 0 jobsInQueue = 3 currentConfig = 0 [ 0.6967 25.0000 -10.7927 ] # energyRemaining = 0 jobsInQueue = 3 currentConfig = 1 [ 25.0000 25.0000 25.0000 ] # energyRemaining = 0 jobsInQueue = 4 currentConfig = 0 [ 25.0000 25.0000 25.0000 ] # energyRemaining = 0 jobsInQueue = 4 currentConfig = 1 [ 25.0000 25.0000 25.0000 ] # energyRemaining = 1 jobsInQueue = 0 currentConfig = 0 [ 0.0013 0.0019 0.0039 ] # energyRemaining = 1 jobsInQueue = 0 currentConfig = 1 [ 25.0000 25.0000 25.0000 ] # energyRemaining = 1 jobsInQueue = 1 currentConfig = 0 [ 0.0012 0.0019 0.2711 ]