Exemplo n.º 1
0
def runThread(jobInterval, fpgaSleepTime, numEpisodes, results, finished):
    exp = SimpleSimulation(numDevices=4, maxJobs=maxJobs)
    exp.setFpgaIdleSleep(fpgaSleepTime)
    exp.scenario.setInterval(jobInterval)
    print('interval', exp.scenario.timeInterval.mean)
    exp.setBatterySize(1e1)

    try:
        for i in range(numEpisodes):
            # exp.simulateTime(10)
            exp.simulateEpisode()
            results.put([
                "FPGA Idle Sleep {} Interval {}".format(
                    fpgaSleepTime, jobInterval), i,
                exp.getCurrentTime()
            ])
    except:
        traceback.print_exc(file=sys.stdout)
        print(
            jobInterval,
            fpgaSleepTime,
        )
        print("Error in experiment:", jobInterval, fpgaSleepTime,
              exp.getCurrentTime())

    finished.put(True)
Exemplo n.º 2
0
def runThread(agent, numEpisodes, centralised, results, finished):
    exp = SimpleSimulation(numDevices=2,
                           maxJobs=maxjobs,
                           agentClass=agent,
                           tasks=[HARD],
                           systemStateClass=minimalSystemState,
                           scenarioTemplate=REGULAR_SCENARIO_ROUND_ROBIN,
                           centralisedLearning=centralised)
    # exp.scenario.setInterval(1)
    exp.setBatterySize(1e-1)
    exp.setFpgaIdleSleep(1e-3)

    e = None
    try:
        for e in range(numEpisodes):
            debug.infoEnabled = False
            exp.simulateEpisode(e)

            # results.put(["%s %s" % (exp.devices[0].agent.__name__, "Centralised" if centralised else "Decentralised"), e, exp.numFinishedJobs])
            results.put([
                "%s %s" % (exp.devices[0].agent.__name__,
                           "Centralised" if centralised else "Decentralised"),
                e,
                exp.getCurrentTime()
            ])
    except:
        debug.printCache()
        traceback.print_exc(file=sys.stdout)
        print(agent, e)
        print("Error in experiment ̰:", exp.time)
        sys.exit(0)

    finished.put(True)
Exemplo n.º 3
0
def runThread(agent, numEpisodes, results, finished):
    exp = SimpleSimulation(numDevices=16, maxJobs=150, agentClass=agent, tasks=[HARD])
    exp.scenario.setInterval(1)
    exp.setBatterySize(1e0)

    e = None
    try:
        for e in range(numEpisodes):
            debug.infoEnabled = False
            exp.simulateEpisode()

            results.put(["Agent %s" % agent.__name__, e, exp.getCurrentTime()])
    except:
        debug.printCache()
        traceback.print_exc(file=sys.stdout)
        print(agent, e)
        print("Error in experiment ̰:", exp.time)
        sys.exit(0)

    finished.put(True)
    # assert simulationResults.learningHistory is not None
    # histories.put(simulationResults.learningHistory)
    # print("\nsaving history", simulationResults.learningHistory, '\nr')

    print("forward", counters.NUM_FORWARD, "backward", counters.NUM_BACKWARD)
Exemplo n.º 4
0
def runThread(agent, numEpisodes, results, finished, histories):
    exp = SimpleSimulation(numDevices=2, maxJobs=6, agentClass=agent)
    exp.setFpgaIdleSleep(5)
    exp.setBatterySize(1e0)

    try:
        for e in range(numEpisodes):
            debug.infoEnabled = False
            exp.simulateEpisode()
            results.put(["Duration %s" % exp.sharedAgent, e, exp.getCurrentTime()])
            # results.put(["Episode reward %s" % exp.sharedAgent, e, exp.sharedAgent.episodeReward])
    except:
        debug.printCache(200)
        traceback.print_exc(file=sys.stdout)
        print(agent, e)
        print("Error in experiment ̰:", exp.time)
        sys.exit(0)

    finished.put(True)
    assert simulationResults.learningHistory is not None
    histories.put(simulationResults.learningHistory)
    print("\nsaving history", simulationResults.learningHistory, '\nr')

    print("forward", counters.NUM_FORWARD, "backward", counters.NUM_BACKWARD)

    exp.sharedAgent.printModel()
Exemplo n.º 5
0
def runThread(agent, numEpisodes, results, finished):
    # constants.CENTRALISED_LEARNING = False
    exp = SimpleSimulation(numDevices=2,
                           maxJobs=maxjobs,
                           agentClass=agent,
                           tasks=[HARD],
                           systemStateClass=minimalSystemState,
                           scenarioTemplate=REGULAR_SCENARIO_ROUND_ROBIN,
                           reconsiderBatches=False,
                           centralisedLearning=False)
    # exp.scenario.setInterval(1)
    exp.setFpgaIdleSleep(1e-3)
    exp.setBatterySize(1e-1)

    e = None
    try:
        for e in range(numEpisodes):
            debug.infoEnabled = False
            exp.simulateEpisode(e)

            results.put([
                "Job %s" % exp.devices[0].agent.__name__, e,
                exp.numFinishedJobs
            ])
            results.put([
                "Duration %s" % exp.devices[0].agent.__name__, e,
                exp.getCurrentTime()
            ])
    except:
        debug.printCache()
        traceback.print_exc(file=sys.stdout)
        print(agent, e)
        print("Error in experiment ̰:", exp.time)
        sys.exit(0)

    finished.put(True)
    # assert simulationResults.learningHistory is not None
    # histories.put(simulationResults.learningHistory)
    # print("\nsaving history", simulationResults.learningHistory, '\nr')

    print("forward", counters.NUM_FORWARD, "backward", counters.NUM_BACKWARD)
    if exp.sharedAgent.__class__ == minimalTableAgent:
        plotting.plotModel(exp.sharedAgent, drawLabels=False)
Exemplo n.º 6
0
def runThread(jobInterval, fpgaSleepTime, numEpisodes, results, finished):
    exp = SimpleSimulation(numDevices=4)
    exp.scenario.setInterval(1)
    exp.setFpgaIdleSleep(fpgaSleepTime)
    exp.setBatterySize(1e1)

    try:
        for i in range(numEpisodes):
            # exp.simulateTime(10)
            exp.simulateEpisode()
    except:
        traceback.print_exc(file=sys.stdout)
        print(
            jobInterval,
            fpgaSleepTime,
        )
        print("Error in experiment:", jobInterval, fpgaSleepTime,
              exp.getCurrentTime())

    results.put([
        "FPGA Idle Sleep {}".format(fpgaSleepTime), jobInterval,
        np.sum(exp.totalDevicesEnergy()) / exp.getNumDevices()
    ])
    finished.put(True)