physbo.search.score_multi module
- physbo.search.score_multi.EHVI(fmean, fstd, pareto)[source]
Calculate Expected Hyper-Volume Improvement (EHVI).
Reference: (Couckuyt et al., 2014) Fast calculation of multiobjective probability of improvement and expected improvement criteria for Pareto optimization
- Parameters:
fmean (numpy.ndarray) – mean of the predictive distribution, shape (N, n_obj); the first axis must be the N candidates, the rest is reshaped to (N, n_obj)
fstd (numpy.ndarray) – standard deviation of the predictive distribution, any shape with N * n_obj elements (reshaped to (N, n_obj))
pareto (Pareto object) – Pareto object. The non-dominated region is divided into cells and the reference points are set by default if not done yet.
objectives (The result is the expected hypervolume improvement when the)
deviation (are independent normal variables with mean fmean and standard)
fstd
contribute (where predictions beyond reference_max in any objective)
between (zero (they are not clipped). It holds only while the front lies)
reference_max. (reference_min and)
- Returns:
score – score of the candidates, shape (N,)
- Return type:
numpy.ndarray
- class physbo.search.score_multi.ExpectedHypervolumeImprovement[source]
Bases:
objectCallable hypervolume acquisition function wrapping
EHVI().Notes
Called with predictor_list, training, test and pareto as positional arguments. Returns scores of shape
(test.X.shape[0],).See also
EHVIAcquisition function using posterior means and standard deviations.
- name = 'EHVI'
- physbo.search.score_multi.HVPI(fmean, fstd, pareto)[source]
Calculate Hypervolume-based Probability of Improvement (HVPI).
Reference: (Couckuyt et al., 2014) Fast calculation of multiobjective probability of improvement and expected improvement criteria for Pareto optimization
- Parameters:
fmean (numpy.ndarray) – mean of the predictive distribution, shape (N, n_obj); the first axis must be the N candidates, the rest is reshaped to (N, n_obj)
fstd (numpy.ndarray) – standard deviation of the predictive distribution, any shape with N * n_obj elements (reshaped to (N, n_obj))
pareto (Pareto object) – Pareto object. The non-dominated region is divided into cells and reference_min is set by default if not done yet.
reference_min. (The result holds only while the front lies above)
- Returns:
score – score of the candidates, shape (N,)
- Return type:
numpy.ndarray
- class physbo.search.score_multi.HypervolumeProbabilityOfImprovement[source]
Bases:
objectCallable hypervolume acquisition function wrapping
HVPI().Notes
Called with predictor_list, training, test and pareto as positional arguments. Returns scores of shape
(test.X.shape[0],).See also
HVPIAcquisition function using posterior means and standard deviations.
- name = 'HVPI'
- physbo.search.score_multi.TS(predictor_list, training, test, alpha=1, reduced_candidate_num=None, rng=None)[source]
Thompson Sampling for multi-objective optimization.
- Parameters:
predictor_list (list of Predictor) – List of predictors for each objective.
training (Variable) – Training data containing all objectives.
test (Variable) – Test points.
alpha (float, optional) – Scaling parameter for sampling from posterior distribution. Default is 1.
reduced_candidate_num (int, optional) – Number of candidates to randomly select for Pareto front calculation. If None or less than number of test points, all points are used. Default is None.
- Returns:
score_res – Score array with 1 at the chosen index and 0 elsewhere.
- Return type:
numpy.ndarray
- class physbo.search.score_multi.ThompsonSampling(alpha=1.0, reduced_candidate_num=None, rng=None)[source]
Bases:
objectCallable multi-objective Thompson sampling wrapping
TS().- Parameters:
alpha (float, optional) – Posterior sampling scale. Default is 1.0.
reduced_candidate_num (int, optional) – Maximum number of candidates used for Pareto front calculation. Default is None, which uses all candidates.
rng (rng object, optional) – Random number generator for the posterior samples and the choice among the Pareto front; None (default) draws from the global
numpy.randomstate. An instance given to a policy without a generator of its own borrows the policy’s (seephysbo._rng.attach_rng()).
See also
TSMulti-objective Thompson sampling acquisition function.
- name = 'TS'
- physbo.search.score_multi.resolve(score, *, alpha=1.0, reduced_candidate_num=None, rng=None)[source]
Resolve a multi-objective score name or return a callable unchanged.
- Parameters:
score (str or callable) – “EHVI”, “HVPI”, “TS”, or a callable accepting predictor_list, training, test and pareto as positional arguments.
alpha (float, optional) – Posterior sampling scale for “TS”. Default is 1.0.
reduced_candidate_num (int, optional) – Candidate limit for “TS”. Default is None, using all candidates.
rng (rng object, optional) – Random number generator for “TS”. A callable that holds a generator in an
rngattribute and was not given one of its own (the built-inThompsonSampling) is attached to it (seephysbo._rng.attach_rng()). Default is None, the globalnumpy.randomstate.
- Returns:
Acquisition function. Existing callables are returned unchanged.
- Return type:
callable
- Raises:
NotImplementedError – If the score name is unknown.
TypeError – If score is a class rather than an instance, or is neither a string nor a callable.
- physbo.search.score_multi.score(mode, predictor_list, test, training, **kwargs)[source]
Calculate multi-objective acquisition scores for test data.
- Parameters:
mode (str or callable) – “EHVI”, “HVPI”, “TS”, or a callable called as
mode(predictor_list, training, test, pareto).predictor_list (list of predictor objects) – Predictor for each objective.
test (physbo.Variable) – Test inputs.
training (physbo.Variable) – Training dataset containing all objectives.
pareto (Pareto) – Required for EHVI and HVPI. Passed to callable modes, as None when omitted.
alpha (float) – Posterior sampling scale for string “TS”. Default is 1.0.
reduced_candidate_num (int or None) – Required candidate limit for string “TS”; None uses all candidates. Callable modes ignore this parameter and alpha.
rng (rng object) – Random number generator for string “TS” (default: the global
numpy.randomstate); a callable mode draws from its own.
- Returns:
Acquisition scores of shape
(test.X.shape[0],).- Return type:
numpy.ndarray