saealib.JoblibEvaluator#
- class saealib.JoblibEvaluator(n_jobs=-1, backend='loky', **joblib_kwargs)[source]#
Bases:
EvaluatorParallel evaluator backed by joblib.
Candidates in each batch are evaluated in parallel using joblib’s
Parallel/delayedinterface. 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.
-1uses all available CPU cores (joblib convention).1disables parallelism (equivalent toSerialEvaluatorbut 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 forverbose,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. Setn_jobs=1per island evaluator and let the island-level parallelism control concurrency, or usejoblib.parallel_backendas 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.tellinterface and is tracked separately.This evaluator does not use
Problem.evaluate_batcheven when aProblemoverrides it; combining per-row parallel dispatch (this class) with a single vectorized batch call is tracked separately.
Methods
Acknowledge one contiguous update sequence. |
|
Return whether pending work can be restored after checkpoint load. |
|
Cancel submitted work when the backend supports cancellation. |
|
Return unacknowledged updates for a handle. |
|
Return the evaluator family contract. |
|
Detach work whose result must no longer be delivered. |
|
Evaluate candidates in parallel using joblib. |
|
Evaluate a request, including its public metadata boundary. |
|
Return whether lifecycle adapter methods are only partly overridden. |
|
Restore a pending request or raise when unsupported. |
|
Submit a request through the synchronous adapter. |
|
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:
handle (EvaluationHandle)
sequence (int)
- 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:
handle (EvaluationHandle)
wait (bool)
- Return type:
list[EvaluationUpdate]
- JoblibEvaluator.contract()#
Return the evaluator family contract.
- Return type:
- 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:
- JoblibEvaluator.evaluate_request(request, problem)#
Evaluate a request, including its public metadata boundary.
- Parameters:
request (EvaluationRequest)
problem (Problem)
- Return type:
- 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:
pending (PendingEvaluation)
problem (Problem)
- Return type:
- JoblibEvaluator.submit(request, problem)#
Submit a request through the synchronous adapter.
- Parameters:
request (EvaluationRequest)
problem (Problem)
- Return type:
- JoblibEvaluator.supports_batch_rollback()#
Return whether failed batch submission can be rolled back.
- Return type:
bool