saealib.JoblibEvaluator#

class saealib.JoblibEvaluator(n_jobs=-1, backend='loky', **joblib_kwargs)[source]#

Bases: Evaluator

Parallel evaluator backed by joblib.

Candidates in each batch are evaluated in parallel using joblib’s Parallel / delayed interface. The default backend "loky" uses cloudpickle, so problem functions defined as lambdas or closures are handled without extra serialisation work.

Switching to Dask or Ray is a single-parameter change:

JoblibEvaluator(n_jobs=-1, backend="dask")   # Dask cluster
JoblibEvaluator(n_jobs=-1, backend="ray")    # Ray cluster
Parameters:
  • n_jobs (int) – Number of parallel workers. -1 uses all available CPU cores (joblib convention). 1 disables parallelism (equivalent to SerialEvaluator but with joblib overhead).

  • backend (str) – joblib backend name. "loky" (default) launches fresh worker processes with cloudpickle serialisation. Other built-in options: "threading", "multiprocessing". Third-party backends "dask" and "ray" require the corresponding packages and a running cluster.

  • **joblib_kwargs – Additional keyword arguments forwarded verbatim to joblib.Parallel. Useful for verbose, prefer, require, timeout, etc.

Raises:

ImportError – If joblib is not installed.

Notes

Island-model nested parallelism: when multiple islands each own a JoblibEvaluator, CPU cores may be over-subscribed. Set n_jobs=1 per island evaluator and let the island-level parallelism control concurrency, or use joblib.parallel_backend as a context manager to limit inner workers.

Async evaluation is out of scope for this class. Asynchronous candidate dispatch would require changes to the Algorithm.ask / Algorithm.tell interface and is tracked separately.

This evaluator does not use Problem.evaluate_batch even when a Problem overrides it; combining per-row parallel dispatch (this class) with a single vectorized batch call is tracked separately.

Methods

__init__

acknowledge

Acknowledge one contiguous update sequence.

can_reattach

Return whether pending work can be restored after checkpoint load.

cancel

Cancel submitted work when the backend supports cancellation.

collect

Return unacknowledged updates for a handle.

contract

Return the evaluator family contract.

detach

Detach work whose result must no longer be delivered.

evaluate_batch

Evaluate candidates in parallel using joblib.

evaluate_request

Evaluate a request, including its public metadata boundary.

has_partial_lifecycle_override

Return whether lifecycle adapter methods are only partly overridden.

reattach

Restore a pending request or raise when unsupported.

submit

Submit a request through the synchronous adapter.

supports_batch_rollback

Return whether failed batch submission can be rolled back.

Method Details

JoblibEvaluator.__init__(n_jobs=-1, backend='loky', **joblib_kwargs)[source]#
Parameters:
  • n_jobs (int)

  • backend (str)

  • joblib_kwargs (object)

Return type:

None

JoblibEvaluator.acknowledge(handle, sequence)#

Acknowledge one contiguous update sequence.

Parameters:
Return type:

None

JoblibEvaluator.can_reattach(pending)#

Return whether pending work can be restored after checkpoint load.

Parameters:

pending (PendingEvaluation)

Return type:

bool

JoblibEvaluator.cancel(handle)#

Cancel submitted work when the backend supports cancellation.

Parameters:

handle (EvaluationHandle)

Return type:

bool

JoblibEvaluator.collect(handle, *, wait=True)#

Return unacknowledged updates for a handle.

Parameters:
Return type:

list[EvaluationUpdate]

JoblibEvaluator.contract()#

Return the evaluator family contract.

Return type:

ComponentContract

JoblibEvaluator.detach(handle)#

Detach work whose result must no longer be delivered.

Parameters:

handle (EvaluationHandle)

Return type:

bool

JoblibEvaluator.evaluate_batch(x, problem)[source]#

Evaluate candidates in parallel using joblib.

Parameters:
  • x (np.ndarray) – Design vectors to evaluate. shape = (n, dim)

  • problem (Problem) – The optimization problem providing the objective and constraints.

Returns:

Batched objective values, raw constraint values, and violations.

Return type:

EvaluationResult

JoblibEvaluator.evaluate_request(request, problem)#

Evaluate a request, including its public metadata boundary.

Parameters:
Return type:

EvaluationResult

classmethod JoblibEvaluator.has_partial_lifecycle_override()#

Return whether lifecycle adapter methods are only partly overridden.

Return type:

bool

JoblibEvaluator.reattach(pending, problem)#

Restore a pending request or raise when unsupported.

Parameters:
Return type:

EvaluationHandle

JoblibEvaluator.submit(request, problem)#

Submit a request through the synchronous adapter.

Parameters:
Return type:

EvaluationHandle

JoblibEvaluator.supports_batch_rollback()#

Return whether failed batch submission can be rolled back.

Return type:

bool