Skip to content

Commit f348d56

Browse files
committed
Putting skipping of canceling points into support
1 parent 73260ef commit f348d56

5 files changed

Lines changed: 11 additions & 12 deletions

File tree

libensemble/alloc_funcs/fast_alloc.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ def give_sim_work_first(W, H, sim_specs, gen_specs, alloc_specs, persis_info, li
3333
gen_in = gen_specs.get("in", [])
3434

3535
for wid in support.avail_worker_ids():
36-
# Skip any cancelled points
37-
while persis_info["next_to_give"] < len(H) and H[persis_info["next_to_give"]]["cancel_requested"]:
38-
persis_info["next_to_give"] += 1
36+
persis_info = support.skip_canceled_points(H, persis_info)
3937

4038
# Give sim work if possible
4139
if persis_info["next_to_give"] < len(H):

libensemble/alloc_funcs/give_pregenerated_work.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def give_pregenerated_sim_work(W, H, sim_specs, gen_specs, alloc_specs, persis_i
2424
return Work, persis_info, 1
2525

2626
for i in support.avail_worker_ids():
27-
# Skip any cancelled points
28-
while persis_info["next_to_give"] < len(H) and H[persis_info["next_to_give"]]["cancel_requested"]:
29-
persis_info["next_to_give"] += 1
27+
persis_info = support.skip_canceled_points(H, persis_info)
3028

3129
# Give sim work
3230
try:

libensemble/alloc_funcs/only_one_gen_alloc.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ def ensure_one_active_gen(W, H, sim_specs, gen_specs, alloc_specs, persis_info,
2222
gen_in = gen_specs.get("in", [])
2323

2424
for wid in support.avail_worker_ids():
25-
# Skip any cancelled points
26-
while persis_info["next_to_give"] < len(H) and H[persis_info["next_to_give"]]["cancel_requested"]:
27-
persis_info["next_to_give"] += 1
25+
persis_info = support.skip_canceled_points(H, persis_info)
2826

2927
if persis_info["next_to_give"] < len(H):
3028
try:

libensemble/alloc_funcs/persistent_aposmm_alloc.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ def persistent_aposmm_alloc(W, H, sim_specs, gen_specs, alloc_specs, persis_info
5454
returned_but_not_given[point_ids] = False
5555

5656
for wid in support.avail_worker_ids(persistent=False):
57-
# Skip any cancelled points
58-
while persis_info["next_to_give"] < len(H) and H[persis_info["next_to_give"]]["cancel_requested"]:
59-
persis_info["next_to_give"] += 1
57+
persis_info = support.skip_canceled_points(H, persis_info)
6058

6159
if persis_info["next_to_give"] < len(H):
6260
# perform sim evaluations (if they exist in History).

libensemble/tools/alloc_support.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,13 @@ def points_by_priority(self, H, points_avail, batch=False):
366366
q_inds = 0
367367
return np.nonzero(points_avail)[0][q_inds]
368368

369+
def skip_canceled_points(self, H, persis_info):
370+
"""Increments the "next_to_give" field in persis_info to skip any cancelled points"""
371+
while persis_info["next_to_give"] < len(H) and H[persis_info["next_to_give"]]["cancel_requested"]:
372+
persis_info["next_to_give"] += 1
373+
374+
return persis_info
375+
369376
@staticmethod
370377
def _check_H_rows(H_rows):
371378
"""Ensure H_rows is a numpy array. If it is not, then convert if possible,

0 commit comments

Comments
 (0)