Skip to content

Commit

Permalink
add a quick code-sample to Ensemble class doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jlnav committed May 11, 2023
1 parent 53d4bd8 commit 8256bba
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions libensemble/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@ class Ensemble:
"""
The primary class for a libEnsemble workflow.
.. dropdown:: Example
:open:
.. code-block:: python
:linenos:
from libensemble import Ensemble, SimSpecs, GenSpecs, ExitCriteria
from my_simulator import beamline
from someones_optimizer import optimize
experiment = Ensemble()
experiment.sim_specs = SimSpecs(sim_f=beamline, inputs=["x"], out=[("f", float)])
experiment.gen_specs = GenSpecs(
gen_f=optimize,
inputs=["f"],
out=[("x", float, (1,))],
user={
"lb": np.array([-3]),
"ub": np.array([3]),
},
)
experiment.exit_criteria = ExitCriteria(gen_max=101)
results = experiment.run()
Parses ``--comms``, ``--nworkers``,
and other options from the command-line, validates inputs, configures logging,
and performs other preparations.
Expand Down

0 comments on commit 8256bba

Please sign in to comment.