def testSimpleThreadWorkerPreemption(threadWorker): """Testing routine.""" print( '<<<<<<<<<<<<<<<<<<<< Testing Preemption on {0} >>>>>>>>>>>>>>>>>>>'. format(threadWorker.__name__)) samples = [0.0, 0.1] controller = PreemptibleThreadController() strategy = FixedSampleStrategy(samples) strategy = CheckWorkerStrategy(controller, strategy) controller.strategy = strategy add_monitor(controller, 1) for threadID in range(4): """ Worker 0 will be pre-empted as soon as it is launched. Worker 1 will be pre-empted as soon as an eval is launched. Workers 2 and 3 will execute the requests. """ controller.launch_worker(threadWorker(threadID, controller, objective)) result = controller.run() if result.value == 1: print("Test Passed") else: print("Test Failed:") print("Final: {0:.3e} @ {1}".format(result.value, result.params))
def main(): "Testing routine." logging.basicConfig(format="%(name)-18s: %(levelname)-8s %(message)s", level=logging.INFO) samples = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5] controller = SimTeamController(objective, delay, 5) strategy = FixedSampleStrategy(samples) strategy = CheckWorkerStrategy(controller, strategy) controller.strategy = strategy add_monitor(controller, 1) result = controller.run() print("Final: {0:.3e} @ {1}".format(result.value, result.params))
def main(): "Testing routine." logging.basicConfig(format="%(name)-18s: %(levelname)-8s %(message)s", level=logging.INFO) samples = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5] controller = SimTeamController(objective, delay, 5) strategy = FixedSampleStrategy(samples) strategy = CheckWorkerStrategy(controller, strategy) controller.strategy = strategy add_monitor(controller, 1) result = controller.run() print("Final: {0:.3e} @ {1}".format(result.value, result.params))
def main(): "Testing routine." logging.basicConfig(format="%(name)-18s: %(levelname)-8s %(message)s", level=logging.INFO) samples = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5] controller = ThreadController() strategy = FixedSampleStrategy(samples) strategy = CheckWorkerStrategy(controller, strategy) controller.strategy = strategy add_monitor(controller, 1) for _ in range(5): controller.launch_worker(BasicWorkerThread(controller, objective)) result = controller.run() print(("Final: {0:.3e} @ {1}".format(result.value, result.params)))
def main(): "Testing routine." logging.basicConfig(format="%(name)-18s: %(levelname)-8s %(message)s", level=logging.INFO) samples = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5] controller = ThreadController() strategy = FixedSampleStrategy(samples) strategy = CheckWorkerStrategy(controller, strategy) controller.strategy = strategy add_monitor(controller, 1) for _ in range(5): controller.launch_worker(BasicWorkerThread(controller, objective)) result = controller.run() print("Final: {0:.3e} @ {1}".format(result.value, result.params))
def main(): "Testing routine." logging.basicConfig(format="%(name)-18s: %(levelname)-8s %(message)s", level=logging.INFO) samples = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5] controller = SimTeamController(objective, delay, 5) strategy = FixedSampleStrategy(samples) strategy = CheckWorkerStrategy(controller, strategy) strategy = InputStrategy(controller, strategy) controller.strategy = strategy add_monitor(controller, 1) def shutdown(): logging.info("Initiating external shutdown") strategy.terminate() controller.add_timer(7.0, shutdown) result = controller.run() print(("Final: {0:.3e} @ {1}".format(result.value, result.params)))