Skip to content

Commit 75c646b

Browse files
authored
Merge pull request #1371 from Libensemble/release/v_1.4.0
Release/v 1.4.0
2 parents c983f85 + fe7dc4b commit 75c646b

2 files changed

Lines changed: 36 additions & 42 deletions

File tree

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ and an exit condition. Run the following four-worker example via ``python this_f
5959
6060
gen_specs = GenSpecs(
6161
gen_f=uniform_random_sample,
62-
outputs=[("x", float, (2,))],
62+
outputs=[("x", float, 2)],
6363
user={
6464
"gen_batch_size": 50,
6565
"lb": np.array([-3, -2]),

examples/tutorials/forces_with_executor/forces_tutorial_notebook.ipynb

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
" task = exctr.submit(app_name=\"forces\", app_args=args, num_procs=1)\n",
182182
"\n",
183183
" # Block until the task finishes\n",
184-
" task.wait(timeout=60)\n",
184+
" task.wait()\n",
185185
"\n",
186186
" output, calc_status = read_output(sim_specs)\n",
187187
"\n",
@@ -232,11 +232,11 @@
232232
"import numpy as np\n",
233233
"from pprint import pprint\n",
234234
"\n",
235-
"# from forces_simf import run_forces # Sim func from current dir\n",
235+
"# from forces_simf import run_forces # Use is sim function is in a file\n",
236236
"\n",
237237
"from libensemble import Ensemble\n",
238+
"from libensemble.specs import ExitCriteria, GenSpecs, LibeSpecs, SimSpecs\n",
238239
"from libensemble.gen_funcs.sampling import uniform_random_sample\n",
239-
"from libensemble.tools import add_unique_random_streams\n",
240240
"from libensemble.executors import MPIExecutor\n",
241241
"\n",
242242
"# Initialize MPI Executor\n",
@@ -266,32 +266,27 @@
266266
"metadata": {},
267267
"outputs": [],
268268
"source": [
269-
"nworkers = 2\n",
270-
"\n",
271269
"# Global settings - including creating directories for each simulation\n",
272-
"libE_specs = {\n",
273-
" \"nworkers\": nworkers,\n",
274-
" \"comms\": \"local\",\n",
275-
" \"sim_dirs_make\": True,\n",
276-
"}\n",
277-
"\n",
278-
"# State the sim_f, inputs, outputs\n",
279-
"sim_specs = {\n",
280-
" \"sim_f\": run_forces,\n",
281-
" \"in\": [\"x\"], # Name of input for sim_f (defined in gen_specs[\"out\"])\n",
282-
" \"out\": [(\"energy\", float)],\n",
283-
"}\n",
284-
"\n",
285-
"# State the gen_f, inputs, outputs, additional parameters\n",
286-
"gen_specs = {\n",
287-
" \"gen_f\": uniform_random_sample,\n",
288-
" \"out\": [(\"x\", float, (1,))],\n",
289-
" \"user\": {\n",
270+
"libE_specs = LibeSpecs(\n",
271+
" nworkers=2,\n",
272+
" sim_dirs_make=True,\n",
273+
")\n",
274+
"\n",
275+
"gen_specs = GenSpecs(\n",
276+
" gen_f=uniform_random_sample,\n",
277+
" outputs=[(\"x\", float, (1,))],\n",
278+
" user={\n",
290279
" \"lb\": np.array([1000]), # min particles\n",
291280
" \"ub\": np.array([3000]), # max particles\n",
292281
" \"gen_batch_size\": 8,\n",
293282
" },\n",
294-
"}"
283+
")\n",
284+
"\n",
285+
"sim_specs = SimSpecs(\n",
286+
" sim_f=run_forces,\n",
287+
" inputs=[\"x\"], # Name of input for sim_f (defined in gen_specs.outputs)\n",
288+
" outputs=[(\"energy\", float)],\n",
289+
")"
295290
]
296291
},
297292
{
@@ -308,10 +303,7 @@
308303
"outputs": [],
309304
"source": [
310305
"# Instruct libEnsemble to exit after this many simulations\n",
311-
"exit_criteria = {\"sim_max\": 8}\n",
312-
"\n",
313-
"# Seed random streams for each worker, particularly for gen_f\n",
314-
"persis_info = add_unique_random_streams({}, nworkers + 1)\n",
306+
"exit_criteria = ExitCriteria(sim_max=8)\n",
315307
"\n",
316308
"# Initialize ensemble object, passing executor.\n",
317309
"ensemble = Ensemble(\n",
@@ -320,8 +312,10 @@
320312
" gen_specs=gen_specs,\n",
321313
" sim_specs=sim_specs,\n",
322314
" exit_criteria=exit_criteria,\n",
323-
" persis_info=persis_info,\n",
324-
")"
315+
")\n",
316+
"\n",
317+
"# Seed random streams for each worker, particularly for gen_f\n",
318+
"ensemble.add_random_streams()"
325319
]
326320
},
327321
{
@@ -559,19 +553,17 @@
559553
"input_file = \"forces_input\"\n",
560554
"\n",
561555
"# Add a field to libE_specs\n",
562-
"libE_specs[\"sim_dir_copy_files\"] = [input_file]\n",
563-
"ensemble.libE_specs = libE_specs\n",
564-
"\n",
565-
"ensemble.sim_specs = {\n",
566-
" \"sim_f\": run_forces_using_file,\n",
567-
" \"in\": [\"x\"], # Name of input for sim_f (defined in gen_specs[\"out\"])\n",
568-
" \"out\": [(\"energy\", float)],\n",
569-
" \"user\": {\"input_filename\": input_file, \"input_names\": [\"particles\"]},\n",
570-
"}\n",
556+
"ensemble.libE_specs.sim_dir_copy_files = [input_file]\n",
571557
"\n",
558+
"ensemble.sim_specs = SimSpecs(\n",
559+
" sim_f=run_forces_using_file,\n",
560+
" inputs=[\"x\"], # Name of input for sim_f (defined in gen_specs.outputs)\n",
561+
" outputs=[(\"energy\", float)],\n",
562+
" user={\"input_filename\": input_file, \"input_names\": [\"particles\"]},\n",
563+
")\n",
572564
"\n",
573565
"# To reset random number seed in the generator\n",
574-
"ensemble.persis_info = add_unique_random_streams({}, nworkers + 1)\n",
566+
"ensemble.add_random_streams()\n",
575567
"\n",
576568
"# Clean up any previous outputs and launch libEnsemble\n",
577569
"cleanup()\n",
@@ -595,7 +587,9 @@
595587
{
596588
"cell_type": "code",
597589
"execution_count": null,
598-
"metadata": {},
590+
"metadata": {
591+
"scrolled": false
592+
},
599593
"outputs": [],
600594
"source": [
601595
"! ls -l ensemble/sim*"

0 commit comments

Comments
 (0)