Exploration#
- class optimas.explorations.Exploration(generator, evaluator, max_evals=inf, sim_workers=1, run_async=False, history=None, history_save_period=None, exploration_dir_path='./exploration', resume=False, libe_comms='local')#
Class for launching an exploration.
Depending on the generator, the exploration can be an optimization, a parameter scan, etc.
- Parameters:
- generatorGenerator
The generator used to suggest new Trials.
- evaluatorEvaluator
The evaluator that will execute the Trials.
- max_evalsint, optional
Maximum number of trials that will be evaluated in the exploration. If not given, the exploration can run indefinitely.
- sim_workersint, optional
Number of parallel workers performing simulations. By default, 1.
- run_asyncbool, optional
Whether the evaluations should be performed asynchronously (i.e., without waiting for all workers to finish before staring a new evaluation). This is useful when the completion time of the evaluations is not uniform. By default, False.
- historystr, optional
Path to a history file of a past exploration from which to restart the new one. By default, None.
- history_save_periodint, optional
Periodicity, in number of evaluated Trials, with which to save the history file to disk. By default equals to
sim_workers.- exploration_dir_pathstr, optional.
Path to the exploration directory. By default,
'./exploration'.- resumebool, optional
Whether the exploration should resume from a previous run in the same exploration_dir_path. If True, the exploration will continue from the last evaluation of the previous run until the total number of evaluations (including those of the previous run) reaches max_evals. There is no need to provide the history path (it will be ignored). If False (default value), the exploration will raise an error if the exploration_dir_path already exists.
- libe_comms{‘local’, ‘threads’, ‘mpi’}, optional.
The communication mode for libEnseble. Determines whether to use Python
multiprocessing(local),threading(threads) or MPI for the communication between the manager and workers. The'threads'mode is only recommended when running in a Jupyter notebook if the default ‘local’ mode has issues (this can happen especially on Windows and Mac, which use multiprocessingspawn).'threads'only supportsFunctionEvaluator``s. If running in ``'mpi'mode, the Optimas script should be launched withmpirunor equivalent, for example,mpirun -np N python myscript.py. This will launch one manager andN-1simulation workers. In this case, thesim_workersparameter is ignored. By default,'local'mode is used.
Methods
attach_evaluations(evaluation_data[, ...])Attach evaluations from external source.
attach_trials(trial_data[, ...])Attach trials for future evaluation.
evaluate_trials(trial_data[, ...])Attach and evaluate trials.
mark_evaluation_as_failed(trial_index)Mark an already evaluated trial as failed.
run([n_evals])Run the exploration.
Attributes
Get the exploration history.
Get whether the current process is the manager.