OptunaのBoTorchSamplerのためのcandidates_funcを実装
optuna.integration.BoTorchSampler
class optuna.integration.BoTorchSampler(*, candidates_func=None, constraints_func=None, n_startup_trials=10, independent_sampler=None, seed=None)
- candidates_func (Optional[Callable[[torch.Tensor, torch.Tensor, Optional[torch.Tensor], torch.Tensor], torch.Tensor]]) –
An optional function that suggests the next candidates. It must take the training data, the objectives, the constraints, the search space bounds and return the next candidates. The arguments are of type torch.Tensor. The return value must be a torch.Tensor. However, if constraints_func is omitted, constraints will be None. For any constraints that failed to compute, the tensor will contain NaN.
If omitted, it is determined automatically based on the number of objectives. If the number of objectives is one, Quasi MC-based batch Expected Improvement (qEI) is used. If the number of objectives is either two or three, Quasi MC-based batch Expected Hypervolume Improvement (qEHVI) is used. Otherwise, for larger number of objectives, the faster Quasi MC-based extended ParEGO (qParEGO) is used.
以下のcandidates_func
を実装
- Single Objective
- qEI (Gamma Prior)
- qEI (Dim-scale lognormal Prior)
- qEI (SAAS)
- qLogEI (Gamma Prior)
- qLogEI (Dim-scale lognormal Prior)
- LCB
- Thompson Sampling
- Multi Objective
- qEHVI
- qLogEHVI
- Use BoTorch==0.12.0
- 高次元BOの手法として,Dim-scale lognormal Prior[Carl Hvarfner, et al., 2024]が提案されているが,BoTorchではv0.12.0からデフォルトになっている.(release v0.12.0)
candidates_func
を指定しない場合はqEIもしくはqEHVIが利用されると記載されているが,実際にはqLogEI, qLogEHVIが利用されている模様.
Build image
$ docker compose up --build
Run experiment
$ python main.py
Run experiment: StyblinskiTang40
Start trial:1
Start optimization using TPE
100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:06<00:00, 14.98it/s]