'components': m } } alloc_specs = { 'alloc_f': give_sim_work_first, # Allocation function 'out': [('allocated', bool)], # Output fields (included in History) 'user': { 'stop_on_NaNs': True, # Should alloc preempt evals 'batch_mode': True, # Wait until all sim evals are done 'stop_partial_fvec_eval': True } # Should alloc preempt evals } # end_alloc_specs_rst_tag persis_info = add_unique_random_streams(persis_info, nworkers + 1) persis_info_safe = deepcopy(persis_info) exit_criteria = {'sim_max': budget, 'elapsed_wallclock_time': 300} # Perform the run H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, alloc_specs, libE_specs) if is_master: assert flag == 0 save_libE_output(H, persis_info, __file__, nworkers) # Perform the run but not stopping on NaNs alloc_specs['user'].pop('stop_on_NaNs') persis_info = deepcopy(persis_info_safe) H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info,
'gen_f': gen_random_sample, # Our generator function 'out': [('x', float, (1, ))], # gen_f output (name, type, size). 'user': { 'lower': np.array([-3]), # random sampling lower bound 'upper': np.array([3]), # random sampling upper bound 'gen_batch_size': 5 # number of values gen_f will generate per call } } sim_specs = { 'sim_f': sim_find_sine, # Our simulator function 'in': ['x'], # Input field names. 'x' from gen_f output 'out': [('y', float)] } # sim_f output. 'y' = sine('x') persis_info = add_unique_random_streams( {}, nworkers + 1) # Intitialize manager/workers random streams exit_criteria = {'sim_max': 80} # Stop libEnsemble after 80 simulations H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs) # Some (optional) statements to visualize our History array print([i for i in H.dtype.fields]) print(H) colors = ['b', 'g', 'r', 'y', 'm', 'c', 'k', 'w']