Exemplo n.º 1
0
def runThread(results, finished):
    exp = SimpleSimulation(numDevices=4,
                           maxJobs=100,
                           reconsiderBatches=False,
                           systemStateClass=minimalSystemState,
                           agentClass=minimalTableAgent)
    exp.setFpgaIdleSleep(1e-2)
    exp.setBatterySize(1e6)

    try:
        for i in range(numJobs):
            exp.simulateUntilJobDone()
            results.put(
                ["Loss", exp.completedJobs, exp.sharedAgent.latestLoss, False])
            # results.put(["Reward", exp.completedJobs, exp.sharedAgent.latestReward, True])
            # results.put(["Action", exp.completedJobs, exp.sharedAgent.latestAction, True])
            # results.put(["MAE", exp.completedJobs, exp.sharedAgent.latestMAE, True])
            # results.put(["MeanQ", exp.completedJobs, exp.sharedAgent.latestMeanQ, True])
    except:
        traceback.print_exc(file=sys.stdout)
        sys.exit(0)
        print("Error in experiment:", exp.time)

    finished.put(True)
Exemplo n.º 2
0
from sim.simulations.SimpleSimulation import SimpleSimulation as Simulation

if __name__ == '__main__':
    print("testing simple simulation")
    constants.NUM_DEVICES = 2
    constants.DEFAULT_ELASTIC_NODE.BATTERY_SIZE = 1e2
    constants.OFFLOADING_POLICY = REINFORCEMENT_LEARNING
    debug.enabled = True
    debug.learnEnabled = True
    constants.DRAW_DEVICES = False
    exp = Simulation(numDevices=1,
                     systemStateClass=minimalSystemState,
                     agentClass=lazyTableAgent)

    # for i in range(10):
    # 	exp.simulateTick()

    for i in range(1):
        exp.simulateUntilJobDone()

    # exp.simulateUntilTime(50)

    # exp.simulateEpisode()

    # try:
    # 	exp.simulateEpisode()
    # 	print("Experiment done!", exp.time)
    # except Exception:
    # 	print("number of successful episodes:", exp.episodeNumber)
    # 	print(sys.exc_info())