diff --git a/docs/data_structures/history_array.rst b/docs/data_structures/history_array.rst index 5f824d5b1..9cbba3d21 100644 --- a/docs/data_structures/history_array.rst +++ b/docs/data_structures/history_array.rst @@ -33,8 +33,8 @@ run with the generated ``x`` and ``theta`` values. For ease, the ``gen_f`` and ``sim_f`` are expected to return output as NumPy structured arrays. The output from the ``gen_f`` or ``sim_f`` functions can be the exact elements declared in the gen/sim_specs['out'] lists, or can be a -subset of these lists. (The manager's history array will update any fields given -back to it.) +subset of these lists. (The manager's history array will update any fields +returned to it.) The names of the input fields for ``gen_f`` and ``sim_f`` must exist in the manager's history array (i.e.,~ they must be output fields from ``gen_f`` or ``sim_f`` or @@ -57,12 +57,13 @@ The reserved boolean field ``cancel_requested`` can also be set in a user function to request that libEnsemble cancels evaluation of the point. The remaining reserved fields are protected (populated by libEnsemble), and -store information about each entry. These include boolean fields for the current -scheduling status of the point (``given`` out for evaluation, ``returned`` from -evaluation, and ``given_back`` to the generator). Timing fields give the time -(since the epoch) corresponding to each state, and when the point was generated. -Other protected fields include the worker IDs on which points were generated or -evaluated. +store information about each entry. These include boolean fields for the +current scheduling status of the point (``sim_started`` when the sim evaluation +has started out, ``sim_ended`` when sim evaluation has completed, and +``gen_informed`` when the sim output has been passed back to the generator). +Timing fields give the time (since the epoch) corresponding to each state, and +when the point was generated. Other protected fields include the worker IDs on +which points were generated or evaluated. The user fields and the reserved fields together make up the final history array returned by libEnsemble. @@ -82,37 +83,27 @@ The full list of these reserved fields is given below. :*Protected fields*: -* ``given`` [bool]: True if this ``gen_f`` output been given to a libEnsemble - worker to be evaluated by a ``sim_f``. +``gen_worker`` [int]: Worker that generated this entry -* ``given_time`` [float]: Time this entry - was *first* given to a worker to be evaluated by a ``sim_f``. +``gen_started_time`` [ float]: Time gen_worker was initiated that produced this entry -* ``last_given_time`` [float]: Time this entry - was *last* given to a worker to be evaluated by a ``sim_f``. +``gen_ended_time`` [ float]: Time gen_worker requested this entry -* ``returned`` [bool]: True if this entry has been evaluated by a ``sim_f``. +``sim_worker`` [int]: Worker that did (or is doing) the sim evaluation for this entry -* ``returned_time`` [float]: Time this entry was *last* returned from a ``sim_f``. +``sim_started`` [bool]: True if entry was given to sim_worker for sim evaluation -* ``given_back`` [bool]: True if this ``gen_f`` output been given back to a ``gen_f`` - worker after being returned from evaluation. +``sim_started_time`` [float]: Time entry was given to sim_worker for a sim evaluation -.. * ``given_back_time`` [float]: Time this entry -.. was *first* given back to a ``gen_f`` worker. +``sim_ended`` [bool]: True if entry's sim evaluation completed -* ``last_given_back_time`` [float]: Time this entry - was *last* given back to a ``gen_f`` worker. +``sim_ended_time`` [float]: Time entry's sim evaluation completed -* ``sim_worker`` [int]: libEnsemble worker that performed the ``sim_f`` evaluation. +``gen_informed`` [bool]: True if gen_worker was informed about the sim evaluation of this entry -* ``gen_worker`` [int]: libEnsemble worker that generated this entry. +``gen_informed_time`` [float]: Time gen_worker was informed about the sim evaluation of this entry -* ``gen_time`` [float]: Time this entry was put into ``H`` by the manager. - -* ``last_gen_time`` [float]: Time this entry was last requested by a ``gen_f``. - -* ``kill_sent`` [bool]: True if a kill signal has been sent to the worker evaluating this entry. +``kill_sent`` [bool]: True if a kill signal was sent to worker for this entry Other than ``'sim_id'`` and ``cancel_requested``, reserved fields cannot be overwritten by user functions unless ``libE_specs['safe_mode']`` is set to ``False``. @@ -128,7 +119,7 @@ Example workflow updating history array The history array is initialized using the libEnsemble reserved field and the user-provided ``gen_specs['out']`` and ``sim_specs['out']`` entries. In the figure below, only the -reserved fields: ``sim_id``, ``given``, and ``returned`` are shown for brevity. +reserved fields: ``sim_id``, ``sim_started``, and ``sim_ended`` are shown for brevity. .. figure:: ../images/history_init.png :scale: 40 diff --git a/docs/function_guides/allocator.rst b/docs/function_guides/allocator.rst index 7b3fce5e6..9e790cf69 100644 --- a/docs/function_guides/allocator.rst +++ b/docs/function_guides/allocator.rst @@ -96,9 +96,9 @@ routine can be found in ``libE_info``, passed into the allocation function:: libE_info = {'exit_criteria': dict, # Criteria for ending routine 'elapsed_time': float, # Time elapsed since start of routine 'manager_kill_canceled_sims': bool, # True if manager is to send kills to cancelled simulations - 'given_count': int, # Total number of points given for simulation function evaluation - 'returned_count': int, # Total number of points returned from simulation function evaluations - 'given_back_count': int, # Total number of evaluated points given back to a generator function + 'sim_started_count': int, # Total number of points given for simulation function evaluation + 'sim_ended_count': int, # Total number of points returned from simulation function evaluations + 'gen_informed_count': int, # Total number of evaluated points given back to a generator function 'sim_max_given': bool, # True if `sim_max` simulations have been given out to workers 'use_resource_sets': bool} # True if num_resource_sets has been explicitly set. @@ -113,7 +113,7 @@ allocation function and detect impending timeouts, then pack up cleanup work req or mark points for cancellation. The remaining values above are useful for efficient filtering of H values -(e.g. ``returned_count``), saves a filtering an entire column of H. +(e.g. ``sim_ended_count``), saves a filtering an entire column of H. .. note:: An error occurs when the ``alloc_f`` returns nothing while all workers are idle diff --git a/docs/tutorials/calib_cancel_tutorial.rst b/docs/tutorials/calib_cancel_tutorial.rst index 613d2c351..9a00bb907 100644 --- a/docs/tutorials/calib_cancel_tutorial.rst +++ b/docs/tutorials/calib_cancel_tutorial.rst @@ -186,9 +186,9 @@ prepared for irregular sending /receiving of data. .. Between routines to call the allocation function and distribute allocated work .. to each Worker, the Manager selects points from the History array that are: .. -.. 1) Marked as ``'given'`` by the allocation function +.. 1) Marked as ``'sim_started'`` by the allocation function .. 2) Marked with ``'cancel_requested'`` by the generator -.. 3) *Not* been marked as ``'returned'`` by the Manager +.. 3) *Not* been marked as ``'sim_ended'`` by the Manager .. 4) *Not* been marked with ``'kill_sent'`` by the Manager .. .. If any points match these characteristics, the Workers that are processing these @@ -198,7 +198,7 @@ prepared for irregular sending /receiving of data. .. function calls, any points in the Manager's History array that have ``'cancel_requested'`` .. as ``True`` are not allocated:: .. -.. task_avail = ~H['given'] & ~H['cancel_requested'] +.. task_avail = ~H['sim_started'] & ~H['cancel_requested'] .. .. This ``alloc_f`` also can prioritize allocating points that have .. higher ``'priority'`` values from the ``gen_f`` values in the local History array:: diff --git a/docs/tutorials/local_sine_tutorial.rst b/docs/tutorials/local_sine_tutorial.rst index ae0a0642b..c8820feda 100644 --- a/docs/tutorials/local_sine_tutorial.rst +++ b/docs/tutorials/local_sine_tutorial.rst @@ -292,7 +292,7 @@ columns might be rearranged). .. code-block:: - ['y', 'given_time', 'gen_worker', 'sim_worker', 'given', 'returned', 'x', 'allocated', 'sim_id', 'gen_time'] + ['y', 'sim_started_time', 'gen_worker', 'sim_worker', 'sim_started', 'sim_ended', 'x', 'allocated', 'sim_id', 'gen_ended_time'] [(-0.37466051, 1.559+09, 2, 2, True, True, [-0.38403059], True, 0, 1.559+09) (-0.29279634, 1.559+09, 2, 3, True, True, [-2.84444261], True, 1, 1.559+09) ( 0.29358492, 1.559+09, 2, 4, True, True, [ 0.29797487], True, 2, 1.559+09) diff --git a/libensemble/alloc_funcs/fast_alloc_and_pausing.py b/libensemble/alloc_funcs/fast_alloc_and_pausing.py index 7fbe1018d..81e2fd89e 100644 --- a/libensemble/alloc_funcs/fast_alloc_and_pausing.py +++ b/libensemble/alloc_funcs/fast_alloc_and_pausing.py @@ -78,7 +78,7 @@ def give_sim_work_first(W, H, sim_specs, gen_specs, alloc_specs, persis_info, li if 'local_pt' in H.dtype.names and H['local_pt'][a1][0]: persis_info['local_pt_ids'].add(pt_id) - if np.all(H['returned'][a1]): + if np.all(H['sim_ended'][a1]): persis_info['complete'].add(pt_id) values = gen_specs['user']['combine_component_func'](H['f_i'][a1]) persis_info['best_complete_val'] = min(persis_info['best_complete_val'], values) @@ -124,13 +124,13 @@ def give_sim_work_first(W, H, sim_specs, gen_specs, alloc_specs, persis_info, li if len(H): # Don't give gen instances in batch mode if points are unfinished if (alloc_specs['user'].get('batch_mode') - and not all(np.logical_or(H['returned'][last_size:], H['paused'][last_size:]))): + and not all(np.logical_or(H['sim_ended'][last_size:], H['paused'][last_size:]))): break # Don't call APOSMM if there are runs going but none need advancing if len(persis_info[lw]['run_order']): runs_needing_to_advance = np.zeros(len(persis_info[lw]['run_order']), dtype=bool) for run, inds in enumerate(persis_info[lw]['run_order'].values()): - runs_needing_to_advance[run] = np.all(H['returned'][inds]) + runs_needing_to_advance[run] = np.all(H['sim_ended'][inds]) if not np.any(runs_needing_to_advance): break diff --git a/libensemble/alloc_funcs/fast_alloc_to_aposmm.py b/libensemble/alloc_funcs/fast_alloc_to_aposmm.py index a0dd71898..a2153b400 100644 --- a/libensemble/alloc_funcs/fast_alloc_to_aposmm.py +++ b/libensemble/alloc_funcs/fast_alloc_to_aposmm.py @@ -49,13 +49,13 @@ def give_sim_work_first(W, H, sim_specs, gen_specs, alloc_specs, persis_info, li if len(H): # Don't give gen instances in batch mode if points are unfinished - if user.get('batch_mode') and not support.all_returned(pt_filter=~H['paused'], low_bound=last_size): + if user.get('batch_mode') and not support.all_sim_ended(pt_filter=~H['paused'], low_bound=last_size): break # Don't call APOSMM if there are runs going but none need advancing if len(persis_info[lw]['run_order']): runs_needing_to_advance = np.zeros(len(persis_info[lw]['run_order']), dtype=bool) for run, inds in enumerate(persis_info[lw]['run_order'].values()): - runs_needing_to_advance[run] = H['returned'][inds[-1]] + runs_needing_to_advance[run] = H['sim_ended'][inds[-1]] if not np.any(runs_needing_to_advance): break diff --git a/libensemble/alloc_funcs/give_sim_work_first.py b/libensemble/alloc_funcs/give_sim_work_first.py index 2f5a3b8f5..b18929830 100644 --- a/libensemble/alloc_funcs/give_sim_work_first.py +++ b/libensemble/alloc_funcs/give_sim_work_first.py @@ -33,8 +33,8 @@ def give_sim_work_first(W, H, sim_specs, gen_specs, alloc_specs, persis_info, li if 'cancel_sims_time' in user: # Cancel simulations that are taking too long - rows = np.where(np.logical_and.reduce((H['given'], ~H['returned'], ~H['cancel_requested'])))[0] - inds = time.time() - H['last_given_time'][rows] > user['cancel_sims_time'] + rows = np.where(np.logical_and.reduce((H['sim_started'], ~H['sim_ended'], ~H['cancel_requested'])))[0] + inds = time.time() - H['sim_started_time'][rows] > user['cancel_sims_time'] to_request_cancel = rows[inds] for row in to_request_cancel: H[row]['cancel_requested'] = True @@ -52,7 +52,7 @@ def give_sim_work_first(W, H, sim_specs, gen_specs, alloc_specs, persis_info, li gen_count = support.count_gens() Work = {} - points_to_evaluate = ~H['given'] & ~H['cancel_requested'] + points_to_evaluate = ~H['sim_started'] & ~H['cancel_requested'] for wid in support.avail_worker_ids(): if np.any(points_to_evaluate): @@ -69,7 +69,7 @@ def give_sim_work_first(W, H, sim_specs, gen_specs, alloc_specs, persis_info, li break # Do not start gen instances in batch mode if workers still working - if user.get('batch_mode') and not support.all_returned(H): + if user.get('batch_mode') and not support.all_sim_ended(H): break # Give gen work diff --git a/libensemble/alloc_funcs/inverse_bayes_allocf.py b/libensemble/alloc_funcs/inverse_bayes_allocf.py index a5aeb0407..b12e3bcca 100644 --- a/libensemble/alloc_funcs/inverse_bayes_allocf.py +++ b/libensemble/alloc_funcs/inverse_bayes_allocf.py @@ -31,7 +31,7 @@ def only_persistent_gens_for_inverse_bayes(W, H, sim_specs, gen_specs, alloc_spe # if > 1 persistent generator, assign the correct work to it inds_generated_by_wid = (H['gen_worker'] == wid) - if support.all_returned(H, inds_generated_by_wid): + if support.all_sim_ended(H, inds_generated_by_wid): # Has sim_f completed everything from this persistent worker? # Then give back everything in the last batch @@ -45,7 +45,7 @@ def only_persistent_gens_for_inverse_bayes(W, H, sim_specs, gen_specs, alloc_spe Work[wid] = support.gen_work(wid, ['like'], inds_to_send_back, persis_info.get(wid), persistent=True) - points_to_evaluate = ~H['given'] & ~H['cancel_requested'] + points_to_evaluate = ~H['sim_started'] & ~H['cancel_requested'] for wid in support.avail_worker_ids(persistent=False): if np.any(points_to_evaluate): diff --git a/libensemble/alloc_funcs/only_one_gen_alloc.py b/libensemble/alloc_funcs/only_one_gen_alloc.py index ad46cabe4..338b790b6 100644 --- a/libensemble/alloc_funcs/only_one_gen_alloc.py +++ b/libensemble/alloc_funcs/only_one_gen_alloc.py @@ -38,7 +38,7 @@ def ensure_one_active_gen(W, H, sim_specs, gen_specs, alloc_specs, persis_info, elif not support.test_any_gen() and gen_flag: - if not support.all_returned(H): + if not support.all_sim_ended(H): break # Give gen work diff --git a/libensemble/alloc_funcs/persistent_aposmm_alloc.py b/libensemble/alloc_funcs/persistent_aposmm_alloc.py index a51bd8d02..5232de321 100644 --- a/libensemble/alloc_funcs/persistent_aposmm_alloc.py +++ b/libensemble/alloc_funcs/persistent_aposmm_alloc.py @@ -31,9 +31,9 @@ def persistent_aposmm_alloc(W, H, sim_specs, gen_specs, alloc_specs, persis_info Work = {} if persis_info.get('first_call', True): - assert support.all_given(H), "Initial points in H have never been given." - assert support.all_returned(H), "Initial points in H have never been returned." - assert support.all_given_back(H), "Initial points in H have never been given back to gen." + assert support.all_sim_started(H), "Initial points in H have never been given." + assert support.all_sim_ended(H), "Initial points in H have never been returned." + assert support.all_gen_informed(H), "Initial points in H have never been given back to gen." persis_info['samples_in_H0'] = sum(H['local_pt'] == 0) persis_info['next_to_give'] = len(H) # @@ -44,11 +44,11 @@ def persistent_aposmm_alloc(W, H, sim_specs, gen_specs, alloc_specs, persis_info # If any persistent worker's calculated values have returned, give them back. for wid in support.avail_worker_ids(persistent=EVAL_GEN_TAG): - if (persis_info.get('sample_done') or sum(H['returned']) >= init_sample_size + persis_info['samples_in_H0']): + if (persis_info.get('sample_done') or sum(H['sim_ended']) >= init_sample_size + persis_info['samples_in_H0']): # Don't return if the initial sample is not complete persis_info['sample_done'] = True - returned_but_not_given = np.logical_and(H['returned'], ~H['given_back']) + returned_but_not_given = np.logical_and(H['sim_ended'], ~H['gen_informed']) if np.any(returned_but_not_given): point_ids = np.where(returned_but_not_given)[0] Work[wid] = support.gen_work(wid, gen_specs['persis_in'], point_ids, persis_info.get(wid), diff --git a/libensemble/alloc_funcs/start_fd_persistent.py b/libensemble/alloc_funcs/start_fd_persistent.py index 011afabd3..defe15447 100644 --- a/libensemble/alloc_funcs/start_fd_persistent.py +++ b/libensemble/alloc_funcs/start_fd_persistent.py @@ -36,13 +36,13 @@ def finite_diff_alloc(W, H, sim_specs, gen_specs, alloc_specs, persis_info, libE # What (x_ind, f_ind) pairs have all of the evaluation of all n_ind # values complete. - inds_not_sent_back = ~H['given_back'] + inds_not_sent_back = ~H['gen_informed'] H_tmp = H[inds_not_sent_back] inds_to_send = np.array([], dtype=int) for x_ind in range(gen_specs['user']['n']): for f_ind in range(gen_specs['user']['p']): - inds = np.logical_and.reduce((H_tmp['x_ind'] == x_ind, H_tmp['f_ind'] == f_ind, H_tmp['returned'])) + inds = np.logical_and.reduce((H_tmp['x_ind'] == x_ind, H_tmp['f_ind'] == f_ind, H_tmp['sim_ended'])) if sum(inds) == gen_specs['user']['nf']: inds_to_send = np.append(inds_to_send, H_tmp['sim_id'][inds]) @@ -50,7 +50,7 @@ def finite_diff_alloc(W, H, sim_specs, gen_specs, alloc_specs, persis_info, libE Work[wid] = support.gen_work(wid, gen_specs['persis_in'], inds_to_send, persis_info.get(wid), persistent=True) - points_to_evaluate = ~H['given'] & ~H['cancel_requested'] + points_to_evaluate = ~H['sim_started'] & ~H['cancel_requested'] for wid in support.avail_worker_ids(persistent=False): if np.any(points_to_evaluate): # perform sim evaluations (if they exist in History). diff --git a/libensemble/alloc_funcs/start_only_persistent.py b/libensemble/alloc_funcs/start_only_persistent.py index 6155642df..707e0ad82 100644 --- a/libensemble/alloc_funcs/start_only_persistent.py +++ b/libensemble/alloc_funcs/start_only_persistent.py @@ -63,7 +63,7 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l Work = {} # Asynchronous return to generator - async_return = user.get('async_return', False) and sum(H['returned']) >= init_sample_size + async_return = user.get('async_return', False) and sum(H['sim_ended']) >= init_sample_size if gen_count < persis_info.get('num_gens_started', 0): # When a persistent worker is done, trigger a shutdown (returning exit condition of 1) @@ -72,16 +72,16 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l # Give evaluated results back to a running persistent gen for wid in support.avail_worker_ids(persistent=EVAL_GEN_TAG, active_recv=active_recv_gen): gen_inds = (H['gen_worker'] == wid) - returned_but_not_given = np.logical_and.reduce((H['returned'], ~H['given_back'], gen_inds)) + returned_but_not_given = np.logical_and.reduce((H['sim_ended'], ~H['gen_informed'], gen_inds)) if np.any(returned_but_not_given): - if async_return or support.all_returned(H, gen_inds): + if async_return or support.all_sim_ended(H, gen_inds): point_ids = np.where(returned_but_not_given)[0] Work[wid] = support.gen_work(wid, gen_specs['persis_in'], point_ids, persis_info.get(wid), persistent=True, active_recv=active_recv_gen) returned_but_not_given[point_ids] = False # Now the give_sim_work_first part - points_to_evaluate = ~H['given'] & ~H['cancel_requested'] + points_to_evaluate = ~H['sim_started'] & ~H['cancel_requested'] avail_workers = support.avail_worker_ids(persistent=False, zero_resource_workers=False) for wid in avail_workers: @@ -174,7 +174,7 @@ def only_persistent_workers(W, H, sim_specs, gen_specs, alloc_specs, persis_info Work = {} # Asynchronous return to generator - async_return = user.get('async_return', False) and sum(H['returned']) >= init_sample_size + async_return = user.get('async_return', False) and sum(H['sim_ended']) >= init_sample_size if gen_count < persis_info.get('num_gens_started', 0): # When a persistent gen worker is done, trigger a shutdown (returning exit condition of 1) @@ -183,16 +183,16 @@ def only_persistent_workers(W, H, sim_specs, gen_specs, alloc_specs, persis_info # Give evaluated results back to a running persistent gen for wid in support.avail_worker_ids(persistent=EVAL_GEN_TAG, active_recv=active_recv_gen): gen_inds = (H['gen_worker'] == wid) - returned_but_not_given = np.logical_and.reduce((H['returned'], ~H['given_back'], gen_inds)) + returned_but_not_given = np.logical_and.reduce((H['sim_ended'], ~H['gen_informed'], gen_inds)) if np.any(returned_but_not_given): - if async_return or support.all_returned(H, gen_inds): + if async_return or support.all_sim_ended(H, gen_inds): point_ids = np.where(returned_but_not_given)[0] Work[wid] = support.gen_work(wid, gen_specs['persis_in'], point_ids, persis_info.get(wid), persistent=True, active_recv=active_recv_gen) returned_but_not_given[point_ids] = False # Now the give_sim_work_first part - points_to_evaluate = ~H['given'] & ~H['cancel_requested'] + points_to_evaluate = ~H['sim_started'] & ~H['cancel_requested'] avail_workers = list( set(support.avail_worker_ids(persistent=False, zero_resource_workers=False)) | set(support.avail_worker_ids(persistent=EVAL_SIM_TAG, zero_resource_workers=False))) diff --git a/libensemble/alloc_funcs/start_persistent_consensus.py b/libensemble/alloc_funcs/start_persistent_consensus.py index 663722c31..20f16c811 100644 --- a/libensemble/alloc_funcs/start_persistent_consensus.py +++ b/libensemble/alloc_funcs/start_persistent_consensus.py @@ -105,7 +105,7 @@ def start_consensus_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, per [l_H_id, r_H_id] = persis_info[wid].get('curr_H_ids') num_sims_req = r_H_id - l_H_id - num_fin_sims = np.sum(H['returned'][l_H_id:r_H_id]) + num_fin_sims = np.sum(H['sim_ended'][l_H_id:r_H_id]) completed_all_sims_for_gen_i = num_fin_sims == num_sims_req @@ -267,7 +267,7 @@ def start_consensus_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, per # skip points that are not sim work or are already done while persis_info['next_to_give'] < len(H) and \ - (H[persis_info['next_to_give']]['given'] or + (H[persis_info['next_to_give']]['sim_started'] or H[persis_info['next_to_give']]['consensus_pt'] or H[persis_info['next_to_give']]['cancel_requested']): diff --git a/libensemble/alloc_funcs/start_persistent_local_opt_gens.py b/libensemble/alloc_funcs/start_persistent_local_opt_gens.py index fe5f64c95..172a2cc9e 100644 --- a/libensemble/alloc_funcs/start_persistent_local_opt_gens.py +++ b/libensemble/alloc_funcs/start_persistent_local_opt_gens.py @@ -33,7 +33,7 @@ def start_persistent_local_opt_gens(W, H, sim_specs, gen_specs, alloc_specs, per support = AllocSupport(W, manage_resources, persis_info, sched_opts) Work = {} gen_count = support.count_persis_gens() - points_to_evaluate = ~H['given'] & ~H['cancel_requested'] + points_to_evaluate = ~H['sim_started'] & ~H['cancel_requested'] # If a persistent localopt run has just finished, use run_order to update H # and then remove other information from persis_info @@ -50,15 +50,15 @@ def start_persistent_local_opt_gens(W, H, sim_specs, gen_specs, alloc_specs, per # returned, give them back to i. Otherwise, give nothing to wid for wid in support.avail_worker_ids(persistent=EVAL_GEN_TAG): gen_inds = (H['gen_worker'] == wid) - if support.all_returned(H, gen_inds): - last_time_pos = np.argmax(H['given_time'][gen_inds]) + if support.all_sim_ended(H, gen_inds): + last_time_pos = np.argmax(H['sim_started_time'][gen_inds]) last_ind = np.nonzero(gen_inds)[0][last_time_pos] Work[wid] = support.gen_work(wid, gen_specs['persis_in'], last_ind, persis_info[wid], persistent=True) persis_info[wid]['run_order'].append(last_ind) for wid in support.avail_worker_ids(persistent=False): # Find candidates to start local opt runs if a sample has been evaluated - if np.any(np.logical_and(~H['local_pt'], H['returned'], ~H['cancel_requested'])): + if np.any(np.logical_and(~H['local_pt'], H['sim_ended'], ~H['cancel_requested'])): n, _, _, _, r_k, mu, nu = initialize_APOSMM(H, gen_specs) update_history_dist(H, n, gen_specs['user'], c_flag=False) starting_inds = decide_where_to_start_localopt(H, r_k, mu, nu) diff --git a/libensemble/gen_funcs/aposmm_localopt_support.py b/libensemble/gen_funcs/aposmm_localopt_support.py index 71fd58097..16357558f 100644 --- a/libensemble/gen_funcs/aposmm_localopt_support.py +++ b/libensemble/gen_funcs/aposmm_localopt_support.py @@ -563,10 +563,10 @@ def simulate_recv_from_manager(local_H, gen_specs): # output as if the calculations were performed externally by libEnsemble. user = gen_specs['user']['standalone'] - if np.sum(local_H['returned']) >= user['eval_max']: + if np.sum(local_H['sim_ended']) >= user['eval_max']: return STOP_TAG, {}, {} - H_rows = np.where(~local_H['returned'])[0] + H_rows = np.where(~local_H['sim_ended'])[0] H_fields = [i[0] for i in gen_specs['out']] Work = {'libE_info': {'H_rows': H_rows}, 'H_fields': H_fields} diff --git a/libensemble/gen_funcs/old_aposmm.py b/libensemble/gen_funcs/old_aposmm.py index fa6d9c0df..7d06bac40 100644 --- a/libensemble/gen_funcs/old_aposmm.py +++ b/libensemble/gen_funcs/old_aposmm.py @@ -243,7 +243,7 @@ def aposmm_logic(H, persis_info, gen_specs, _): # Find next point in any uncompleted run using persis_info['run_order'] for run in active_runs: - if not np.all(H['returned'][persis_info['run_order'][run]]): + if not np.all(H['sim_ended'][persis_info['run_order'][run]]): continue # Can't advance a run if all points aren't returned. x_opt, exit_code, persis_info, sorted_run_inds, x_new = advance_local_run(H, gen_specs['user'], c_flag, run, persis_info) @@ -399,9 +399,9 @@ def update_history_dist(H, n, gen_specs, c_flag): H['f'][inds] = np.inf H['f'][np.where(inds)[0][0]] = gen_specs['user']['combine_component_func'](H['f_i'][inds]) - p = np.logical_and.reduce((H['returned'], H['obj_component'] == 0, ~np.isnan(H['f']))) + p = np.logical_and.reduce((H['sim_ended'], H['obj_component'] == 0, ~np.isnan(H['f']))) else: - p = np.logical_and.reduce((H['returned'], ~np.isnan(H['f']))) + p = np.logical_and.reduce((H['sim_ended'], ~np.isnan(H['f']))) for new_ind in new_inds: # Loop over new returned points and update their distances @@ -783,7 +783,7 @@ def decide_where_to_start_localopt(H, r_k, mu=0, nu=0, gamma_quantile=1): if nu > 0: test_2_through_5 = np.logical_and.reduce(( - H['returned'] == 1, # have a returned function value + H['sim_ended'] == 1, # have a returned function value H['dist_to_better_s'] > r_k, # no better sample point within r_k (L2) ~H['started_run'], # have not started a run (L3) @@ -795,7 +795,7 @@ def decide_where_to_start_localopt(H, r_k, mu=0, nu=0, gamma_quantile=1): )) else: test_2_through_5 = np.logical_and.reduce(( - H['returned'] == 1, # have a returned function value + H['sim_ended'] == 1, # have a returned function value H['dist_to_better_s'] > r_k, # no better sample point within r_k (L2) ~H['started_run'], # have not started a run (L3) @@ -915,12 +915,12 @@ def initialize_APOSMM(H, gen_specs): if c_flag: # Get the pt_id for non-nan, returned points - pt_ids = H['pt_id'][np.logical_and(H['returned'], ~np.isnan(H['f_i']))] + pt_ids = H['pt_id'][np.logical_and(H['sim_ended'], ~np.isnan(H['f_i']))] _, counts = np.unique(pt_ids, return_counts=True) n_s = np.sum(counts == user_specs['components']) else: # Number of returned sampled points (excluding nans) - n_s = np.sum(np.logical_and.reduce((~np.isnan(H['f']), ~H['local_pt'], H['returned']))) + n_s = np.sum(np.logical_and.reduce((~np.isnan(H['f']), ~H['local_pt'], H['sim_ended']))) # Rather than build up a large output, we will just make changes in the # given H, and then send back the rows corresponding to updated H entries. diff --git a/libensemble/gen_funcs/persistent_aposmm.py b/libensemble/gen_funcs/persistent_aposmm.py index cdc93c853..d35993ce0 100644 --- a/libensemble/gen_funcs/persistent_aposmm.py +++ b/libensemble/gen_funcs/persistent_aposmm.py @@ -261,7 +261,7 @@ def update_local_H_after_receiving(local_H, n, n_s, user_specs, Work, calc_in, f for name in calc_in.dtype.names: local_H[name][Work['libE_info']['H_rows']] = calc_in[name] - local_H['returned'][Work['libE_info']['H_rows']] = True + local_H['sim_ended'][Work['libE_info']['H_rows']] = True n_s += np.sum(~local_H[Work['libE_info']['H_rows']]['local_pt']) n_r = len(Work['libE_info']['H_rows']) @@ -323,7 +323,7 @@ def update_history_dist(H, n): new_inds = np.where(~H['known_to_aposmm'])[0] - p = np.logical_and.reduce((H['returned'], ~np.isnan(H['f']))) + p = np.logical_and.reduce((H['sim_ended'], ~np.isnan(H['f']))) for new_ind in new_inds: # Loop over new returned points and update their distances @@ -491,7 +491,7 @@ def decide_where_to_start_localopt(H, n, n_s, rk_const, ld=0, mu=0, nu=0): if nu > 0: test_2_through_5 = np.logical_and.reduce(( - H['returned'] == 1, # have a returned function value + H['sim_ended'] == 1, # have a returned function value H['dist_to_better_s'] > r_k, # no better sample point within r_k (L2) ~H['started_run'], # have not started a run (L3) @@ -503,7 +503,7 @@ def decide_where_to_start_localopt(H, n, n_s, rk_const, ld=0, mu=0, nu=0): )) else: test_2_through_5 = np.logical_and.reduce(( - H['returned'] == 1, # have a returned function value + H['sim_ended'] == 1, # have a returned function value H['dist_to_better_s'] > r_k, # no better sample point within r_k (L2) ~H['started_run'], # have not started a run (L3) @@ -605,7 +605,7 @@ def initialize_APOSMM(H, user_specs, libE_info): ('local_min', bool), ('sim_id', int), ('paused', bool), - ('returned', bool), + ('sim_ended', bool), ] if 'components' in user_specs: @@ -623,7 +623,7 @@ def initialize_APOSMM(H, user_specs, libE_info): assert 'f' in H.dtype.names, "Must give 'f' values to persistent_aposmm in gen_specs['in']" assert 'sim_id' in H.dtype.names, "Must give 'sim_id' to persistent_aposmm in gen_specs['in']" - assert 'returned' in H.dtype.names, "Must give 'returned' status to persistent_aposmm in gen_specs['in']" + assert 'sim_ended' in H.dtype.names, "Must give 'sim_ended' status to persistent_aposmm in gen_specs['in']" over_written_fields = ['dist_to_unit_bounds', 'dist_to_better_l', 'dist_to_better_s', 'ind_of_better_l', 'ind_of_better_s'] if any([i in H.dtype.names for i in over_written_fields]): diff --git a/libensemble/history.py b/libensemble/history.py index dc53dcd71..3bca979d1 100644 --- a/libensemble/history.py +++ b/libensemble/history.py @@ -28,13 +28,13 @@ class History: :ivar int index: Index where libEnsemble should start filling in H - :ivar int given_count: + :ivar int sim_started_count: Number of points given to sim functions (according to H) - :ivar int returned_count: + :ivar int sim_ended_count: Number of points evaluated (according to H) - Note that index, given_count and returned_count reflect the total number of points + Note that index, sim_started_count and sim_ended_count reflect the total number of points in H and therefore include those prepended to H in addition to the current run. """ @@ -63,36 +63,35 @@ def __init__(self, alloc_specs, sim_specs, gen_specs, exit_criteria, H0): # for ind, val in np.ndenumerate(H0[field]): # Works if H0[field] has arbitrary dimension but is slow # H[field][ind] = val - if 'given' not in fields: - logger.manager_warning("Marking entries in H0 as having been 'given' and 'returned'") - H['given'][:len(H0)] = 1 - H['returned'][:len(H0)] = 1 - elif 'returned' not in fields: - logger.manager_warning("Marking entries in H0 as having been 'returned' if 'given'") - H['returned'][:len(H0)] = H0['given'] + if 'sim_started' not in fields: + logger.manager_warning("Marking entries in H0 as having been 'sim_started' and 'sim_ended'") + H['sim_started'][:len(H0)] = 1 + H['sim_ended'][:len(H0)] = 1 + elif 'sim_ended' not in fields: + logger.manager_warning("Marking entries in H0 as having been 'sim_ended' if 'sim_started'") + H['sim_ended'][:len(H0)] = H0['sim_started'] if 'sim_id' not in fields: logger.manager_warning("Assigning sim_ids to entries in H0") H['sim_id'][:len(H0)] = np.arange(0, len(H0)) H['sim_id'][-L:] = -1 - H['given_time'][-L:] = np.inf - H['last_given_time'][-L:] = np.inf - H['last_given_back_time'][-L:] = np.inf + H['sim_started_time'][-L:] = np.inf + H['gen_informed_time'][-L:] = np.inf self.H = H self.using_H0 = len(H0) > 0 self.index = len(H0) self.grow_count = 0 - self.given_count = np.sum(H['given']) - self.returned_count = np.sum(H['returned']) - self.given_back_count = np.sum(H['given_back']) + self.sim_started_count = np.sum(H['sim_started']) + self.sim_ended_count = np.sum(H['sim_ended']) + self.gen_informed_count = np.sum(H['gen_informed']) self.given_back_warned = False - self.given_offset = self.given_count - self.returned_offset = self.returned_count - self.given_back_offset = self.given_back_count + self.sim_started_offset = self.sim_started_count + self.sim_ended_offset = self.sim_ended_count + self.gen_informed_offset = self.gen_informed_count def update_history_f(self, D, safe_mode): """ @@ -119,9 +118,9 @@ def update_history_f(self, D, safe_mode): else: self.H[field][ind][:H0_size] = returned_H[field][j] # Slice View - self.H['returned'][ind] = True - self.H['returned_time'][ind] = time.time() - self.returned_count += 1 + self.H['sim_ended'][ind] = True + self.H['sim_ended_time'][ind] = time.time() + self.sim_ended_count += 1 def update_history_x_out(self, q_inds, sim_worker): """ @@ -136,15 +135,13 @@ def update_history_x_out(self, q_inds, sim_worker): Worker ID """ q_inds = np.atleast_1d(q_inds) - first_given_inds = ~self.H['given'][q_inds] t = time.time() - self.H['given'][q_inds] = True - self.H['given_time'][q_inds[first_given_inds]] = t - self.H['last_given_time'][q_inds] = t + self.H['sim_started'][q_inds] = True + self.H['sim_started_time'][q_inds] = t self.H['sim_worker'][q_inds] = sim_worker - self.given_count += len(q_inds) + self.sim_started_count += len(q_inds) def update_history_to_gen(self, q_inds): """Updates the history (in place) when points are given back to the gen""" @@ -152,22 +149,22 @@ def update_history_to_gen(self, q_inds): t = time.time() if q_inds.size > 0: - if np.all(self.H['returned'][q_inds]): - self.H['given_back'][q_inds] = True + if np.all(self.H['sim_ended'][q_inds]): + self.H['gen_informed'][q_inds] = True - elif np.any(self.H['returned'][q_inds]): # sporadic returned points need updating - for ind in q_inds[self.H['returned'][q_inds]]: - self.H['given_back'][ind] = True + elif np.any(self.H['sim_ended'][q_inds]): # sporadic returned points need updating + for ind in q_inds[self.H['sim_ended'][q_inds]]: + self.H['gen_informed'][ind] = True if self.using_H0 and not self.given_back_warned: logger.manager_warning( - "Giving entries in H0 back to gen. Marking entries in H0 as 'given_back' if 'returned'.") + "Giving entries in H0 back to gen. Marking entries in H0 as 'gen_informed' if 'sim_ended'.") self.given_back_warned = True - self.H['last_given_back_time'][q_inds] = t - self.given_back_count += len(q_inds) + self.H['gen_informed_time'][q_inds] = t + self.gen_informed_count += len(q_inds) - def update_history_x_in(self, gen_worker, D, safe_mode): + def update_history_x_in(self, gen_worker, D, safe_mode, gen_started_time): """ Updates the history (in place) when new points have been returned from a gen @@ -182,6 +179,7 @@ def update_history_x_in(self, gen_worker, D, safe_mode): if len(D) == 0: return + t = time.time() rows_remaining = len(self.H)-self.index if 'sim_id' not in D.dtype.names: @@ -214,10 +212,9 @@ def update_history_x_in(self, gen_worker, D, safe_mode): assert field not in protected_libE_fields, "The field '" + field + "' is protected" self.H[field][update_inds] = D[field] - first_gen_inds = update_inds[self.H['gen_time'][update_inds] == 0] - t = time.time() - self.H['gen_time'][first_gen_inds] = t - self.H['last_gen_time'][update_inds] = t + first_gen_inds = update_inds[self.H['gen_ended_time'][update_inds] == 0] + self.H['gen_started_time'][first_gen_inds] = gen_started_time + self.H['gen_ended_time'][first_gen_inds] = t self.H['gen_worker'][first_gen_inds] = gen_worker self.index += num_new @@ -233,9 +230,8 @@ def grow_H(self, k): """ H_1 = np.zeros(k, dtype=self.H.dtype) H_1['sim_id'] = -1 - H_1['given_time'] = np.inf - H_1['last_given_time'] = np.inf - H_1['last_given_back_time'] = np.inf + H_1['sim_started_time'] = np.inf + H_1['gen_informed_time'] = np.inf self.H = np.append(self.H, H_1) # Could be arguments here to return different truncations eg. all done, given etc... diff --git a/libensemble/libE.py b/libensemble/libE.py index 44d6db5d5..f3a200d9f 100644 --- a/libensemble/libE.py +++ b/libensemble/libE.py @@ -612,9 +612,9 @@ def _dump_on_abort(hist, persis_info, save_H=True): """Dump history and persis_info on abort""" logger.error("Manager exception raised .. aborting ensemble:") logger.error("Dumping ensemble history with {} sims evaluated:". - format(hist.returned_count)) + format(hist.sim_ended_count)) if save_H: - np.save('libE_history_at_abort_' + str(hist.returned_count) + '.npy', hist.trim_H()) - with open('libE_persis_info_at_abort_' + str(hist.returned_count) + '.pickle', "wb") as f: + np.save('libE_history_at_abort_' + str(hist.sim_ended_count) + '.npy', hist.trim_H()) + with open('libE_persis_info_at_abort_' + str(hist.sim_ended_count) + '.pickle', "wb") as f: pickle.dump(persis_info, f) diff --git a/libensemble/manager.py b/libensemble/manager.py index 12653491b..274d69288 100644 --- a/libensemble/manager.py +++ b/libensemble/manager.py @@ -30,6 +30,7 @@ import cProfile import pstats import copy +import time if tuple(np.__version__.split('.')) >= ('1', '15'): from numpy.lib.recfunctions import repack_fields @@ -150,6 +151,7 @@ class Manager: ('active', int), ('persis_state', int), ('active_recv', int), + ('gen_started_time', float), ('zero_resource_worker', bool)] def __init__(self, hist, libE_specs, alloc_specs, @@ -202,17 +204,17 @@ def term_test_wallclock(self, max_elapsed): def term_test_sim_max(self, sim_max): """Checks against max simulations""" - return self.hist.returned_count >= sim_max + self.hist.returned_offset + return self.hist.sim_ended_count >= sim_max + self.hist.sim_ended_offset def term_test_gen_max(self, gen_max): """Checks against max generator calls""" - return self.hist.index >= gen_max + self.hist.given_back_offset + return self.hist.index >= gen_max + self.hist.gen_informed_offset def term_test_stop_val(self, stop_val): """Checks against stop value criterion""" key, val = stop_val H = self.hist.H - return np.any(filter_nans(H[key][H['returned']]) <= val) + return np.any(filter_nans(H[key][H['sim_ended']]) <= val) def term_test(self, logged=True): """Checks termination criteria""" @@ -245,7 +247,7 @@ def _save_every_k(self, fname, count, k): def _save_every_k_sims(self): """Saves history every kth sim step""" self._save_every_k('libE_history_for_run_starting_{}_after_sim_{}.npy', - self.hist.returned_count, + self.hist.sim_ended_count, self.libE_specs['save_every_k_sims']) def _save_every_k_gens(self): @@ -314,6 +316,9 @@ def _send_work_order(self, Work, w): self.wcomms[w-1].send(Work['tag'], Work) + if Work['tag'] == EVAL_GEN_TAG: + self.W[w-1]['gen_started_time'] = time.time() + work_rows = Work['libE_info']['H_rows'] work_name = calc_type_strings[Work['tag']] logger.debug("Manager sending {} work to worker {}. Rows {}". @@ -407,7 +412,7 @@ def _update_state_on_worker_msg(self, persis_info, D_recv, w): final_data = D_recv.get('calc_out', None) if isinstance(final_data, np.ndarray): if calc_status is FINISHED_PERSISTENT_GEN_TAG and self.libE_specs.get('use_persis_return_gen', False): - self.hist.update_history_x_in(w, final_data, self.safe_mode) + self.hist.update_history_x_in(w, final_data, self.safe_mode, self.W[w-1]['gen_started_time']) elif calc_status is FINISHED_PERSISTENT_SIM_TAG and self.libE_specs.get('use_persis_return_sim', False): self.hist.update_history_f(D_recv, self.safe_mode) else: @@ -424,7 +429,7 @@ def _update_state_on_worker_msg(self, persis_info, D_recv, w): if calc_type == EVAL_SIM_TAG: self.hist.update_history_f(D_recv, self.safe_mode) if calc_type == EVAL_GEN_TAG: - self.hist.update_history_x_in(w, D_recv['calc_out'], self.safe_mode) + self.hist.update_history_x_in(w, D_recv['calc_out'], self.safe_mode, self.W[w-1]['gen_started_time']) assert len(D_recv['calc_out']) or np.any(self.W['active']) or self.W[w-1]['persis_state'], \ "Gen must return work when is is the only thing active and not persistent." if 'libE_info' in D_recv and 'persistent' in D_recv['libE_info']: @@ -463,8 +468,8 @@ def _handle_msg_from_worker(self, persis_info, w): def _kill_cancelled_sims(self): """Send kill signals to any sims marked as cancel_requested""" if self.kill_canceled_sims: - kill_sim = self.hist.H['given'] & self.hist.H['cancel_requested'] \ - & ~self.hist.H['returned'] & ~self.hist.H['kill_sent'] + kill_sim = self.hist.H['sim_started'] & self.hist.H['cancel_requested'] \ + & ~self.hist.H['sim_ended'] & ~self.hist.H['kill_sent'] # Note that a return is still expected when running sims are killed if np.any(kill_sim): @@ -491,7 +496,7 @@ def _final_receive_and_kill(self, persis_info): for w in self.W['worker_id'][self.W['persis_state'] > 0]: logger.debug("Manager sending PERSIS_STOP to worker {}".format(w)) if 'final_fields' in self.libE_specs: - rows_to_send = self.hist.trim_H()['returned'] + rows_to_send = self.hist.trim_H()['sim_ended'] fields_to_send = self.libE_specs['final_fields'] H_to_send = self.hist.trim_H()[rows_to_send][fields_to_send] self.wcomms[w-1].send(PERSIS_STOP, H_to_send) @@ -523,7 +528,7 @@ def _final_receive_and_kill(self, persis_info): def _sim_max_given(self): if 'sim_max' in self.exit_criteria: - return self.hist.given_count >= self.exit_criteria['sim_max'] + self.hist.given_offset + return self.hist.sim_started_count >= self.exit_criteria['sim_max'] + self.hist.sim_started_offset else: return False @@ -534,9 +539,9 @@ def _get_alloc_libE_info(self): 'exit_criteria': self.exit_criteria, 'elapsed_time': self.elapsed(), 'manager_kill_canceled_sims': self.kill_canceled_sims, - 'given_count': self.hist.given_count, - 'returned_count': self.hist.returned_count, - 'given_back_count': self.hist.given_back_count, + 'sim_started_count': self.hist.sim_started_count, + 'sim_ended_count': self.hist.sim_ended_count, + 'gen_informed_count': self.hist.gen_informed_count, 'sim_max_given': self._sim_max_given(), 'use_resource_sets': 'num_resource_sets' in self.libE_specs} diff --git a/libensemble/sim_funcs/executor_hworld.py b/libensemble/sim_funcs/executor_hworld.py index 4efbf1cb2..837aaec3a 100644 --- a/libensemble/sim_funcs/executor_hworld.py +++ b/libensemble/sim_funcs/executor_hworld.py @@ -13,7 +13,7 @@ __all__ = ['executor_hworld'] # Alt send values through X -returned_count = 0 +sim_ended_count = 0 def custom_polling_loop(exctr, task, timeout_sec=5.0, delay=0.3): @@ -83,24 +83,24 @@ def executor_hworld(H, persis_info, sim_specs, libE_info): timeout = 65.0 else: - global returned_count - returned_count += 1 + global sim_ended_count + sim_ended_count += 1 timeout = 6.0 launch_shc = False - print(returned_count) + print(sim_ended_count) - if returned_count == 1: + if sim_ended_count == 1: args_for_sim = 'sleep 1' # Should finish - elif returned_count == 2: + elif sim_ended_count == 2: args_for_sim = 'sleep 1 Error' # Worker kill on error - elif returned_count == 3: + elif sim_ended_count == 3: wait = True args_for_sim = 'sleep 1' # Should finish launch_shc = True - elif returned_count == 4: + elif sim_ended_count == 4: args_for_sim = 'sleep 8' # Worker kill on timeout timeout = 1.0 - elif returned_count == 5: + elif sim_ended_count == 5: args_for_sim = 'sleep 2 Fail' # Manager kill - if signal received else completes if USE_BALSAM: @@ -127,9 +127,9 @@ def executor_hworld(H, persis_info, sim_specs, libE_info): else: if not ELAPSED_TIMEOUT: - if returned_count >= 2 and not USE_BALSAM: + if sim_ended_count >= 2 and not USE_BALSAM: calc_status = exctr.polling_loop(task, timeout=timeout, delay=0.3, poll_manager=True) - if returned_count == 2 and task.stdout_exists() and 'Error' in task.read_stdout(): + if sim_ended_count == 2 and task.stdout_exists() and 'Error' in task.read_stdout(): calc_status = WORKER_KILL_ON_ERR else: diff --git a/libensemble/tests/deprecated_tests/test_nan_func_old_aposmm.py b/libensemble/tests/deprecated_tests/test_nan_func_old_aposmm.py index 5273872fd..953af2070 100644 --- a/libensemble/tests/deprecated_tests/test_nan_func_old_aposmm.py +++ b/libensemble/tests/deprecated_tests/test_nan_func_old_aposmm.py @@ -32,7 +32,7 @@ gen_out += [('x', float, n), ('x_on_cube', float, n), ('obj_component', int)] gen_specs = {'gen_f': gen_f, - 'in': [o[0] for o in gen_out] + ['f', 'f_i', 'returned'], + 'in': [o[0] for o in gen_out] + ['f', 'f_i', 'sim_ended'], 'out': gen_out, 'user': {'initial_sample_size': 5, 'lb': -2*np.ones(n), diff --git a/libensemble/tests/deprecated_tests/test_old_aposmm_logic.py b/libensemble/tests/deprecated_tests/test_old_aposmm_logic.py index ab05c62eb..ab8dd37da 100644 --- a/libensemble/tests/deprecated_tests/test_old_aposmm_logic.py +++ b/libensemble/tests/deprecated_tests/test_old_aposmm_logic.py @@ -23,7 +23,7 @@ def test_failing_localopt_method(): hist, sim_specs_0, gen_specs_0, exit_criteria_0, alloc = setup.hist_setup1() - hist.H['returned'] = 1 + hist.H['sim_ended'] = 1 gen_specs_0['user']['localopt_method'] = 'BADNAME' @@ -37,7 +37,7 @@ def test_failing_localopt_method(): def test_exception_raising(): hist, sim_specs_0, gen_specs_0, exit_criteria_0, alloc = setup.hist_setup1(n=2) - hist.H['returned'] = 1 + hist.H['sim_ended'] = 1 for method in ['LN_SBPLX', 'pounders', 'scipy_COBYLA']: gen_specs_0['user']['localopt_method'] = method @@ -48,10 +48,10 @@ def test_exception_raising(): def test_decide_where_to_start_localopt(): - H = np.zeros(10, dtype=gen_out + [('f', float), ('returned', bool)]) + H = np.zeros(10, dtype=gen_out + [('f', float), ('sim_ended', bool)]) H['x'] = np.random.uniform(0, 1, (10, 2)) H['f'] = np.random.uniform(0, 1, 10) - H['returned'] = 1 + H['sim_ended'] = 1 b = al.decide_where_to_start_localopt(H, 9, 1) assert len(b) == 0 @@ -94,10 +94,10 @@ def test_declare_opt(): def test_localopt_error_saving(): _, sim_specs_0, gen_specs_0, _, _ = setup.hist_setup1() - H = np.zeros(4, dtype=gen_out + [('f', float), ('fvec', float, 2), ('returned', bool)]) + H = np.zeros(4, dtype=gen_out + [('f', float), ('fvec', float, 2), ('sim_ended', bool)]) H['x'] = np.random.uniform(0, 1, (4, 2)) H['f'] = np.random.uniform(0, 1, 4) - H['returned'] = True + H['sim_ended'] = True H['local_pt'][1:] = True gen_specs_0['user']['initial_sample_size'] = 1 gen_specs_0['user']['localopt_method'] = 'scipy_COBYLA' diff --git a/libensemble/tests/deprecated_tests/test_old_aposmm_one_residual_at_a_time.py b/libensemble/tests/deprecated_tests/test_old_aposmm_one_residual_at_a_time.py index bc8241f56..5beca24a8 100644 --- a/libensemble/tests/deprecated_tests/test_old_aposmm_one_residual_at_a_time.py +++ b/libensemble/tests/deprecated_tests/test_old_aposmm_one_residual_at_a_time.py @@ -44,7 +44,7 @@ UB = 2*np.ones(n) LB = (-2-np.pi/10)*np.ones(n) gen_specs = {'gen_f': gen_f, - 'in': [o[0] for o in gen_out] + ['f_i', 'returned'], + 'in': [o[0] for o in gen_out] + ['f_i', 'sim_ended'], 'out': gen_out, 'user': {'initial_sample_size': 5, 'lb': LB, diff --git a/libensemble/tests/deprecated_tests/test_old_aposmm_pounders.py b/libensemble/tests/deprecated_tests/test_old_aposmm_pounders.py index 8e6d7e320..7185dbb03 100644 --- a/libensemble/tests/deprecated_tests/test_old_aposmm_pounders.py +++ b/libensemble/tests/deprecated_tests/test_old_aposmm_pounders.py @@ -43,7 +43,7 @@ # lb tries to avoid x[1]=-x[2], which results in division by zero in chwirut. gen_specs = {'gen_f': gen_f, - 'in': [o[0] for o in gen_out]+['f', 'fvec', 'returned'], + 'in': [o[0] for o in gen_out]+['f', 'fvec', 'sim_ended'], 'out': gen_out, 'user': {'initial_sample_size': 5, 'lb': (-2-np.pi/10)*np.ones(n), diff --git a/libensemble/tests/deprecated_tests/test_old_aposmm_pounders_splitcomm.py b/libensemble/tests/deprecated_tests/test_old_aposmm_pounders_splitcomm.py index 51798ea91..e21258b3f 100644 --- a/libensemble/tests/deprecated_tests/test_old_aposmm_pounders_splitcomm.py +++ b/libensemble/tests/deprecated_tests/test_old_aposmm_pounders_splitcomm.py @@ -48,7 +48,7 @@ # lb tries to avoid x[1]=-x[2], which results in division by zero in chwirut. gen_specs = {'gen_f': gen_f, - 'in': [o[0] for o in gen_out]+['f', 'fvec', 'returned'], + 'in': [o[0] for o in gen_out]+['f', 'fvec', 'sim_ended'], 'out': gen_out, 'user': {'initial_sample_size': 5, 'lb': (-2-np.pi/10)*np.ones(n), diff --git a/libensemble/tests/deprecated_tests/test_old_aposmm_pounders_subcomm.py b/libensemble/tests/deprecated_tests/test_old_aposmm_pounders_subcomm.py index fb1e3b312..6e2aff583 100644 --- a/libensemble/tests/deprecated_tests/test_old_aposmm_pounders_subcomm.py +++ b/libensemble/tests/deprecated_tests/test_old_aposmm_pounders_subcomm.py @@ -52,7 +52,7 @@ # lb tries to avoid x[1]=-x[2], which results in division by zero in chwirut. gen_specs = {'gen_f': gen_f, - 'in': [o[0] for o in gen_out]+['f', 'fvec', 'returned'], + 'in': [o[0] for o in gen_out]+['f', 'fvec', 'sim_ended'], 'out': gen_out, 'user': {'initial_sample_size': 5, 'lb': (-2-np.pi/10)*np.ones(n), diff --git a/libensemble/tests/deprecated_tests/test_old_aposmm_sim_dirs.py b/libensemble/tests/deprecated_tests/test_old_aposmm_sim_dirs.py index 9fbaadb14..a08e32185 100644 --- a/libensemble/tests/deprecated_tests/test_old_aposmm_sim_dirs.py +++ b/libensemble/tests/deprecated_tests/test_old_aposmm_sim_dirs.py @@ -47,7 +47,7 @@ n = 2 gen_out += [('x', float, n), ('x_on_cube', float, n)] gen_specs = {'gen_f': gen_f, - 'in': [o[0] for o in gen_out] + ['f', 'returned'], + 'in': [o[0] for o in gen_out] + ['f', 'sim_ended'], 'out': gen_out, 'user': {'lb': np.array([-5, 0]), 'ub': np.array([10, 15]), diff --git a/libensemble/tests/deprecated_tests/test_old_aposmm_with_gradients.py b/libensemble/tests/deprecated_tests/test_old_aposmm_with_gradients.py index bc16d0812..4767c0f1b 100644 --- a/libensemble/tests/deprecated_tests/test_old_aposmm_with_gradients.py +++ b/libensemble/tests/deprecated_tests/test_old_aposmm_with_gradients.py @@ -40,7 +40,7 @@ gen_out += [('x', float, n), ('x_on_cube', float, n)] gen_specs = {'gen_f': gen_f, - 'in': [o[0] for o in gen_out] + ['f', 'grad', 'returned'], + 'in': [o[0] for o in gen_out] + ['f', 'grad', 'sim_ended'], 'out': gen_out, 'user': {'initial_sample_size': 100, 'sample_points': np.round(minima, 1), diff --git a/libensemble/tests/regression_tests/skip_test_persistent_gp_multitask_ax.py b/libensemble/tests/regression_tests/skip_test_persistent_gp_multitask_ax.py index f662ab047..0572b85d5 100644 --- a/libensemble/tests/regression_tests/skip_test_persistent_gp_multitask_ax.py +++ b/libensemble/tests/regression_tests/skip_test_persistent_gp_multitask_ax.py @@ -98,7 +98,7 @@ def run_simulation(H, persis_info, sim_specs, libE_info): alloc_specs = { 'alloc_f': only_persistent_gens, - 'out': [('given_back', bool)], + 'out': [('gen_informed', bool)], 'user': {'async_return': False}, } diff --git a/libensemble/tests/regression_tests/test_evaluate_existing_sample.py b/libensemble/tests/regression_tests/test_evaluate_existing_sample.py index d2591f858..c29bd22b8 100644 --- a/libensemble/tests/regression_tests/test_evaluate_existing_sample.py +++ b/libensemble/tests/regression_tests/test_evaluate_existing_sample.py @@ -35,12 +35,12 @@ n_samp = 1000 n = 8 -H0 = np.zeros(n_samp, dtype=[('x', float, 8), ('sim_id', int), ('given', bool)]) +H0 = np.zeros(n_samp, dtype=[('x', float, 8), ('sim_id', int), ('sim_started', bool)]) np.random.seed(0) H0['x'] = gen_borehole_input(n_samp) H0['sim_id'] = range(n_samp) -H0['given'] = False +H0['sim_started'] = False alloc_specs = {'alloc_f': alloc_f, 'out': [('x', float, n)]} @@ -52,6 +52,6 @@ if is_manager: assert len(H) == len(H0) assert np.array_equal(H0['x'], H['x']) - assert np.all(H['returned']) + assert np.all(H['sim_ended']) print("\nlibEnsemble correctly didn't add anything to initial sample") save_libE_output(H, persis_info, __file__, nworkers) diff --git a/libensemble/tests/regression_tests/test_evaluate_mixed_sample.py b/libensemble/tests/regression_tests/test_evaluate_mixed_sample.py index 9cbe623af..31a7b1e41 100644 --- a/libensemble/tests/regression_tests/test_evaluate_mixed_sample.py +++ b/libensemble/tests/regression_tests/test_evaluate_mixed_sample.py @@ -27,24 +27,24 @@ sim_specs = { 'sim_f': sim_f, 'in': ['x'], - 'out': [('f', float, 8)], + 'out': [('f', float)], } gen_specs = {} -n_samp = 1000 +samp = 1000 n = 8 -H0 = np.zeros(n_samp, dtype=[('x', float, 8), ('f', float, 8), ('sim_id', int), ('given', bool), ('returned', bool)]) +H0 = np.zeros(samp, dtype=[('x', float, n), ('f', float), ('sim_id', int), ('sim_started', bool), ('sim_ended', bool)]) np.random.seed(0) -H0['x'] = gen_borehole_input(n_samp) +H0['x'] = gen_borehole_input(samp) for i in range(500): H0['f'][i] = borehole_func(H0['x'][i]) -H0['given'][:500] = True -H0['returned'][:500] = True +H0['sim_started'][:500] = True +H0['sim_ended'][:500] = True alloc_specs = {'alloc_f': alloc_f, 'out': [('x', float, n)]} @@ -56,6 +56,6 @@ if is_manager: assert len(H) == len(H0) assert np.array_equal(H0['x'], H['x']) - assert np.all(H['returned']) + assert np.all(H['sim_ended']) print("\nlibEnsemble correctly didn't add anything to initial sample") save_libE_output(H, persis_info, __file__, nworkers) diff --git a/libensemble/tests/regression_tests/test_executor_hworld_pass_fail.py b/libensemble/tests/regression_tests/test_executor_hworld_pass_fail.py index ccc63cb3d..8c94dd9d7 100644 --- a/libensemble/tests/regression_tests/test_executor_hworld_pass_fail.py +++ b/libensemble/tests/regression_tests/test_executor_hworld_pass_fail.py @@ -81,7 +81,7 @@ persis_info = add_unique_random_streams({}, nworkers + 1) -# num returned_count conditions in executor_hworld +# num sim_ended_count conditions in executor_hworld exit_criteria = {'sim_max': nworkers * 5} # Perform the run diff --git a/libensemble/tests/regression_tests/test_persistent_aposmm_dfols.py b/libensemble/tests/regression_tests/test_persistent_aposmm_dfols.py index 0513b785d..f7e97a8db 100644 --- a/libensemble/tests/regression_tests/test_persistent_aposmm_dfols.py +++ b/libensemble/tests/regression_tests/test_persistent_aposmm_dfols.py @@ -94,7 +94,7 @@ if is_manager: assert persis_info[1].get('run_order'), "Run_order should have been given back" assert flag == 0 - assert np.min(H['f'][H['returned']]) <= 3000, "Didn't find a value below 3000" + assert np.min(H['f'][H['sim_ended']]) <= 3000, "Didn't find a value below 3000" save_libE_output(H, persis_info, __file__, nworkers) diff --git a/libensemble/tests/regression_tests/test_persistent_aposmm_scipy.py b/libensemble/tests/regression_tests/test_persistent_aposmm_scipy.py index 0af6b17d4..a26c11f0c 100644 --- a/libensemble/tests/regression_tests/test_persistent_aposmm_scipy.py +++ b/libensemble/tests/regression_tests/test_persistent_aposmm_scipy.py @@ -124,4 +124,4 @@ H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, alloc_specs, libE_specs) if is_manager: - assert np.sum(H['returned']) >= exit_criteria['sim_max'], "Run didn't finish" + assert np.sum(H['sim_ended']) >= exit_criteria['sim_max'], "Run didn't finish" diff --git a/libensemble/tests/regression_tests/test_persistent_aposmm_with_grad.py b/libensemble/tests/regression_tests/test_persistent_aposmm_with_grad.py index c1b8d4d17..9b2d17441 100644 --- a/libensemble/tests/regression_tests/test_persistent_aposmm_with_grad.py +++ b/libensemble/tests/regression_tests/test_persistent_aposmm_with_grad.py @@ -58,7 +58,7 @@ ('local_pt', bool), ] -gen_in = ['x', 'f', 'grad', 'local_pt', 'sim_id', 'returned', 'x_on_cube', 'local_min'] +gen_in = ['x', 'f', 'grad', 'local_pt', 'sim_id', 'sim_ended', 'x_on_cube', 'local_min'] gen_specs = { 'gen_f': gen_f, @@ -92,10 +92,10 @@ ('grad', float, n), ('sim_id', int), ('x_on_cube', float, n), - ('returned', bool), + ('sim_ended', bool), ('f', float), - ('given_back', bool), - ('given', bool), + ('gen_informed', bool), + ('sim_started', bool), ] H0 = np.zeros(sample_size, dtype=H0_dtype) @@ -104,7 +104,7 @@ H0['x'] = np.round(minima, 1) H0['x_on_cube'] = (H0['x'] - gen_specs['user']['lb']) / (gen_specs['user']['ub'] - gen_specs['user']['lb']) H0['sim_id'] = range(sample_size) -H0[['given', 'given_back', 'returned']] = True +H0[['sim_started', 'gen_informed', 'sim_ended']] = True for i in range(sample_size): H0['f'][i] = six_hump_camel_func(H0['x'][i]) diff --git a/libensemble/tests/regression_tests/test_persistent_sim_uniform_sampling.py b/libensemble/tests/regression_tests/test_persistent_sim_uniform_sampling.py index f392eb3c8..6eab0ba27 100644 --- a/libensemble/tests/regression_tests/test_persistent_sim_uniform_sampling.py +++ b/libensemble/tests/regression_tests/test_persistent_sim_uniform_sampling.py @@ -69,7 +69,7 @@ H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, alloc_specs, libE_specs) if is_manager: - assert len(np.unique(H['gen_time'])) == 8 + assert len(np.unique(H['gen_ended_time'])) == 8 assert not any((H['f'] == 0)) # Should overwrite the last value (in fact last (nworker-1) values) with f(1,1) = 3.23333333 assert not np.isclose(H['f'][0], 3.23333333) diff --git a/libensemble/tests/regression_tests/test_persistent_surmise_calib.py b/libensemble/tests/regression_tests/test_persistent_surmise_calib.py index ca4caf170..66f529254 100644 --- a/libensemble/tests/regression_tests/test_persistent_surmise_calib.py +++ b/libensemble/tests/regression_tests/test_persistent_surmise_calib.py @@ -77,7 +77,7 @@ gen_specs = { 'gen_f': gen_f, - 'persis_in': [o[0] for o in gen_out] + ['f', 'returned', 'sim_id'], + 'persis_in': [o[0] for o in gen_out] + ['f', 'sim_ended', 'sim_id'], 'out': gen_out, 'user': { 'n_init_thetas': n_init_thetas, # Num thetas in initial batch @@ -114,6 +114,6 @@ if is_manager: print('Cancelled sims', H['sim_id'][H['cancel_requested']]) - sims_done = np.count_nonzero(H['returned']) + sims_done = np.count_nonzero(H['sim_ended']) save_libE_output(H, persis_info, __file__, nworkers) assert sims_done == max_evals, 'Num of completed simulations should be {}. Is {}'.format(max_evals, sims_done) diff --git a/libensemble/tests/regression_tests/test_persistent_surmise_killsims.py b/libensemble/tests/regression_tests/test_persistent_surmise_killsims.py index e127c0d34..b4c752206 100644 --- a/libensemble/tests/regression_tests/test_persistent_surmise_killsims.py +++ b/libensemble/tests/regression_tests/test_persistent_surmise_killsims.py @@ -97,7 +97,7 @@ gen_specs = { 'gen_f': gen_f, - 'persis_in': [o[0] for o in gen_out] + ['f', 'returned', 'sim_id'], + 'persis_in': [o[0] for o in gen_out] + ['f', 'sim_ended', 'sim_id'], 'out': gen_out, 'user': { 'n_init_thetas': n_init_thetas, # Num thetas in initial batch @@ -131,6 +131,6 @@ if is_manager: print('Cancelled sims', H['sim_id'][H['cancel_requested']]) print('Killed sims', H['sim_id'][H['kill_sent']]) - sims_done = np.count_nonzero(H['returned']) + sims_done = np.count_nonzero(H['sim_ended']) save_libE_output(H, persis_info, __file__, nworkers) assert sims_done == max_evals, 'Num of completed simulations should be {}. Is {}'.format(max_evals, sims_done) diff --git a/libensemble/tests/regression_tests/test_persistent_uniform_gen_decides_stop.py b/libensemble/tests/regression_tests/test_persistent_uniform_gen_decides_stop.py index 6d8590619..167874b22 100644 --- a/libensemble/tests/regression_tests/test_persistent_uniform_gen_decides_stop.py +++ b/libensemble/tests/regression_tests/test_persistent_uniform_gen_decides_stop.py @@ -71,11 +71,11 @@ H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, alloc_specs, libE_specs) if is_manager: - [_, counts] = np.unique(H['gen_time'], return_counts=True) + [_, counts] = np.unique(H['gen_ended_time'], return_counts=True) print('Num. points in each gen iteration:', counts) - assert counts[0] == nworkers, "The first gen_time should be common among initial_batch_size number of points" - assert counts[1] == nworkers, "The second gen_time should be common among initial_batch_size number of points" - assert len(np.unique(counts)) > 1, "There is no variablitiy in the gen_times but there should be for the async case" + assert counts[0] == nworkers, "The first gen_ended_time should be common among initial_batch_size number of points" + assert counts[1] == nworkers, "The second gen_ended_time should be common among initial_batch_size number of points" + assert len(np.unique(counts)) > 1, "All gen_ended_times are the same; they should be different for the async case" gen_workers = np.unique(H['gen_worker']) print('Generators that issued points', gen_workers) diff --git a/libensemble/tests/regression_tests/test_persistent_uniform_sampling.py b/libensemble/tests/regression_tests/test_persistent_uniform_sampling.py index 50dd41972..e3fcccaed 100644 --- a/libensemble/tests/regression_tests/test_persistent_uniform_sampling.py +++ b/libensemble/tests/regression_tests/test_persistent_uniform_sampling.py @@ -62,6 +62,6 @@ H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, alloc_specs, libE_specs) if is_manager: - assert len(np.unique(H['gen_time'])) == 2 + assert len(np.unique(H['gen_ended_time'])) == 2 save_libE_output(H, persis_info, __file__, nworkers) diff --git a/libensemble/tests/regression_tests/test_persistent_uniform_sampling_adv.py b/libensemble/tests/regression_tests/test_persistent_uniform_sampling_adv.py index 03f25f668..1277240e5 100644 --- a/libensemble/tests/regression_tests/test_persistent_uniform_sampling_adv.py +++ b/libensemble/tests/regression_tests/test_persistent_uniform_sampling_adv.py @@ -70,7 +70,7 @@ H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, alloc_specs, libE_specs) if is_manager: - assert len(np.unique(H['gen_time'])) == 1, "Everything should have been generated in one batch" + assert len(np.unique(H['gen_ended_time'])) == 1, "Everything should have been generated in one batch" if prob_id == 1: assert np.all(H['x'][0:sim_max] == -1.23), "The persistent gen should have set these at shutdown" diff --git a/libensemble/tests/regression_tests/test_persistent_uniform_sampling_async.py b/libensemble/tests/regression_tests/test_persistent_uniform_sampling_async.py index 2626f15dd..526c19426 100644 --- a/libensemble/tests/regression_tests/test_persistent_uniform_sampling_async.py +++ b/libensemble/tests/regression_tests/test_persistent_uniform_sampling_async.py @@ -64,9 +64,9 @@ H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, alloc_specs, libE_specs) if is_manager: - [_, counts] = np.unique(H['gen_time'], return_counts=True) + [_, counts] = np.unique(H['gen_ended_time'], return_counts=True) print('Num. points in each gen iteration:', counts) - assert counts[0] == nworkers, "The first gen_time should be common among initial_batch_size number of points" - assert len(np.unique(counts)) > 1, "There is no variablitiy in the gen_times but there should be for the async case" + assert counts[0] == nworkers, "The first gen_ended_time should be common among initial_batch_size number of points" + assert len(np.unique(counts)) > 1, "All gen_ended_times are the same; they should be different for the async case" save_libE_output(H, persis_info, __file__, nworkers) diff --git a/libensemble/tests/regression_tests/test_uniform_sampling_cancel.py b/libensemble/tests/regression_tests/test_uniform_sampling_cancel.py index 618570f1a..503a632b5 100644 --- a/libensemble/tests/regression_tests/test_uniform_sampling_cancel.py +++ b/libensemble/tests/regression_tests/test_uniform_sampling_cancel.py @@ -41,21 +41,21 @@ def create_H0(persis_info, gen_specs, sim_max): n = len(lb) b = sim_max - H0 = np.zeros(b, dtype=[('x', float, 2), ('sim_id', int), ('given', bool), ('cancel_requested', bool)]) + H0 = np.zeros(b, dtype=[('x', float, 2), ('sim_id', int), ('sim_started', bool), ('cancel_requested', bool)]) H0['x'] = persis_info[0]['rand_stream'].uniform(lb, ub, (b, n)) H0['sim_id'] = range(b) - H0['given'] = False + H0['sim_started'] = False for i in range(b): if i % 10 == 0: H0[i]['cancel_requested'] = True # Using uniform_random_sample_cancel call - need to adjust some gen_specs though # gen_specs['out'].append(('sim_id', int)) - # gen_specs['out'].append(('given', bool)) + # gen_specs['out'].append(('sim_started', bool)) # gen_specs['user']['gen_batch_size'] = sim_max # H0, persis_info[0] = uniform_random_sample_cancel({}, persis_info[0], gen_specs, {}) # H0['sim_id'] = range(gen_specs['user']['gen_batch_size']) - # H0['given'] = False + # H0['sim_started'] = False return H0 @@ -149,7 +149,7 @@ def create_H0(persis_info, gen_specs, sim_max): if is_manager: assert flag == 0 assert np.all(H['cancel_requested'][::10]), 'Some values should be cancelled but are not' - assert np.all(~H['given'][::10]), 'Some values are given that should not have been' + assert np.all(~H['sim_started'][::10]), 'Some values are given that should not have been' tol = 0.1 for m in minima: assert np.min(np.sum((H['x'] - m) ** 2, 1)) < tol diff --git a/libensemble/tests/scaling_tests/persistent_gp/run_example.py b/libensemble/tests/scaling_tests/persistent_gp/run_example.py index 8647a34bb..7b919a8f6 100644 --- a/libensemble/tests/scaling_tests/persistent_gp/run_example.py +++ b/libensemble/tests/scaling_tests/persistent_gp/run_example.py @@ -80,7 +80,7 @@ def run_simulation(H, persis_info, sim_specs, libE_info): alloc_specs = { 'alloc_f': only_persistent_gens, - 'out': [('given_back', bool)], + 'out': [('gen_informed', bool)], 'user': {'async_return': False}, } diff --git a/libensemble/tests/scaling_tests/warpx/plot_results.py b/libensemble/tests/scaling_tests/warpx/plot_results.py index 83fb9f68e..7b5a2b69b 100755 --- a/libensemble/tests/scaling_tests/warpx/plot_results.py +++ b/libensemble/tests/scaling_tests/warpx/plot_results.py @@ -34,7 +34,7 @@ nbatches = len(pickle_data[1]['run_order']) # Remove un-returned (i.e., not submitted) simulations -results = results[results['returned'] == 1] +results = results[results['sim_ended'] == 1] # Re-organize results into a dictionary. Each key is a field in libE_output, # each value is an array with the value of this field for all WarpX simulations diff --git a/libensemble/tests/unit_tests/test_allocation_funcs_and_support.py b/libensemble/tests/unit_tests/test_allocation_funcs_and_support.py index 03d8927be..7ee215021 100644 --- a/libensemble/tests/unit_tests/test_allocation_funcs_and_support.py +++ b/libensemble/tests/unit_tests/test_allocation_funcs_and_support.py @@ -18,15 +18,15 @@ dtype=[('worker_id', '= eval_max, "Standalone persistent_aposmm, didn't evaluate enough points" + assert np.sum(H['sim_ended']) >= eval_max, "Standalone persistent_aposmm, didn't evaluate enough points" assert persis_info.get('run_order'), "Standalone persistent_aposmm didn't do any localopt runs" tol = 1e-3 @@ -120,7 +120,7 @@ def combined_func(x): H, persis_info, exit_code = al.aposmm(H, persis_info, gen_specs, libE_info) assert exit_code == FINISHED_PERSISTENT_GEN_TAG, "Standalone persistent_aposmm didn't exit correctly" - assert np.sum(H['returned']) >= eval_max, "Standalone persistent_aposmm, didn't evaluate enough points" + assert np.sum(H['sim_ended']) >= eval_max, "Standalone persistent_aposmm, didn't evaluate enough points" assert persis_info.get('run_order'), "Standalone persistent_aposmm didn't do any localopt runs" diff --git a/libensemble/tests/unit_tests/tofix__test_worker.py b/libensemble/tests/unit_tests/tofix__test_worker.py index 28119bc51..77a7eaf51 100644 --- a/libensemble/tests/unit_tests/tofix__test_worker.py +++ b/libensemble/tests/unit_tests/tofix__test_worker.py @@ -19,7 +19,7 @@ def test_worker_init_run(): # check H['sim_id'][-L:] = -1 - H['given_time'][-L:] = np.inf + H['sim_started_time'][-L:] = np.inf # Create work sim_ids = np.zeros(1, dtype=int) diff --git a/libensemble/tools/alloc_support.py b/libensemble/tools/alloc_support.py index 03eb868a7..328e48cd7 100644 --- a/libensemble/tools/alloc_support.py +++ b/libensemble/tools/alloc_support.py @@ -237,44 +237,44 @@ def _filter_points(self, H_in, pt_filter, low_bound): pfilter = pt_filter return H, pfilter - def all_given(self, H, pt_filter=None, low_bound=None): - """Returns ``True`` if all expected points have been given to sim + def all_sim_started(self, H, pt_filter=None, low_bound=None): + """Returns ``True`` if all expected points have started their sim Excludes cancelled points. :param pt_filter: Optional boolean array filtering expected returned points in ``H``. :param low_bound: Optional lower bound for testing all returned. - :returns: True if all expected points have been returned + :returns: True if all expected points have started their sim """ H, pfilter = self._filter_points(H, pt_filter, low_bound) excluded_points = H['cancel_requested'] - return np.all(H['given'][pfilter & ~excluded_points]) + return np.all(H['sim_started'][pfilter & ~excluded_points]) - def all_returned(self, H, pt_filter=None, low_bound=None): - """Returns ``True`` if all expected points have returned from sim + def all_sim_ended(self, H, pt_filter=None, low_bound=None): + """Returns ``True`` if all expected points have had their sim_end - Excludes cancelled points that were not already given out. + Excludes cancelled points that were not already sim_started. :param pt_filter: Optional boolean array filtering expected returned points in ``H``. :param low_bound: Optional lower bound for testing all returned. - :returns: True if all expected points have been returned + :returns: True if all expected points have had their sim_end """ H, pfilter = self._filter_points(H, pt_filter, low_bound) - excluded_points = H['cancel_requested'] & ~H['given'] - return np.all(H['returned'][pfilter & ~excluded_points]) + excluded_points = H['cancel_requested'] & ~H['sim_started'] + return np.all(H['sim_ended'][pfilter & ~excluded_points]) - def all_given_back(self, H, pt_filter=None, low_bound=None): - """Returns ``True`` if all expected points have been given back to gen. + def all_gen_informed(self, H, pt_filter=None, low_bound=None): + """Returns ``True`` if gen has been informed of all expected points Excludes cancelled points that were not already given out. - :param pt_filter: Optional boolean array filtering expected returned points in ``H``. + :param pt_filter: Optional boolean array filtering expected sim_end points in ``H``. :param low_bound: Optional lower bound for testing all returned. - :returns: True if all expected points have been returned + :returns: True if gen have been informed of all expected points """ H, pfilter = self._filter_points(H, pt_filter, low_bound) - excluded_points = H['cancel_requested'] & ~H['given'] - return np.all(H['given_back'][pfilter & ~excluded_points]) + excluded_points = H['cancel_requested'] & ~H['sim_started'] + return np.all(H['gen_informed'][pfilter & ~excluded_points]) def points_by_priority(self, H, points_avail, batch=False): """Returns indices of points to give by priority diff --git a/libensemble/tools/check_inputs.py b/libensemble/tools/check_inputs.py index c2f1c569d..5c6c8861d 100644 --- a/libensemble/tools/check_inputs.py +++ b/libensemble/tools/check_inputs.py @@ -140,11 +140,11 @@ def check_H(H0, sim_specs, alloc_specs, gen_specs): format(set(fields).difference(set(Dummy_H.dtype.names))) # Prior history cannot contain unreturned points - # assert 'returned' not in fields or np.all(H0['returned']), \ + # assert 'sim_ended' not in fields or np.all(H0['sim_ended']), \ # "H0 contains unreturned points." # Fail if prior history contains unreturned points (or returned but not given). - assert('returned' not in fields or np.all(H0['given'] == H0['returned'])), \ + assert('sim_ended' not in fields or np.all(H0['sim_started'] == H0['sim_ended'])), \ 'H0 contains unreturned or invalid points' # # Fail if points in prior history don't have a sim_id. diff --git a/libensemble/tools/fields_keys.py b/libensemble/tools/fields_keys.py index 17da49313..6b45a7c6e 100644 --- a/libensemble/tools/fields_keys.py +++ b/libensemble/tools/fields_keys.py @@ -2,31 +2,35 @@ Below are the fields used within libEnsemble """ -libE_fields = [('sim_id', int), # Unique id of entry in H that was generated - ('gen_worker', int), # Worker that (first) generated the entry - ('gen_time', float), # Time (since epoch) entry (first) was entered into H from a gen - ('last_gen_time', float), # Time (since epoch) entry was last requested by a gen - ('given', bool), # True if entry has been given for sim eval - ('given_time', float), # Time (since epoch) that the entry was (first) given to be evaluated - ('last_given_time', float), # Time (since epoch) that the entry was last given to be evaluated - ('last_given_back_time', float), # Time (since epoch) that the entry was last given back to the gen - ('returned', bool), # True if entry has been returned from sim eval - ('returned_time', float), # Time entry was (last) returned from sim eval - ('sim_worker', int), # Worker that did (or is doing) the sim eval - ('cancel_requested', bool), # True if cancellation of this entry is requested - ('kill_sent', bool), # True if a kill signal has been sent to worker - ('given_back', bool) # True if entry has been given back to the gen after evaluation. + +libE_fields = [('sim_id', int), # Unique id of a generated entry in H + ('gen_worker', int), # Worker that generated this entry + ('gen_started_time', float), # Time gen_worker was initiated that produced this entry + ('gen_ended_time', float), # Time gen_worker requested this entry + ('sim_worker', int), # Worker that did (or is doing) the sim eval for this entry + ('sim_started', bool), # True if entry was given to sim_worker for sim eval + ('sim_started_time', float), # Time entry was given to sim_worker for a sim eval + ('sim_ended', bool), # True if entry's sim eval completed + ('sim_ended_time', float), # Time entry's sim eval completed + ('gen_informed', bool), # True if gen_worker was informed about the sim eval of this entry + ('gen_informed_time', float), # Time gen_worker was informed about the sim eval of this entry + ('cancel_requested', bool), # True if cancellation was requested for this entry + ('kill_sent', bool), # True if a kill signal was sent to worker for this entry ] # end_libE_fields_rst_tag + protected_libE_fields = ['gen_worker', - 'gen_time', - 'given', - 'given_time', - 'returned', - 'returned_time', - 'given_back', - 'sim_worker'] + 'gen_started_time', + 'gen_ended_time', + 'sim_worker', + 'sim_started', + 'sim_started_time', + 'sim_ended', + 'sim_ended_time', + 'gen_informed', + 'gen_informed_time', + 'kill_sent'] allowed_sim_spec_keys = ['sim_f', # 'in', # diff --git a/libensemble/tools/tools.py b/libensemble/tools/tools.py index ddca20946..216d68abb 100644 --- a/libensemble/tools/tools.py +++ b/libensemble/tools/tools.py @@ -103,7 +103,7 @@ def save_libE_output(H, persis_info, calling_file, nworkers, mess='Run completed script_name = os.path.splitext(os.path.basename(calling_file))[0] short_name = script_name.split("test_", 1).pop() prob_str = 'length=' + str(len(H)) \ - + '_evals=' + str(sum(H['returned'])) \ + + '_evals=' + str(sum(H['sim_ended'])) \ + '_workers=' + str(nworkers) h_filename = short_name + '_history_' + prob_str diff --git a/postproc_scripts/compare_npy.py b/postproc_scripts/compare_npy.py index b22b7b8ed..2b8f9a346 100755 --- a/postproc_scripts/compare_npy.py +++ b/postproc_scripts/compare_npy.py @@ -28,7 +28,7 @@ ./compare_npy.py out1.npy out2.npy --rtol 1e-03 --atol 1e-06 ''' -exclude_fields = ['gen_worker', 'sim_worker', 'gen_time', 'given_time'] # list of fields to ignore +exclude_fields = ['gen_worker', 'sim_worker', 'gen_ended_time', 'sim_started_time'] # list of fields to ignore locate_mismatch = True parser = argparse.ArgumentParser(description=desc, epilog=example, diff --git a/postproc_scripts/print_npy.py b/postproc_scripts/print_npy.py index 6a82e2854..b826d3c70 100755 --- a/postproc_scripts/print_npy.py +++ b/postproc_scripts/print_npy.py @@ -23,13 +23,13 @@ if done_only: count = 0 for line in results: - if line['returned']: + if line['sim_ended']: count += 1 results_filtered = np.zeros(count, dtype=results.dtype) count = 0 for i, line in enumerate(results): - if line['returned']: + if line['sim_ended']: results_filtered[count] = results[i] count += 1 diff --git a/postproc_scripts/readme.rst b/postproc_scripts/readme.rst index 022c2495c..765950958 100644 --- a/postproc_scripts/readme.rst +++ b/postproc_scripts/readme.rst @@ -25,7 +25,7 @@ Results analysis scripts * ``print_npy.py``: Prints to screen from a given ``*.npy`` file containing a NumPy structured array. Use ``done`` to print only the lines containing - ``'returned'`` points. Example:: + ``'sim_ended'`` points. Example:: ./print_npy.py run_libe_forces_results_History_length=1000_evals=8.npy done