Skip to content

Commit

Permalink
Fix README and sampler
Browse files Browse the repository at this point in the history
  • Loading branch information
nabenabe0928 committed Oct 22, 2024
1 parent 0c1ed85 commit 133ad55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package/samplers/auto_sampler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ These arguments follow the same convention as the other samplers, so please take
This sampler requires optional dependencies of Optuna.

```shell
$ pip install optunahub cmaes torch
$ pip install optunahub cmaes torch scipy
```

## Example
Expand Down
11 changes: 3 additions & 8 deletions package/samplers/auto_sampler/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def objective(trial):
.. note::
This sampler requires optional dependencies of Optuna.
You can install them with ``pip install "optuna[optional]"``.
You can install them with ``pip install optunahub scipy torch cmaes``.
Alternatively, you can install them with ``pip install -r https://hub.optuna.org/samplers/auto_sampler/requirements.txt``.
Args:
Expand All @@ -73,10 +73,6 @@ def objective(trial):
The ``constraints_func`` will be evaluated after each successful trial.
The function won't be called when trials fail or they are pruned, but this behavior is
subject to change in the future releases.
.. note::
If you enable this feature, Optuna's default sampler will be selected automatically.
"""

def __init__(
Expand Down Expand Up @@ -130,8 +126,7 @@ def _determine_multi_objective_sampler(
if len(study.directions) < THRESHOLD_OF_MANY_OBJECTIVES
else NSGAIIISampler
)
# Use ``NSGAIISampler`` if search space is numerical and
# len(complete_trials) <= _N_COMPLETE_TRIALS_FOR_NSGA.
# Use NSGA-II/III if len(complete_trials) <= _N_COMPLETE_TRIALS_FOR_NSGA.
self._sampler = nsga_sampler_cls(constraints_func=self._constraints_func, seed=seed)

def _determine_single_objective_sampler(
Expand Down Expand Up @@ -208,7 +203,7 @@ def sample_relative(
) -> dict[str, Any]:
n_objectives = len(study.directions)
if n_objectives > 1 and isinstance(self._sampler, TPESampler):
# NOTE(nabenabe): Set generation 0 so that NSGAIISampler can use the trial information
# NOTE(nabenabe): Set generation 0 so that NSGA-II/III can use the trial information
# obtained during the optimization using TPESampler.
# NOTE(nabenabe): Use NSGA-III for many objective problems.
_GENERATION_KEY = (
Expand Down

0 comments on commit 133ad55

Please sign in to comment.