Skip to content

Latest commit

 

History

History
72 lines (54 loc) · 2.76 KB

extras.rst

File metadata and controls

72 lines (54 loc) · 2.76 KB

Extras and Plugins

Running in Parallel using libEnsemble

libEnsemble is a Python library to "coordinate concurrent evaluation of dynamic ensembles of calculations." Read more about libEnsemble by visiting the libEnsemble documentation.

The :mod:`libE_MOOP <extras.libe.libE_MOOP>` class is used to solve MOOPs using libEnsemble. The :mod:`libE_MOOP <extras.libe.libE_MOOP>` class inherits from :mod:`MOOP <moop.MOOP>` and supports all of the public methods in its API.

To create an instance of the :mod:`libE_MOOP <extras.libe.libE_MOOP>` class, import it from the :mod:`extras.libe` module and then create a MOOP, just as you normally would. The :meth:`solve() <extras.libe.libE_MOOP.solve>` method has been redefined to create a libEnsemble Persistent Generator function, which libEnsemble can call to generate batches of simulation evaluations, which it will distribute over available resources.

Below we reproduce the example from the :doc:`Quickstart <quickstart>` guide, using a :mod:`libE_MOOP <extras.libe.libE_MOOP>` object.

Note that it is always recommended that you turn on :meth:`checkpointing <moop.MOOP.setCheckpoint>` when using libEnsemble. Since :meth:`setCheckpoint <moop.MOOP.setCheckpoint>` method does not support the usage of Python lambda functions, each of the objectives and constraints is explicitly defined.

.. literalinclude:: ../examples/libe_basic_ex.py
    :language: python

To run a ParMOO/libEnsemble script, first make sure that libEnsemble is installed. You can find instructions on how to do so under libEnsemble's Advanced Installation documentation.

Next, run libEnsemble as described in the Running libEnsemble section. Common methods of running a libEnsemble script are with MPI

mpirun -np N python3 libe_basic_ex.py

and with Python's built-in multiprocessing module.

python3 libe_basic_ex.py --comms local --nworkers N

  • Note: When running a libE_MOOP with Python multiprocessing, MacOS and Windows systems default to using the spawn method. When using the spawn method, one must enclose the libE_MOOP.solve() command inside an if __name__ == '__main__': block, as shown in the example above. Read more about the issue here:

    https://libensemble.readthedocs.io/en/main/running_libE.html#local-comms

The result from running the example is shown below.

.. literalinclude:: ../examples/libe_basic_ex.out