physbo.search.discrete.policy module

class physbo.search.discrete.policy.policy(test_X, config=None, initial_data=None, comm=None)[ソース]

ベースクラス: object

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

export_history()[ソース]

Returning the information of the history.

export_predictor()[ソース]

Returning the predictor dataset

export_training()[ソース]

Returning the training dataset

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.

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.policy_mo(test_X, num_objectives, comm=None, config=None, initial_actions=None)[ソース]

ベースクラス: physbo.search.discrete.policy.policy

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_fmean_fstd(predictor_list, training_list, test)[ソース]
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.

load_predictor_list(file_name)[ソース]
load_training_list(file_name)[ソース]

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_predictor_list(file_name)[ソース]
save_training_list(file_name)[ソース]
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.

physbo.search.discrete.policy.run_simulator(simulator, action, comm=None)[ソース]