Skip to content

Commit

Permalink
Merge pull request #342 from Libensemble/feature/alloc_default_adjust
Browse files Browse the repository at this point in the history
move default alloc_specs from libE() definition to alloc_funcs.defaults
  • Loading branch information
jlnav committed Jan 27, 2020
2 parents 5185a22 + 68a81ae commit 8165094
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
14 changes: 12 additions & 2 deletions docs/data_structures/alloc_specs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@ to main ``libE()`` routine::
Default: {'batch_mode': True}

.. note::

* The alloc_specs has the default keys as given above but may be overidden by the user.
* The tuples defined in the 'out' list are entered into the master :ref:`history array<datastruct-history-array>`.
* libEnsemble uses the following defaults if the user doesn't provide their own ``alloc_specs``:

.. literalinclude:: ../../libensemble/alloc_funcs/defaults.py
:end-before: end_alloc_specs_rst_tag
:caption: /libensemble/alloc_funcs/defaults.py

* Users can import and adjust these defaults using:

.. code-block:: python
from libensemble.alloc_funcs import defaults
alloc_specs = defaults.alloc_specs
.. seealso::
- `test_chwirut_uniform_sampling_one_residual_at_a_time.py`_ specifies fields
Expand Down
6 changes: 6 additions & 0 deletions libensemble/alloc_funcs/defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from libensemble.alloc_funcs.give_sim_work_first import give_sim_work_first

alloc_specs = {'alloc_f': give_sim_work_first,
'out': [('allocated', bool)],
'user': {'batch_mode': True, 'num_active_gens': 1}}
# end_alloc_specs_rst_tag
10 changes: 6 additions & 4 deletions libensemble/libE.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from libensemble.history import History
from libensemble.libE_manager import manager_main, ManagerException
from libensemble.libE_worker import worker_main
from libensemble.alloc_funcs.give_sim_work_first import give_sim_work_first
from libensemble.alloc_funcs import defaults as alloc_defaults
from libensemble.comms.comms import QCommProcess, Timeout
from libensemble.comms.logs import manager_logging_config
from libensemble.comms.tcp_mgr import ServerQCommManager, ClientQCommManager
Expand All @@ -41,9 +41,7 @@

def libE(sim_specs, gen_specs, exit_criteria,
persis_info={},
alloc_specs={'alloc_f': give_sim_work_first,
'out': [('allocated', bool)],
'user': {'batch_mode': True, 'num_active_gens': 1}},
alloc_specs={},
libE_specs={},
H0=[]):
"""
Expand Down Expand Up @@ -111,6 +109,10 @@ def libE(sim_specs, gen_specs, exit_criteria,
3 = Current process is not in libEnsemble MPI communicator
"""

# Set default alloc_specs
if not alloc_specs:
alloc_specs = alloc_defaults.alloc_specs

# Set default comms
if 'comms' not in libE_specs:
libE_specs['comms'] = 'mpi'
Expand Down

0 comments on commit 8165094

Please sign in to comment.