Holds persistent information that can be updated during the ensemble.
An initialized persis_info dictionary can be provided to the libE() call
or as an attribute of the Ensemble class.
Dictionary keys that have an integer value contain entries that are passed to
and from the corresponding workers. These are received in the persis_info
argument of user functions, and returned as the optional second return value.
A typical example is a random number generator stream to be used in consecutive calls to a generator. Generators should initialize their own RNG using :meth:`get_rng()<tools.get_rng>`.
All other entries persist on the manager and can be updated in the calling script between ensemble invocations, or in the allocation function.
Examples:
.. tab-set::
.. tab-item:: RNG or reusable structures
.. literalinclude:: ../../libensemble/gen_funcs/sampling.py
:linenos:
:start-at: def uniform_random_sample(_, persis_info, gen_specs):
:end-before: def uniform_random_sample_with_variable_resources(_, persis_info, gen_specs):
:emphasize-lines: 17
:caption: libensemble/libensemble/gen_funcs/sampling.py
.. tab-item:: Incrementing indexes or process counts
.. literalinclude:: ../../libensemble/alloc_funcs/fast_alloc.py
:linenos:
:start-at: for wid in support.avail_worker_ids(gen_workers=False):
:end-before: # Give gen work if possible
:caption: libensemble/alloc_funcs/fast_alloc.py
.. tab-item:: Tracking running generators
.. literalinclude:: ../../libensemble/alloc_funcs/start_only_persistent.py
:linenos:
:start-at: avail_workers = support.avail_worker_ids(persistent=False, zero_resource_workers=True, gen_workers=True)
:end-before: return Work, persis_info, 0
:emphasize-lines: 18
:caption: libensemble/alloc_funcs/start_only_persistent.py
.. tab-item:: Allocation function triggers shutdown
.. literalinclude:: ../../libensemble/alloc_funcs/start_only_persistent.py
:linenos:
:start-at: if gen_count < persis_info.get("num_gens_started", 0):
:end-before: # Give evaluated results back to a running persistent gen
:emphasize-lines: 1
:caption: libensemble/alloc_funcs/start_only_persistent.py
When there are repeated calls to libE() or ensemble.run(), users may
need to modify or reset the contents of persis_info in some cases.
.. seealso::
From: support.py_
.. literalinclude:: ../../libensemble/tests/regression_tests/support.py
:start-at: persis_info_1
:end-before: end_persis_info_rst_tag