saealib.JoblibEvaluator#
- class saealib.JoblibEvaluator(n_jobs=-1, backend='loky', **joblib_kwargs)[ソース]#
ベースクラス:
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
- パラメータ:
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.
- 例外:
ImportError -- If joblib is not installed.
メモ
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)[ソース]#
- パラメータ:
n_jobs (int)
backend (str)
joblib_kwargs (object)
- 戻り値の型:
None
- JoblibEvaluator.acknowledge(handle, sequence)#
Acknowledge one contiguous update sequence.
- パラメータ:
handle (EvaluationHandle)
sequence (int)
- 戻り値の型:
None
- JoblibEvaluator.can_reattach(pending)#
Return whether pending work can be restored after checkpoint load.
- パラメータ:
pending (PendingEvaluation)
- 戻り値の型:
bool
- JoblibEvaluator.cancel(handle)#
Cancel submitted work when the backend supports cancellation.
- パラメータ:
handle (EvaluationHandle)
- 戻り値の型:
bool
- JoblibEvaluator.collect(handle, *, wait=True)#
Return unacknowledged updates for a handle.
- パラメータ:
handle (EvaluationHandle)
wait (bool)
- 戻り値の型:
list[EvaluationUpdate]
- JoblibEvaluator.contract()#
Return the evaluator family contract.
- 戻り値の型:
- JoblibEvaluator.detach(handle)#
Detach work whose result must no longer be delivered.
- パラメータ:
handle (EvaluationHandle)
- 戻り値の型:
bool
- JoblibEvaluator.evaluate_batch(x, problem)[ソース]#
Evaluate candidates in parallel using joblib.
- パラメータ:
x (np.ndarray) -- Design vectors to evaluate. shape = (n, dim)
problem (Problem) -- The optimization problem providing the objective and constraints.
- 戻り値:
Batched objective values, raw constraint values, and violations.
- 戻り値の型:
- JoblibEvaluator.evaluate_request(request, problem)#
Evaluate a request, including its public metadata boundary.
- パラメータ:
request (EvaluationRequest)
problem (Problem)
- 戻り値の型:
- classmethod JoblibEvaluator.has_partial_lifecycle_override()#
Return whether lifecycle adapter methods are only partly overridden.
- 戻り値の型:
bool
- JoblibEvaluator.reattach(pending, problem)#
Restore a pending request or raise when unsupported.
- パラメータ:
pending (PendingEvaluation)
problem (Problem)
- 戻り値の型:
- JoblibEvaluator.submit(request, problem)#
Submit a request through the synchronous adapter.
- パラメータ:
request (EvaluationRequest)
problem (Problem)
- 戻り値の型:
- JoblibEvaluator.supports_batch_rollback()#
Return whether failed batch submission can be rolled back.
- 戻り値の型:
bool