Skip to content

Commit

Permalink
switch many user-facing examples to update ensemble's persis_info usi…
Browse files Browse the repository at this point in the history
…ng add_unique_random_streams function
  • Loading branch information
jlnav committed Sep 6, 2023
1 parent 52e9c7e commit 4ddf6d4
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion libensemble/tests/regression_tests/test_1d_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# Import libEnsemble items for this test
from libensemble.sim_funcs.one_d_func import one_d_example as sim_f
from libensemble.specs import ExitCriteria, GenSpecs, LibeSpecs, SimSpecs
from libensemble.tools import add_unique_random_streams

# Main block is necessary only when using local comms with spawn start method (default on macOS and Windows).
if __name__ == "__main__":
Expand All @@ -38,7 +39,7 @@
},
)

sampling.add_random_streams()
sampling.persis_info = add_unique_random_streams({}, sampling.nworkers + 1)
sampling.exit_criteria = ExitCriteria(gen_max=501)

sampling.run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from libensemble.sim_funcs import six_hump_camel
from libensemble.sim_funcs.var_resources import gpu_variable_resources_from_gen as sim_f
from libensemble.specs import AllocSpecs, ExitCriteria, GenSpecs, LibeSpecs, SimSpecs
from libensemble.tools import add_unique_random_streams

# from libensemble import logger
# logger.set_level("DEBUG") # For testing the test
Expand Down Expand Up @@ -83,7 +84,7 @@
},
)

gpu_test.add_random_streams()
gpu_test.persis_info = add_unique_random_streams({}, gpu_test.nworkers + 1)
gpu_test.exit_criteria = ExitCriteria(sim_max=40)
gpu_test.run()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from libensemble.sim_funcs import six_hump_camel
from libensemble.sim_funcs.var_resources import gpu_variable_resources_from_gen as sim_f
from libensemble.specs import AllocSpecs, ExitCriteria, GenSpecs, LibeSpecs, SimSpecs
from libensemble.tools import add_unique_random_streams

# from libensemble import logger
# logger.set_level("DEBUG") # For testing the test
Expand Down Expand Up @@ -95,7 +96,7 @@
},
)

gpu_test.add_random_streams()
gpu_test.persis_info = add_unique_random_streams({}, gpu_test.nworkers + 1)
gpu_test.exit_criteria = ExitCriteria(sim_max=40, wallclock_max=300)

if gpu_test.ready():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from libensemble.gen_funcs.persistent_inverse_bayes import persistent_updater_after_likelihood as gen_f
from libensemble.sim_funcs.inverse_bayes import likelihood_calculator as sim_f
from libensemble.specs import AllocSpecs, ExitCriteria, GenSpecs, SimSpecs
from libensemble.tools import add_unique_random_streams

# Main block is necessary only when using local comms with spawn start method (default on macOS and Windows).
if __name__ == "__main__":
Expand Down Expand Up @@ -57,7 +58,7 @@
alloc_specs=AllocSpecs(alloc_f=alloc_f),
)

bayes_test.add_random_streams()
bayes_test.persis_info = add_unique_random_streams({}, bayes_test.nworkers + 1)
gen_user = bayes_test.gen_specs.user
val = gen_user["subbatch_size"] * gen_user["num_subbatches"] * gen_user["num_batches"]
bayes_test.exit_criteria = ExitCriteria(sim_max=val, wallclock_max=300)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from libensemble.sim_funcs.noisy_vector_mapping import func_wrapper as sim_f
from libensemble.sim_funcs.noisy_vector_mapping import noisy_function
from libensemble.specs import AllocSpecs, ExitCriteria, GenSpecs, SimSpecs
from libensemble.tools import add_unique_random_streams

# Main block is necessary only when using local comms with spawn start method (default on macOS and Windows).
if __name__ == "__main__":
Expand Down Expand Up @@ -62,7 +63,7 @@
alloc_specs=AllocSpecs(alloc_f=alloc_f),
exit_criteria=ExitCriteria(gen_max=1000),
)
fd_test.add_random_streams()
fd_test.persis_info = add_unique_random_streams({}, fd_test.nworkers + 1)

shutil.copy("./scripts_used_by_reg_tests/ECnoise.m", "./")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from libensemble.sim_funcs.surmise_test_function import borehole as sim_f
from libensemble.sim_funcs.surmise_test_function import tstd2theta
from libensemble.specs import AllocSpecs, ExitCriteria, GenSpecs, SimSpecs
from libensemble.tools import add_unique_random_streams

if __name__ == "__main__":

Expand Down Expand Up @@ -100,7 +101,7 @@
exit_criteria=ExitCriteria(sim_max=max_evals),
)

test.add_random_streams()
test.persis_info = add_unique_random_streams({}, test.nworkers + 1)

# Perform the run
H, _, _ = test.run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from libensemble.ensemble import Ensemble
from libensemble.executors.mpi_executor import MPIExecutor
from libensemble.tools import add_unique_random_streams

####################

Expand Down Expand Up @@ -36,7 +37,7 @@
}
)

forces.add_random_streams()
forces.persis_info = add_unique_random_streams({}, forces.nworkers + 1)

forces.run()
forces.save_output(__file__)

0 comments on commit 4ddf6d4

Please sign in to comment.