physbo.search.discrete package¶
Submodules¶
Module contents¶
-
class
physbo.search.discrete.
Pareto
(num_objectives, dom_rule=None)[ソース]¶ ベースクラス:
object
-
class
physbo.search.discrete.
history
[ソース]¶ ベースクラス:
object
-
export_all_sequence_best_fx
()[ソース]¶ - Export all fx and actions at each sequence.
(The total number of data is total_num_research.)
- 戻り値
best_fx (numpy.ndarray)
best_actions (numpy.ndarray)
-
export_sequence_best_fx
()[ソース]¶ Export fx and actions at each sequence. (The total number of data is num_runs.)
- 戻り値
best_fx (numpy.ndarray)
best_actions (numpy.ndarray)
-
load
(filename)[ソース]¶ Load the information of the history.
- パラメータ
filename (str) -- The name of the file which stores the information of the history
-
save
(filename)[ソース]¶ Save the information of the history.
- パラメータ
filename (str) -- The name of the file which stores the information of the history
-
write
(t, action)[ソース]¶ Overwrite fx and chosen_actions by t and action.
- パラメータ
t (numpy.ndarray) -- N dimensional array. The negative energy of each search candidate (value of the objective function to be optimized).
action (numpy.ndarray) -- N dimensional array. The indexes of actions of each search candidate.
-
-
class
physbo.search.discrete.
policy
(test_X, config=None, initial_data=None, comm=None)[ソース]¶ ベースクラス:
object
-
bayes_search
(training=None, max_num_probes=None, num_search_each_probe=1, predictor=None, is_disp=True, simulator=None, score='TS', interval=0, num_rand_basis=0)[ソース]¶ Performing Bayesian optimization.
- パラメータ
training (physbo.variable) -- Training dataset.
max_num_probes (int) -- Maximum number of searching process by Bayesian optimization.
num_search_each_probe (int) -- Number of searching by Bayesian optimization at each process.
predictor (predictor object) -- Base class is defined in physbo.predictor. If None, blm_predictor is defined.
is_disp (bool) -- If true, process messages are outputted.
simulator (callable) -- Callable (function or object with
__call__
) Here, action is an integer which represents the index of the candidate.score (str) -- The type of aquision funciton. TS (Thompson Sampling), EI (Expected Improvement) and PI (Probability of Improvement) are available.
interval (int) -- The interval number of learning the hyper parameter. If you set the negative value to interval, the hyper parameter learning is not performed. If you set zero to interval, the hyper parameter learning is performed only at the first step.
num_rand_basis (int) -- The number of basis function. If you choose 0, ordinary Gaussian process run.
- 戻り値
history
- 戻り値の型
history object (physbo.search.discrete.results.history)
-
delete_actions
(index, actions=None)[ソース]¶ Deleteing actions
- パラメータ
index (int) -- Index of an action to be deleted.
actions (numpy.ndarray) -- Array of actions.
- 戻り値
actions -- Array of actions which does not include action specified by index.
- 戻り値の型
numpy.ndarray
-
get_actions
(mode, N, K, alpha)[ソース]¶ Getting actions
- パラメータ
mode (str) -- The type of aquision funciton. TS (Thompson Sampling), EI (Expected Improvement) and PI (Probability of Improvement) are available. These functions are defined in score.py.
N (int) -- The total number of actions to return.
K (int) -- The total number of samples to evaluate marginal score
alpha (float) -- Tuning parameter which is used if mode = TS. In TS, multi variation is tuned as np.random.multivariate_normal(mean, cov*alpha**2, size).
- 戻り値
chosen_actions -- An N-dimensional array of actions selected in each search process.
- 戻り値の型
numpy.ndarray
-
get_marginal_score
(mode, chosen_actions, K, alpha)[ソース]¶ Getting marginal scores.
- パラメータ
mode (str) -- The type of aquision funciton. TS (Thompson Sampling), EI (Expected Improvement) and PI (Probability of Improvement) are available. These functions are defined in score.py.
chosen_actions (numpy.ndarray) -- Array of selected actions.
K (int) -- The total number of search candidates.
alpha (float) -- not used.
- 戻り値
f -- N dimensional scores (score is defined in each mode)
- 戻り値の型
list
-
get_random_action
(N)[ソース]¶ Getting indexes of actions randomly.
- パラメータ
N (int) -- Total number of search candidates.
- 戻り値
action -- Indexes of actions selected randomly from search candidates.
- 戻り値の型
numpy.ndarray
-
get_score
(mode, predictor=None, training=None, alpha=1)[ソース]¶ Getting score.
- パラメータ
mode (str) -- The type of aquision funciton. TS, EI and PI are available. These functions are defined in score.py.
predictor (predictor object) -- Base class is defined in physbo.predictor.
training (physbo.variable) -- Training dataset.
alpha (float) -- Tuning parameter which is used if mode = TS. In TS, multi variation is tuned as np.random.multivariate_normal(mean, cov*alpha**2, size).
- 戻り値
f -- Score defined in each mode.
- 戻り値の型
float or list of float
-
load
(file_history, file_training=None, file_predictor=None)[ソース]¶ Loading files about history, training and predictor.
- パラメータ
file_history (str) -- The name of the file that stores the information of the history.
file_training (str) -- The name of the file that stores the training dataset.
file_predictor (str) -- The name of the file that stores the predictor dataset.
-
random_search
(max_num_probes, num_search_each_probe=1, simulator=None, is_disp=True)[ソース]¶ Performing random search.
- パラメータ
max_num_probes (int) -- Maximum number of random search process.
num_search_each_probe (int) -- Number of search at each random search process.
simulator (callable) -- Callable (function or object with
__call__
) from action to t Here, action is an integer which represents the index of the candidate.is_disp (bool) -- If true, process messages are outputted.
- 戻り値
history
- 戻り値の型
history object (physbo.search.discrete.results.history)
-
save
(file_history, file_training=None, file_predictor=None)[ソース]¶ Saving history, training and predictor into the corresponding files.
- パラメータ
file_history (str) -- The name of the file that stores the information of the history.
file_training (str) -- The name of the file that stores the training dataset.
file_predictor (str) -- The name of the file that stores the predictor dataset.
-
set_seed
(seed)[ソース]¶ Setting a seed parameter for np.random.
- パラメータ
seed (int) -- seed number
------- --
-
write
(action, t, X=None)[ソース]¶ Writing history (update history, not output to a file).
- パラメータ
action (numpy.ndarray) -- Indexes of actions.
t (numpy.ndarray) -- N dimensional array. The negative energy of each search candidate (value of the objective function to be optimized).
X (numpy.ndarray) -- N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of each search candidate.
-
-
class
physbo.search.discrete.
policy_mo
(test_X, num_objectives, comm=None, config=None, initial_actions=None)[ソース]¶ ベースクラス:
physbo.search.discrete.policy.policy
-
bayes_search
(training_list=None, max_num_probes=None, num_search_each_probe=1, predictor_list=None, is_disp=True, disp_pareto_set=False, simulator=None, score='HVPI', interval=0, num_rand_basis=0)[ソース]¶ Performing Bayesian optimization.
- パラメータ
training (physbo.variable) -- Training dataset.
max_num_probes (int) -- Maximum number of searching process by Bayesian optimization.
num_search_each_probe (int) -- Number of searching by Bayesian optimization at each process.
predictor (predictor object) -- Base class is defined in physbo.predictor. If None, blm_predictor is defined.
is_disp (bool) -- If true, process messages are outputted.
simulator (callable) -- Callable (function or object with
__call__
) Here, action is an integer which represents the index of the candidate.score (str) -- The type of aquision funciton. TS (Thompson Sampling), EI (Expected Improvement) and PI (Probability of Improvement) are available.
interval (int) -- The interval number of learning the hyper parameter. If you set the negative value to interval, the hyper parameter learning is not performed. If you set zero to interval, the hyper parameter learning is performed only at the first step.
num_rand_basis (int) -- The number of basis function. If you choose 0, ordinary Gaussian process run.
- 戻り値
history
- 戻り値の型
history object (physbo.search.discrete.results.history)
-
get_actions
(mode, N, K, alpha)[ソース]¶ Getting actions
- パラメータ
mode (str) -- The type of aquision funciton. TS (Thompson Sampling), EI (Expected Improvement) and PI (Probability of Improvement) are available. These functions are defined in score.py.
N (int) -- The total number of actions to return.
K (int) -- The total number of samples to evaluate marginal score
alpha (float) -- Tuning parameter which is used if mode = TS. In TS, multi variation is tuned as np.random.multivariate_normal(mean, cov*alpha**2, size).
- 戻り値
chosen_actions -- An N-dimensional array of actions selected in each search process.
- 戻り値の型
numpy.ndarray
-
get_score
(mode, predictor_list, training_list, pareto, alpha=1)[ソース]¶ Getting score.
- パラメータ
mode (str) -- The type of aquision funciton. TS, EI and PI are available. These functions are defined in score.py.
predictor (predictor object) -- Base class is defined in physbo.predictor.
training (physbo.variable) -- Training dataset.
alpha (float) -- Tuning parameter which is used if mode = TS. In TS, multi variation is tuned as np.random.multivariate_normal(mean, cov*alpha**2, size).
- 戻り値
f -- Score defined in each mode.
- 戻り値の型
float or list of float
-
load
(file_history, file_training_list=None, file_predictor_list=None)[ソース]¶ Loading files about history, training and predictor.
- パラメータ
file_history (str) -- The name of the file that stores the information of the history.
file_training (str) -- The name of the file that stores the training dataset.
file_predictor (str) -- The name of the file that stores the predictor dataset.
-
random_search
(max_num_probes, num_search_each_probe=1, simulator=None, is_disp=True, disp_pareto_set=False)[ソース]¶ Performing random search.
- パラメータ
max_num_probes (int) -- Maximum number of random search process.
num_search_each_probe (int) -- Number of search at each random search process.
simulator (callable) -- Callable (function or object with
__call__
) from action to t Here, action is an integer which represents the index of the candidate.is_disp (bool) -- If true, process messages are outputted.
- 戻り値
history
- 戻り値の型
history object (physbo.search.discrete.results.history)
-
write
(action, t, X=None)[ソース]¶ Writing history (update history, not output to a file).
- パラメータ
action (numpy.ndarray) -- Indexes of actions.
t (numpy.ndarray) -- N dimensional array. The negative energy of each search candidate (value of the objective function to be optimized).
X (numpy.ndarray) -- N x d dimensional matrix. Each row of X denotes the d-dimensional feature vector of each search candidate.
-