@@ -36,42 +36,68 @@ Basic Usage
3636===========
3737
3838Create an ``Ensemble ``, then customize it with general settings, simulation and generator parameters,
39- and an exit condition. Run the following via ``python this_file.py --comms local --nworkers 4 ``:
39+ and an exit condition. Run the following four-worker example via ``python this_file.py ``:
4040
4141.. code-block :: python
4242
43- import numpy as np
44-
45- from libensemble import Ensemble
46- from libensemble.gen_funcs.sampling import uniform_random_sample
47- from libensemble.sim_funcs.six_hump_camel import six_hump_camel
48- from libensemble.specs import ExitCriteria, GenSpecs, SimSpecs
49- from libensemble.tools import add_unique_random_streams
50-
51- if __name__ == " __main__" :
52- sampling = Ensemble(parse_args = True )
53- sampling.sim_specs = SimSpecs(
54- sim_f = six_hump_camel,
55- inputs = [" x" ],
56- outputs = [(" f" , float )],
57- )
58- sampling.gen_specs = GenSpecs(
59- gen_f = uniform_random_sample,
60- outputs = [(" x" , float , (2 ,))],
61- user = {
62- " gen_batch_size" : 500 ,
63- " lb" : np.array([- 3 , - 2 ]),
64- " ub" : np.array([3 , 2 ]),
65- },
66- )
67-
68- sampling.persis_info = add_unique_random_streams({}, sampling.nworkers + 1 )
69- sampling.exit_criteria = ExitCriteria(sim_max = 101 )
70- sampling.run()
71- sampling.save_output(__file__ )
72-
73- if sampling.is_manager:
74- print (" Some output data:\n " , sampling.H[[" x" , " f" ]][:10 ])
43+ import numpy as np
44+
45+ from libensemble import Ensemble
46+ from libensemble.gen_funcs.sampling import uniform_random_sample
47+ from libensemble.sim_funcs.six_hump_camel import six_hump_camel
48+ from libensemble.specs import ExitCriteria, GenSpecs, LibeSpecs, SimSpecs
49+
50+ if __name__ == " __main__" :
51+
52+ libE_specs = LibeSpecs(nworkers = 4 )
53+
54+ sim_specs = SimSpecs(
55+ sim_f = six_hump_camel,
56+ inputs = [" x" ],
57+ outputs = [(" f" , float )],
58+ )
59+
60+ gen_specs = GenSpecs(
61+ gen_f = uniform_random_sample,
62+ outputs = [(" x" , float , (2 ,))],
63+ user = {
64+ " gen_batch_size" : 50 ,
65+ " lb" : np.array([- 3 , - 2 ]),
66+ " ub" : np.array([3 , 2 ]),
67+ },
68+ )
69+
70+ exit_criteria = ExitCriteria(sim_max = 100 )
71+
72+ sampling = Ensemble(
73+ libE_specs = libE_specs,
74+ sim_specs = sim_specs,
75+ gen_specs = gen_specs,
76+ exit_criteria = exit_criteria,
77+ )
78+
79+ sampling.add_random_streams()
80+ sampling.run()
81+
82+ if sampling.is_manager:
83+ sampling.save_output(__file__ )
84+ print (" Some output data:\n " , sampling.H[[" x" , " f" ]][:10 ])
85+
86+ |Inline Example |
87+
88+ Try some other examples live in Colab.
89+
90+ +---------------------------------------------------------------+-------------------------------------+
91+ | Description | Try online |
92+ +===============================================================+=====================================+
93+ | Simple Ensemble that makes a Sine wave. | |Simple Ensemble | |
94+ +---------------------------------------------------------------+-------------------------------------+
95+ | Ensemble with an MPI application. | |Ensemble with an MPI application | |
96+ +---------------------------------------------------------------+-------------------------------------+
97+ | Optimization example that finds multiple minima. | |Optimization example | |
98+ +---------------------------------------------------------------+-------------------------------------+
99+
100+ There are many more examples in the `regression tests `_.
75101
76102Resources
77103=========
@@ -139,3 +165,16 @@ Resources
139165.. _PyPI : https://pypi.org
140166.. _Quickstart : https://libensemble.readthedocs.io/en/main/introduction.html
141167.. _ReadtheDocs : http://libensemble.readthedocs.org/
168+ .. _regression tests : https://github.com/Libensemble/libensemble/tree/main/libensemble/tests/regression_tests
169+
170+ .. |Inline Example | image :: https://colab.research.google.com/assets/colab-badge.svg
171+ :target: http://colab.research.google.com/github/Libensemble/libensemble/blob/develop/examples/readme_notebook.ipynb
172+
173+ .. |Simple Ensemble | image :: https://colab.research.google.com/assets/colab-badge.svg
174+ :target: http://colab.research.google.com/github/Libensemble/libensemble/blob/develop/examples/tutorials/simple_sine/sine_tutorial_notebook.ipynb
175+
176+ .. |Ensemble with an MPI application | image :: https://colab.research.google.com/assets/colab-badge.svg
177+ :target: http://colab.research.google.com/github/Libensemble/libensemble/blob/develop/examples/tutorials/forces_with_executor/forces_tutorial_notebook.ipynb
178+
179+ .. |Optimization example | image :: https://colab.research.google.com/assets/colab-badge.svg
180+ :target: http://colab.research.google.com/github/Libensemble/libensemble/blob/develop/examples/tutorials/aposmm/aposmm_tutorial_notebook.ipynb
0 commit comments