Exemplo n.º 1
0
def test_term_test_1():
    # termination_test should be True when we want to stop

    # sh - Should separate the tests
    # Test 1
    hist, sim_specs, gen_specs, exit_criteria, al = setup.hist_setup1()
    mgr = man.Manager(hist, libE_specs, al, sim_specs, gen_specs,
                      exit_criteria)
    assert not mgr.term_test()
def test_decide_work_and_resources():

    sim_specs, gen_specs, exit_criteria = setup.make_criteria_and_specs_1()
    hist = History(al, sim_specs, gen_specs, exit_criteria, H0)

    mgr = man.Manager(hist, libE_specs, al, sim_specs, gen_specs, exit_criteria)
    W = mgr.W

    # Don't give out work when all workers are active
    W['active'] = 1
    Work, persis_info = al['alloc_f'](W, hist.H, sim_specs, gen_specs, al, {})
    assert len(Work) == 0
Exemplo n.º 3
0
def test_term_test_3():
    # Test 3.
    # Terminate because enough time has passed
    H0 = np.zeros(3,
                  dtype=[('g', float)] + [('x', float), ('priority', float)])
    hist, sim_specs, gen_specs, exit_criteria, al = setup.hist_setup2(H0_in=H0)
    mgr = man.Manager(hist, libE_specs, al, sim_specs, gen_specs,
                      exit_criteria)
    hist.index = 4
    hist.H['given_time'][0] = time.time()
    time.sleep(0.5)
    hist.given_count = 4
    assert mgr.term_test()
Exemplo n.º 4
0
def test_term_test_2():
    # Test 2 - these could also be sep - with a setup or fixture....
    # Shouldn't terminate
    hist, sim_specs, gen_specs, exit_criteria, al = setup.hist_setup2()
    mgr = man.Manager(hist, libE_specs, al, sim_specs, gen_specs,
                      exit_criteria)
    assert not mgr.term_test()
    #
    # Terminate because we've found a good 'g' value
    hist.H['g'][0] = -1
    hist.H['returned'][0] = True
    hist.index = 1
    hist.given_count = 1
    assert mgr.term_test()
    #
    # Terminate because everything has been given.
    hist.H['given'] = np.ones
    hist.given_count = len(hist.H)
    assert mgr.term_test()