Engines

The execution of the multistarts can be parallelized in different ways, e.g. multi-threaded or cluster-based. Note that it is not checked whether a single task itself is internally parallelized.

class pypesto.engine.Engine

Bases: abc.ABC

Abstract engine base class.

__init__()

Initialize self. See help(type(self)) for accurate signature.

abstract execute(tasks: List[pypesto.engine.task.Task])

Execute tasks.

Parameters

tasks – List of tasks to execute.

class pypesto.engine.MultiProcessEngine(n_procs: int = None)

Bases: pypesto.engine.base.Engine

Parallelize the task execution using multiprocessing.

Parameters

n_procs – The maximum number of processes to use in parallel. Defaults to the number of CPUs available on the system according to os.cpu_count(). The effectively used number of processes will be the minimum of n_procs and the number of tasks submitted.

__init__(n_procs: int = None)

Initialize self. See help(type(self)) for accurate signature.

execute(tasks: List[pypesto.engine.task.Task])

Pickle tasks and distribute work over parallel processes.

class pypesto.engine.MultiThreadEngine(n_threads: int = None)

Bases: pypesto.engine.base.Engine

Parallelize the task execution using multithreading.

Parameters

n_threads – The maximum number of threads to use in parallel. Defaults to the number of CPUs available on the system according to os.cpu_count(). The effectively used number of threads will be the minimum of n_threads and the number of tasks submitted.

__init__(n_threads: int = None)

Initialize self. See help(type(self)) for accurate signature.

execute(tasks: List[pypesto.engine.task.Task])

Deepcopy tasks and distribute work over parallel threads.

class pypesto.engine.OptimizerTask(optimizer: pypesto.optimize.optimizer.Optimizer, problem: pypesto.problem.Problem, x0: numpy.ndarray, id: str, options: pypesto.optimize.options.OptimizeOptions, history_options: pypesto.objective.history.HistoryOptions)

Bases: pypesto.engine.task.Task

A multistart optimization task, performed in pypesto.minimize.

__init__(optimizer: pypesto.optimize.optimizer.Optimizer, problem: pypesto.problem.Problem, x0: numpy.ndarray, id: str, options: pypesto.optimize.options.OptimizeOptions, history_options: pypesto.objective.history.HistoryOptions)

Create the task object.

Parameters
  • optimizer – The optimizer to use.

  • problem – The problem to solve.

  • x0 – The point from which to start.

  • id – The multistart id.

  • options – Options object applying to optimization.

  • history_options – Optimizer history options.

execute() → pypesto.optimize.result.OptimizerResult

Execute the task and return its results.

class pypesto.engine.SingleCoreEngine

Bases: pypesto.engine.base.Engine

Dummy engine for sequential execution on one core. Note that the objective itself may be multithreaded.

__init__()

Initialize self. See help(type(self)) for accurate signature.

execute(tasks: List[pypesto.engine.task.Task])

Execute all tasks in a simple for loop sequentially.