Skip to content

Commit 0b12af2

Browse files
committed
refactor start_fd_persistent
1 parent 4aa386f commit 0b12af2

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

libensemble/alloc_funcs/start_fd_persistent.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,21 @@ def finite_diff_alloc(W, H, sim_specs, gen_specs, alloc_specs, persis_info, libE
4949
)
5050

5151
points_to_evaluate = ~H["sim_started"] & ~H["cancel_requested"]
52-
for wid in support.avail_worker_ids(persistent=False):
53-
if np.any(points_to_evaluate):
52+
if np.any(points_to_evaluate):
53+
for wid in support.avail_worker_ids(persistent=False, gen_workers=False):
5454
# perform sim evaluations (if they exist in History).
5555
sim_ids_to_send = np.nonzero(points_to_evaluate)[0][0] # oldest point
5656
try:
5757
Work[wid] = support.sim_work(wid, H, sim_specs["in"], sim_ids_to_send, persis_info.get(wid))
5858
except InsufficientFreeResources:
5959
break
6060
points_to_evaluate[sim_ids_to_send] = False
61-
62-
elif gen_count == 0:
63-
# Finally, call a persistent generator as there is nothing else to do.
64-
try:
65-
Work[wid] = support.gen_work(wid, gen_specs.get("in", []), [], persis_info.get(wid), persistent=True)
66-
except InsufficientFreeResources:
61+
if not np.any(points_to_evaluate):
6762
break
68-
gen_count += 1
63+
64+
if gen_count == 0:
65+
wid = support.avail_worker_ids(persistent=False, gen_workers=True)[0]
66+
Work[wid] = support.gen_work(wid, gen_specs.get("in", []), [], persis_info.get(wid), persistent=True)
67+
gen_count += 1
6968

7069
return Work, persis_info, 0

0 commit comments

Comments
 (0)