Skip to content

Commit 45e99b2

Browse files
committed
trying to refcator only_one_gen_alloc, but currently doesnt pass test_uniform_sampling_cancel
1 parent 14c8b1f commit 45e99b2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

libensemble/alloc_funcs/only_one_gen_alloc.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,26 @@ def ensure_one_active_gen(W, H, sim_specs, gen_specs, alloc_specs, persis_info,
2121
gen_flag = True
2222
gen_in = gen_specs.get("in", [])
2323

24-
for wid in support.avail_worker_ids():
25-
persis_info = support.skip_canceled_points(H, persis_info)
24+
persis_info = support.skip_canceled_points(H, persis_info)
2625

27-
if persis_info["next_to_give"] < len(H):
26+
if persis_info["next_to_give"] < len(H):
27+
for wid in support.avail_worker_ids(gen_workers=False):
2828
try:
2929
Work[wid] = support.sim_work(wid, H, sim_specs["in"], [persis_info["next_to_give"]], [])
3030
except InsufficientFreeResources:
3131
break
3232
persis_info["next_to_give"] += 1
33+
if persis_info["next_to_give"] >= len(H):
34+
break
35+
36+
elif not support.test_any_gen() and gen_flag:
37+
# Give gen work
38+
return_rows = range(len(H)) if gen_in else []
39+
for wid in support.avail_worker_ids(gen_workers=True):
3340

34-
elif not support.test_any_gen() and gen_flag:
3541
if not support.all_sim_ended(H):
3642
break
3743

38-
# Give gen work
39-
return_rows = range(len(H)) if gen_in else []
4044
try:
4145
Work[wid] = support.gen_work(wid, gen_in, return_rows, persis_info.get(wid))
4246
except InsufficientFreeResources:

0 commit comments

Comments
 (0)