Produce and register samples to try
Suggest new parameter sets which optimize the objective.
from orion.core.io.database import DuplicateKeyError
log = logging.getLogger(__name__)
"""Produce suggested sets of problem's parameter space to try out.
It uses an `Experiment`s `BaseAlgorithm` object to observe trial results
and suggest new trials of the parameter `Space` to be evaluated. The producer
is the bridge between the storage and the algorithm.
def __init__(self, experiment):
"""Initialize a producer.
:param experiment: Manager of this experiment, provides convenient
interface for interacting with the database.
log.debug("Creating Producer object.")
self.experiment = experiment
[docs] def observe(self, trial):
"""Observe a trial to update algorithm's status"""
# algorithm = self.experiment.algorithms
# if True:
with self.experiment.acquire_algorithm_lock() as algorithm:
[docs] def produce(self, pool_size, timeout=60, retry_interval=1):
"""Create and register new trials."""
log.debug("### Algorithm attempts suggesting %s new trials.", pool_size)
n_suggested_trials = 0
) as algorithm:
new_trials = algorithm.suggest(pool_size)
if not new_trials and not algorithm.is_done:
"Algo does not have more trials to sample."
"Waiting for current trials to finish"
for new_trial in new_trials:
n_suggested_trials += 1
log.debug("Algo suggested duplicate trial %s", new_trial)