Skip to content

Commit 9f2f547

Browse files
committed
Update simple examples
1 parent 38d1de8 commit 9f2f547

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ and an exit condition. Run the following four-worker example via ``python this_f
6161
gen_f=uniform_random_sample,
6262
outputs=[("x", float, (2,))],
6363
user={
64-
"gen_batch_size": 500,
64+
"gen_batch_size": 50,
6565
"lb": np.array([-3, -2]),
6666
"ub": np.array([3, 2]),
6767
},
6868
)
6969
70-
exit_criteria = ExitCriteria(sim_max=101)
70+
exit_criteria = ExitCriteria(sim_max=100)
7171
7272
sampling = Ensemble(
7373
libE_specs=libE_specs,

libensemble/ensemble.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ class Ensemble:
5050
from libensemble import Ensemble
5151
from libensemble.gen_funcs.sampling import latin_hypercube_sample
5252
from libensemble.sim_funcs.simple_sim import norm_eval
53-
from libensemble.specs import ExitCriteria, GenSpecs, SimSpecs
53+
from libensemble.specs import ExitCriteria, GenSpecs, LibeSpecs, SimSpecs
5454
55-
sampling = Ensemble(parse_args=True)
55+
libE_specs = LibeSpecs(nworkers=4)
56+
sampling = Ensemble(libE_specs=libE_specs)
5657
sampling.sim_specs = SimSpecs(
5758
sim_f=norm_eval,
5859
inputs=["x"],
@@ -69,13 +70,17 @@ class Ensemble:
6970
)
7071
7172
sampling.add_random_streams()
72-
sampling.exit_criteria = ExitCriteria(sim_max=101)
73+
sampling.exit_criteria = ExitCriteria(sim_max=100)
7374
7475
if __name__ == "__main__":
7576
sampling.run()
7677
sampling.save_output(__file__)
7778
78-
Run the above example via ``python this_file.py -n 4`` (4 workers). The ``parse_args=True`` parameter
79+
80+
Run the above example via ``python this_file.py``.
81+
82+
Instead of using the libE_specs line, you can also use ``sampling = Ensemble(parse_args=True)``
83+
and run via ``python this_file.py -n 4`` (4 workers). The ``parse_args=True`` parameter
7984
instructs the Ensemble class to read command-line arguments.
8085
8186
Configure by:

0 commit comments

Comments
 (0)