File: optuna_sampler.py

package info (click to toggle)
python-cmaes 0.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 544 kB
  • sloc: python: 5,136; sh: 88; makefile: 4
file content (17 lines) | stat: -rw-r--r-- 430 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import optuna


def objective(trial: optuna.Trial):
    x1 = trial.suggest_float("x1", -4, 4)
    x2 = trial.suggest_float("x2", -4, 4)
    return (x1 - 3) ** 2 + (10 * (x2 + 2)) ** 2


def main():
    optuna.logging.set_verbosity(optuna.logging.INFO)
    study = optuna.create_study(sampler=optuna.samplers.CmaEsSampler())
    study.optimize(objective, n_trials=250, gc_after_trial=False)


if __name__ == "__main__":
    main()