Note
Go to the end to download the full example code.
How to Implement Your Sampler with OptunaHub
OptunaHub is an Optuna package registry, which is a platform to share algorithms developed by contributors. This recipe shows how to implement your own algorithm with OptunaHub.
Here, we show how to implement your own sampler, i.e., optimizaiton algorithm. If you want to implement algorithms other than a sampler, please refer to the other recipes.
Usually, Optuna provides BaseSampler
class to implement your own sampler.
However, it is a bit complicated to implement a sampler from scratch.
Instead, in OptunaHub, you can use optunahub.samplers.SimpleBaseSampler class, which is a sampler template that can be easily extended.
You need to install optuna
to implement your own sampler, and optunahub
to use the template SimpleBaseSampler
.
$ pip install optuna optunahub
First of all, import optuna
, optunahub
, and other required modules.
from __future__ import annotations
from typing import Any
import numpy as np
import optuna
import optunahub
Next, define your own sampler class by inheriting SimpleBaseSampler
class.
In this example, we implement a sampler that returns a random value.
class MySampler(optunahub.samplers.SimpleBaseSampler):
# By default, search space will be estimated automatically like Optuna's built-in samplers.
# You can fix the search spacd by `search_space` argument of `SimpleSampler` class.
def __init__(
self, search_space: dict[str, optuna.distributions.BaseDistribution] | None = None
) -> None:
super().__init__(search_space)
self._rng = np.random.RandomState()
# You need to implement sample_relative method.
# This method returns a dictionary of hyperparameters.
# The keys of the dictionary are the names of the hyperparameters, which must be the same as the keys of the search_space argument.
# The values of the dictionary are the values of the hyperparameters.
# In this example, sample_relative method returns a dictionary of randomly sampled hyperparameters.
def sample_relative(
self,
study: optuna.study.Study,
trial: optuna.trial.FrozenTrial,
search_space: dict[str, optuna.distributions.BaseDistribution],
) -> dict[str, Any]:
# search_space argument must be identical to search_space argument input to __init__ method.
# This method is automatically invoked by Optuna and SimpleBaseSampler.
# If search space is empty, all parameter values are sampled randomly by SimpleBaseSampler.
if search_space == {}:
return {}
params = {} # type: dict[str, Any]
for n, d in search_space.items():
if isinstance(d, optuna.distributions.FloatDistribution):
params[n] = self._rng.uniform(d.low, d.high)
elif isinstance(d, optuna.distributions.IntDistribution):
params[n] = self._rng.randint(d.low, d.high)
elif isinstance(d, optuna.distributions.CategoricalDistribution):
params[n] = d.choices[self._rng.randint(len(d.choices))]
else:
raise NotImplementedError
return params
Here, as an example, the objective function is defined as follows.
def objective(trial: optuna.trial.Trial) -> float:
x = trial.suggest_float("x", -10, 10)
y = trial.suggest_int("y", -10, 10)
z = trial.suggest_categorical("z", ["a", "b", "c"])
return x**2 + y**2 + {"a": -10, "b": 0, "c": 10}[z] ** 2
This sampler can be used in the same way as other Optuna samplers.
In the following example, we create a study and optimize it using MySampler
class.
sampler = MySampler()
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=100)
[I 2025-03-05 07:55:49,935] A new study created in memory with name: no-name-aeb86575-1b63-481b-966c-d12cdd15d404
[I 2025-03-05 07:55:49,936] Trial 0 finished with value: 115.49769998773064 and parameters: {'x': 2.549058647369778, 'y': 3, 'z': 'c'}. Best is trial 0 with value: 115.49769998773064.
[I 2025-03-05 07:55:49,937] Trial 1 finished with value: 137.5843504768781 and parameters: {'x': -5.795200641641158, 'y': 2, 'z': 'a'}. Best is trial 0 with value: 115.49769998773064.
[I 2025-03-05 07:55:49,937] Trial 2 finished with value: 214.64667673141906 and parameters: {'x': -9.468192896821392, 'y': 5, 'z': 'c'}. Best is trial 0 with value: 115.49769998773064.
[I 2025-03-05 07:55:49,938] Trial 3 finished with value: 109.00144069116288 and parameters: {'x': 0.037956437700106704, 'y': 3, 'z': 'a'}. Best is trial 3 with value: 109.00144069116288.
[I 2025-03-05 07:55:49,938] Trial 4 finished with value: 276.4315592359595 and parameters: {'x': -8.742514468730349, 'y': -10, 'z': 'a'}. Best is trial 3 with value: 109.00144069116288.
[I 2025-03-05 07:55:49,939] Trial 5 finished with value: 120.97912282447817 and parameters: {'x': -4.580297241935087, 'y': -10, 'z': 'b'}. Best is trial 3 with value: 109.00144069116288.
[I 2025-03-05 07:55:49,939] Trial 6 finished with value: 113.86151493305653 and parameters: {'x': 3.5862954330418066, 'y': 1, 'z': 'a'}. Best is trial 3 with value: 109.00144069116288.
[I 2025-03-05 07:55:49,940] Trial 7 finished with value: 135.45758912402215 and parameters: {'x': 9.298257316509485, 'y': -7, 'z': 'b'}. Best is trial 3 with value: 109.00144069116288.
[I 2025-03-05 07:55:49,940] Trial 8 finished with value: 126.0168694235047 and parameters: {'x': -1.008399436485714, 'y': -5, 'z': 'c'}. Best is trial 3 with value: 109.00144069116288.
[I 2025-03-05 07:55:49,940] Trial 9 finished with value: 260.94185867945976 and parameters: {'x': -8.941021120624857, 'y': -9, 'z': 'a'}. Best is trial 3 with value: 109.00144069116288.
[I 2025-03-05 07:55:49,941] Trial 10 finished with value: 81.82512078711315 and parameters: {'x': -4.221980671096583, 'y': 8, 'z': 'b'}. Best is trial 10 with value: 81.82512078711315.
[I 2025-03-05 07:55:49,941] Trial 11 finished with value: 135.33170620117573 and parameters: {'x': 3.214297155083166, 'y': -5, 'z': 'c'}. Best is trial 10 with value: 81.82512078711315.
[I 2025-03-05 07:55:49,942] Trial 12 finished with value: 125.92306908617321 and parameters: {'x': -0.9607648443678674, 'y': -5, 'z': 'c'}. Best is trial 10 with value: 81.82512078711315.
[I 2025-03-05 07:55:49,942] Trial 13 finished with value: 66.22134299056584 and parameters: {'x': 7.888050645791129, 'y': 2, 'z': 'b'}. Best is trial 13 with value: 66.22134299056584.
[I 2025-03-05 07:55:49,942] Trial 14 finished with value: 84.73013149601636 and parameters: {'x': 5.97746865286773, 'y': 7, 'z': 'b'}. Best is trial 13 with value: 66.22134299056584.
[I 2025-03-05 07:55:49,943] Trial 15 finished with value: 115.89296050009179 and parameters: {'x': 2.6254448194718893, 'y': 3, 'z': 'a'}. Best is trial 13 with value: 66.22134299056584.
[I 2025-03-05 07:55:49,943] Trial 16 finished with value: 242.291050361016 and parameters: {'x': 9.658729231167836, 'y': -7, 'z': 'c'}. Best is trial 13 with value: 66.22134299056584.
[I 2025-03-05 07:55:49,943] Trial 17 finished with value: 136.5681577350647 and parameters: {'x': -3.401199455348756, 'y': 5, 'z': 'c'}. Best is trial 13 with value: 66.22134299056584.
[I 2025-03-05 07:55:49,944] Trial 18 finished with value: 113.61298663241652 and parameters: {'x': 2.1477864494442915, 'y': -3, 'z': 'c'}. Best is trial 13 with value: 66.22134299056584.
[I 2025-03-05 07:55:49,944] Trial 19 finished with value: 127.99347943483534 and parameters: {'x': -4.89831393796226, 'y': -2, 'z': 'a'}. Best is trial 13 with value: 66.22134299056584.
[I 2025-03-05 07:55:49,945] Trial 20 finished with value: 199.93840868200255 and parameters: {'x': 9.536163205503698, 'y': -3, 'z': 'a'}. Best is trial 13 with value: 66.22134299056584.
[I 2025-03-05 07:55:49,945] Trial 21 finished with value: 126.44197852100773 and parameters: {'x': 1.2008241007773464, 'y': 5, 'z': 'c'}. Best is trial 13 with value: 66.22134299056584.
[I 2025-03-05 07:55:49,945] Trial 22 finished with value: 109.92878917744126 and parameters: {'x': -8.598185225816042, 'y': 6, 'z': 'b'}. Best is trial 13 with value: 66.22134299056584.
[I 2025-03-05 07:55:49,946] Trial 23 finished with value: 49.2245310315918 and parameters: {'x': 6.724918663567003, 'y': -2, 'z': 'b'}. Best is trial 23 with value: 49.2245310315918.
[I 2025-03-05 07:55:49,946] Trial 24 finished with value: 147.4892039639181 and parameters: {'x': -9.924172709295123, 'y': 7, 'z': 'b'}. Best is trial 23 with value: 49.2245310315918.
[I 2025-03-05 07:55:49,947] Trial 25 finished with value: 104.30722722279079 and parameters: {'x': -0.5542808158242369, 'y': -2, 'z': 'a'}. Best is trial 23 with value: 49.2245310315918.
[I 2025-03-05 07:55:49,947] Trial 26 finished with value: 79.93259533612456 and parameters: {'x': 5.561707951351327, 'y': -7, 'z': 'b'}. Best is trial 23 with value: 49.2245310315918.
[I 2025-03-05 07:55:49,947] Trial 27 finished with value: 185.2759773577959 and parameters: {'x': -8.323219170356857, 'y': 4, 'z': 'a'}. Best is trial 23 with value: 49.2245310315918.
[I 2025-03-05 07:55:49,948] Trial 28 finished with value: 138.63017265445268 and parameters: {'x': 4.757118103899952, 'y': -4, 'z': 'a'}. Best is trial 23 with value: 49.2245310315918.
[I 2025-03-05 07:55:49,948] Trial 29 finished with value: 16.06786651043813 and parameters: {'x': -0.2605120159189038, 'y': 4, 'z': 'b'}. Best is trial 29 with value: 16.06786651043813.
[I 2025-03-05 07:55:49,949] Trial 30 finished with value: 174.18233138161332 and parameters: {'x': 8.377489563205277, 'y': 2, 'z': 'c'}. Best is trial 29 with value: 16.06786651043813.
[I 2025-03-05 07:55:49,949] Trial 31 finished with value: 126.17940414386516 and parameters: {'x': -1.0860037494710433, 'y': -5, 'z': 'c'}. Best is trial 29 with value: 16.06786651043813.
[I 2025-03-05 07:55:49,949] Trial 32 finished with value: 30.723721713173944 and parameters: {'x': 4.6608713469880225, 'y': -3, 'z': 'b'}. Best is trial 29 with value: 16.06786651043813.
[I 2025-03-05 07:55:49,950] Trial 33 finished with value: 121.22493156314977 and parameters: {'x': -4.150292949075977, 'y': 2, 'z': 'a'}. Best is trial 29 with value: 16.06786651043813.
[I 2025-03-05 07:55:49,950] Trial 34 finished with value: 186.93440998053097 and parameters: {'x': 6.159091652226891, 'y': -7, 'z': 'c'}. Best is trial 29 with value: 16.06786651043813.
[I 2025-03-05 07:55:49,950] Trial 35 finished with value: 205.0267430871541 and parameters: {'x': -8.308233451652288, 'y': -6, 'z': 'c'}. Best is trial 29 with value: 16.06786651043813.
[I 2025-03-05 07:55:49,951] Trial 36 finished with value: 43.303839501764436 and parameters: {'x': 4.278298669069802, 'y': -5, 'z': 'b'}. Best is trial 29 with value: 16.06786651043813.
[I 2025-03-05 07:55:49,951] Trial 37 finished with value: 18.543748859451874 and parameters: {'x': -4.188525857560375, 'y': -1, 'z': 'b'}. Best is trial 29 with value: 16.06786651043813.
[I 2025-03-05 07:55:49,952] Trial 38 finished with value: 210.9334668225266 and parameters: {'x': 5.4711485834810425, 'y': 9, 'z': 'c'}. Best is trial 29 with value: 16.06786651043813.
[I 2025-03-05 07:55:49,952] Trial 39 finished with value: 1.1598836347599575 and parameters: {'x': -0.3998545169933152, 'y': -1, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,952] Trial 40 finished with value: 26.634072853912187 and parameters: {'x': 5.06301025615317, 'y': 1, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,953] Trial 41 finished with value: 186.2382028251756 and parameters: {'x': -6.102311269115628, 'y': -7, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,953] Trial 42 finished with value: 122.82868657931331 and parameters: {'x': -2.613175573763331, 'y': -4, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,953] Trial 43 finished with value: 104.89571507156761 and parameters: {'x': 4.8883243623523605, 'y': 9, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,954] Trial 44 finished with value: 61.141093225660995 and parameters: {'x': 6.718712170175248, 'y': 4, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,954] Trial 45 finished with value: 48.10709695763319 and parameters: {'x': -6.253566738880556, 'y': -3, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,955] Trial 46 finished with value: 298.66229153853146 and parameters: {'x': -9.932889385195601, 'y': -10, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,955] Trial 47 finished with value: 170.58614333258782 and parameters: {'x': 7.847683947037357, 'y': -3, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,955] Trial 48 finished with value: 49.498530569825064 and parameters: {'x': -6.745259859325293, 'y': 2, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,956] Trial 49 finished with value: 121.87105376104218 and parameters: {'x': -2.423025745022569, 'y': -4, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,956] Trial 50 finished with value: 116.43524442687192 and parameters: {'x': 0.6597305714243689, 'y': -4, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,956] Trial 51 finished with value: 9.18436370673212 and parameters: {'x': -2.860832694641915, 'y': 1, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,957] Trial 52 finished with value: 65.12068062313638 and parameters: {'x': 5.396358088853665, 'y': 6, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,957] Trial 53 finished with value: 278.8871419215957 and parameters: {'x': 8.881843385333681, 'y': -10, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,957] Trial 54 finished with value: 2.2628119825827264 and parameters: {'x': 1.1237490745636798, 'y': 1, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,958] Trial 55 finished with value: 189.61303590326042 and parameters: {'x': -9.252731267212964, 'y': 2, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,958] Trial 56 finished with value: 90.62369301033729 and parameters: {'x': -3.1022077638896617, 'y': -9, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,959] Trial 57 finished with value: 148.54241237028856 and parameters: {'x': 6.288275786754948, 'y': -3, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,959] Trial 58 finished with value: 191.60357918993242 and parameters: {'x': -8.161101591692903, 'y': -5, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,959] Trial 59 finished with value: 99.48966467936017 and parameters: {'x': -9.924195921048726, 'y': 1, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,960] Trial 60 finished with value: 146.2954252956863 and parameters: {'x': 4.614696663453223, 'y': 5, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,960] Trial 61 finished with value: 192.78318626931133 and parameters: {'x': 6.616886448270918, 'y': 7, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,960] Trial 62 finished with value: 83.7868950087383 and parameters: {'x': 4.448246284631539, 'y': 8, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,961] Trial 63 finished with value: 164.18173921436062 and parameters: {'x': 3.8963751377864835, 'y': 7, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,961] Trial 64 finished with value: 241.39791671469868 and parameters: {'x': -8.797608579307145, 'y': -8, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,962] Trial 65 finished with value: 108.05097985525866 and parameters: {'x': -2.0127046120230023, 'y': -2, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,962] Trial 66 finished with value: 98.67268131846735 and parameters: {'x': -8.583279170484166, 'y': 5, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,962] Trial 67 finished with value: 156.5685506102377 and parameters: {'x': -7.250417271456707, 'y': -2, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,963] Trial 68 finished with value: 225.3902310424445 and parameters: {'x': 9.45464071461441, 'y': -6, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,963] Trial 69 finished with value: 246.32219057357366 and parameters: {'x': 8.08221445976124, 'y': -9, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,963] Trial 70 finished with value: 192.70635281908557 and parameters: {'x': 8.228387011989991, 'y': 5, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,964] Trial 71 finished with value: 161.85727381269248 and parameters: {'x': 3.5857040888356195, 'y': 7, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,964] Trial 72 finished with value: 201.88995990493814 and parameters: {'x': -8.768692029313046, 'y': -5, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,965] Trial 73 finished with value: 149.73678812808677 and parameters: {'x': 0.8583636339493737, 'y': 7, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,965] Trial 74 finished with value: 181.87448619177664 and parameters: {'x': 8.993024307304893, 'y': -1, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,965] Trial 75 finished with value: 75.26316180868571 and parameters: {'x': -8.140218781377175, 'y': 3, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,966] Trial 76 finished with value: 125.32540823960503 and parameters: {'x': -7.83105409505036, 'y': 8, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,966] Trial 77 finished with value: 133.6706966425615 and parameters: {'x': -4.966960503422742, 'y': 3, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,966] Trial 78 finished with value: 175.4260995806747 and parameters: {'x': 8.684820066108145, 'y': -10, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,967] Trial 79 finished with value: 47.33908290507672 and parameters: {'x': 6.583242582882445, 'y': -2, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,967] Trial 80 finished with value: 47.15183565167661 and parameters: {'x': 6.866719424272162, 'y': 0, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,968] Trial 81 finished with value: 128.30203371500204 and parameters: {'x': -1.8171498878744288, 'y': 5, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,968] Trial 82 finished with value: 142.48401219776753 and parameters: {'x': -5.786537150815462, 'y': -3, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,969] Trial 83 finished with value: 116.5739968025158 and parameters: {'x': -4.071117389920831, 'y': 0, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,969] Trial 84 finished with value: 6.655497897843949 and parameters: {'x': 1.629569850556873, 'y': 2, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,970] Trial 85 finished with value: 163.71775977861688 and parameters: {'x': 6.2223596632320195, 'y': 5, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,970] Trial 86 finished with value: 100.79797401283128 and parameters: {'x': -0.8932939117845091, 'y': 0, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,971] Trial 87 finished with value: 227.28118036188357 and parameters: {'x': 9.554118502608368, 'y': 6, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,971] Trial 88 finished with value: 144.79835802241942 and parameters: {'x': -7.987387434100053, 'y': -9, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,971] Trial 89 finished with value: 101.90090610333684 and parameters: {'x': -1.3787335142574992, 'y': 0, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,972] Trial 90 finished with value: 48.93172934248159 and parameters: {'x': 6.995121824706242, 'y': 0, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,972] Trial 91 finished with value: 186.36806616967658 and parameters: {'x': -7.097046298966676, 'y': -6, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,973] Trial 92 finished with value: 10.339031474154794 and parameters: {'x': -1.1571652752112787, 'y': 3, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,973] Trial 93 finished with value: 242.98918305167365 and parameters: {'x': 9.694801857267308, 'y': 7, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,973] Trial 94 finished with value: 157.4738329802203 and parameters: {'x': -7.514907383342811, 'y': -1, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,974] Trial 95 finished with value: 19.37334772356031 and parameters: {'x': -1.8366675593477204, 'y': -4, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,974] Trial 96 finished with value: 100.55705680806531 and parameters: {'x': -0.7463623838761677, 'y': 0, 'z': 'c'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,974] Trial 97 finished with value: 126.44666121556273 and parameters: {'x': -8.800378470018362, 'y': 7, 'z': 'b'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,975] Trial 98 finished with value: 200.51882187639706 and parameters: {'x': -0.7202929101393867, 'y': -10, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
[I 2025-03-05 07:55:49,975] Trial 99 finished with value: 151.48458687375194 and parameters: {'x': 3.9350459811483685, 'y': -6, 'z': 'a'}. Best is trial 39 with value: 1.1598836347599575.
The best parameters can be fetched as follows.
best_params = study.best_params
best_value = study.best_value
print(f"Best params: {best_params}, Best value: {best_value}")
Best params: {'x': -0.3998545169933152, 'y': -1, 'z': 'b'}, Best value: 1.1598836347599575
We can see that best_params
value found by Optuna is close to the optimal value {"x":0, "y": 0, "z": "b"}
.
In the above examples, search space is estimated at the first trial and updated dynamically through optimization.
If your sampler requires the search space to be fixed before optimization, you can pass the search space to the sampler at initialization.
Passing the search space also allows the sampler to avoid the overhead of estimating the search space.
See the documentation for more information about the optuna.distributions
to define search space.
sampler = MySampler(
search_space={
"x": optuna.distributions.FloatDistribution(-10, 10),
"y": optuna.distributions.IntDistribution(-10, 10),
"z": optuna.distributions.CategoricalDistribution(["a", "b", "c"]),
}
)
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=100)
[I 2025-03-05 07:55:49,976] A new study created in memory with name: no-name-d912e365-93db-4f7f-9a76-627b28ad4dad
[I 2025-03-05 07:55:49,977] Trial 0 finished with value: 129.2837543328353 and parameters: {'x': -5.318247298954355, 'y': 1, 'z': 'c'}. Best is trial 0 with value: 129.2837543328353.
[I 2025-03-05 07:55:49,977] Trial 1 finished with value: 157.13891690359983 and parameters: {'x': 6.938221451034828, 'y': -3, 'z': 'c'}. Best is trial 0 with value: 129.2837543328353.
[I 2025-03-05 07:55:49,978] Trial 2 finished with value: 68.3411692449198 and parameters: {'x': 4.397859620874659, 'y': -7, 'z': 'b'}. Best is trial 2 with value: 68.3411692449198.
[I 2025-03-05 07:55:49,978] Trial 3 finished with value: 206.21914944933872 and parameters: {'x': -8.379686715464889, 'y': -6, 'z': 'a'}. Best is trial 2 with value: 68.3411692449198.
[I 2025-03-05 07:55:49,978] Trial 4 finished with value: 161.90212534996556 and parameters: {'x': 7.2733847244570775, 'y': 3, 'z': 'c'}. Best is trial 2 with value: 68.3411692449198.
[I 2025-03-05 07:55:49,979] Trial 5 finished with value: 157.27409203199858 and parameters: {'x': -4.612384636172331, 'y': -6, 'z': 'a'}. Best is trial 2 with value: 68.3411692449198.
[I 2025-03-05 07:55:49,979] Trial 6 finished with value: 206.06975826978788 and parameters: {'x': 8.37076808123292, 'y': 6, 'z': 'c'}. Best is trial 2 with value: 68.3411692449198.
[I 2025-03-05 07:55:49,979] Trial 7 finished with value: 208.2370782755601 and parameters: {'x': 2.870031058291895, 'y': -10, 'z': 'a'}. Best is trial 2 with value: 68.3411692449198.
[I 2025-03-05 07:55:49,979] Trial 8 finished with value: 125.02404909835701 and parameters: {'x': -3.0040055090423863, 'y': 4, 'z': 'c'}. Best is trial 2 with value: 68.3411692449198.
[I 2025-03-05 07:55:49,980] Trial 9 finished with value: 16.340923219749268 and parameters: {'x': 0.5838863072116585, 'y': -4, 'z': 'b'}. Best is trial 9 with value: 16.340923219749268.
[I 2025-03-05 07:55:49,980] Trial 10 finished with value: 105.95688048924212 and parameters: {'x': -1.398885445360742, 'y': 2, 'z': 'c'}. Best is trial 9 with value: 16.340923219749268.
[I 2025-03-05 07:55:49,980] Trial 11 finished with value: 170.13049038725137 and parameters: {'x': 8.314474751134394, 'y': 1, 'z': 'c'}. Best is trial 9 with value: 16.340923219749268.
[I 2025-03-05 07:55:49,981] Trial 12 finished with value: 46.11415714221093 and parameters: {'x': -4.595014378890552, 'y': -5, 'z': 'b'}. Best is trial 9 with value: 16.340923219749268.
[I 2025-03-05 07:55:49,981] Trial 13 finished with value: 147.6376382874086 and parameters: {'x': -9.931648316740208, 'y': -7, 'z': 'b'}. Best is trial 9 with value: 16.340923219749268.
[I 2025-03-05 07:55:49,981] Trial 14 finished with value: 134.18917683147572 and parameters: {'x': -7.293091034086694, 'y': 9, 'z': 'b'}. Best is trial 9 with value: 16.340923219749268.
[I 2025-03-05 07:55:49,982] Trial 15 finished with value: 210.8134307430627 and parameters: {'x': 3.288378132615332, 'y': -10, 'z': 'a'}. Best is trial 9 with value: 16.340923219749268.
[I 2025-03-05 07:55:49,982] Trial 16 finished with value: 180.69249240875246 and parameters: {'x': 9.98461278211391, 'y': 9, 'z': 'b'}. Best is trial 9 with value: 16.340923219749268.
[I 2025-03-05 07:55:49,982] Trial 17 finished with value: 195.8145397971477 and parameters: {'x': 3.848966068588771, 'y': -9, 'z': 'a'}. Best is trial 9 with value: 16.340923219749268.
[I 2025-03-05 07:55:49,983] Trial 18 finished with value: 106.82947951092133 and parameters: {'x': -9.530450121107677, 'y': 4, 'z': 'b'}. Best is trial 9 with value: 16.340923219749268.
[I 2025-03-05 07:55:49,983] Trial 19 finished with value: 213.63650565590245 and parameters: {'x': 7.045317995371285, 'y': 8, 'z': 'a'}. Best is trial 9 with value: 16.340923219749268.
[I 2025-03-05 07:55:49,983] Trial 20 finished with value: 15.779920062912636 and parameters: {'x': -3.4321888151604707, 'y': -2, 'z': 'b'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,984] Trial 21 finished with value: 92.85663610000773 and parameters: {'x': -6.622434303185479, 'y': -7, 'z': 'b'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,984] Trial 22 finished with value: 116.00612810714426 and parameters: {'x': -0.07828222751216884, 'y': -4, 'z': 'c'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,984] Trial 23 finished with value: 238.14251633105096 and parameters: {'x': 6.175962785756642, 'y': -10, 'z': 'c'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,984] Trial 24 finished with value: 201.63731869254246 and parameters: {'x': -1.279577544560098, 'y': -10, 'z': 'a'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,985] Trial 25 finished with value: 105.69138512959498 and parameters: {'x': 9.83317777372071, 'y': 3, 'z': 'b'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,985] Trial 26 finished with value: 129.94773539399816 and parameters: {'x': -5.380309971925239, 'y': -1, 'z': 'a'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,985] Trial 27 finished with value: 170.22711157530637 and parameters: {'x': -2.4954181163296756, 'y': 8, 'z': 'a'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,986] Trial 28 finished with value: 183.93298373475812 and parameters: {'x': 1.7125956133186087, 'y': 9, 'z': 'a'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,986] Trial 29 finished with value: 96.01500017069145 and parameters: {'x': -7.746934888760293, 'y': 6, 'z': 'b'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,986] Trial 30 finished with value: 130.64720045618205 and parameters: {'x': 5.444924283787797, 'y': 1, 'z': 'c'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,987] Trial 31 finished with value: 181.71628756300683 and parameters: {'x': -0.8463377357809492, 'y': -9, 'z': 'c'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,987] Trial 32 finished with value: 132.53585798756845 and parameters: {'x': 5.615679654998889, 'y': 1, 'z': 'c'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,987] Trial 33 finished with value: 204.28639657471152 and parameters: {'x': 2.070361459917452, 'y': -10, 'z': 'c'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,988] Trial 34 finished with value: 42.42099480540475 and parameters: {'x': -4.173846523939848, 'y': 5, 'z': 'b'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,988] Trial 35 finished with value: 221.92759467339846 and parameters: {'x': -9.845181292053411, 'y': 5, 'z': 'c'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,988] Trial 36 finished with value: 200.26039759300832 and parameters: {'x': -0.5102916744454298, 'y': -10, 'z': 'c'}. Best is trial 20 with value: 15.779920062912636.
[I 2025-03-05 07:55:49,989] Trial 37 finished with value: 5.921488495728907 and parameters: {'x': 1.3861776566259127, 'y': 2, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,989] Trial 38 finished with value: 123.65463921321778 and parameters: {'x': -3.82813782578655, 'y': 3, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,989] Trial 39 finished with value: 194.2460651731445 and parameters: {'x': 9.232879571030075, 'y': -3, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,990] Trial 40 finished with value: 100.21561277618613 and parameters: {'x': 0.46434122817829504, 'y': -10, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,990] Trial 41 finished with value: 165.24282026859257 and parameters: {'x': -7.017322870482201, 'y': -4, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,990] Trial 42 finished with value: 158.30237480760843 and parameters: {'x': 5.770820982114106, 'y': -5, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,990] Trial 43 finished with value: 141.65233867837156 and parameters: {'x': -2.377464758597185, 'y': -6, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,991] Trial 44 finished with value: 224.72643824043925 and parameters: {'x': -9.419471229343994, 'y': -6, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,991] Trial 45 finished with value: 65.44943787053931 and parameters: {'x': -1.2039260236988465, 'y': 8, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,991] Trial 46 finished with value: 58.04453497347996 and parameters: {'x': -7.003180347062323, 'y': 3, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,992] Trial 47 finished with value: 139.5505322037001 and parameters: {'x': 3.814515985508528, 'y': 5, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,992] Trial 48 finished with value: 133.77487718637786 and parameters: {'x': 4.977436808878426, 'y': -3, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,992] Trial 49 finished with value: 121.65305341489073 and parameters: {'x': 2.377615068696093, 'y': -4, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,993] Trial 50 finished with value: 40.38358579933989 and parameters: {'x': -2.0937014589811724, 'y': -6, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,993] Trial 51 finished with value: 127.04655109484104 and parameters: {'x': -4.248123243838511, 'y': -3, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,993] Trial 52 finished with value: 280.45720853895625 and parameters: {'x': 9.972823498837041, 'y': 9, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,994] Trial 53 finished with value: 234.14581625983388 and parameters: {'x': 7.2901177123441485, 'y': 9, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,994] Trial 54 finished with value: 145.91710422043653 and parameters: {'x': 4.573522080457963, 'y': 5, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,994] Trial 55 finished with value: 181.70456313180227 and parameters: {'x': 0.8393825896468634, 'y': -9, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,995] Trial 56 finished with value: 193.531008737982 and parameters: {'x': -5.434244081561115, 'y': 8, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,995] Trial 57 finished with value: 180.84814872427438 and parameters: {'x': -8.93577913358843, 'y': -1, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,995] Trial 58 finished with value: 175.82524340361124 and parameters: {'x': 7.129182520009657, 'y': 5, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,995] Trial 59 finished with value: 132.05185450914502 and parameters: {'x': 5.661435728606749, 'y': 0, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,996] Trial 60 finished with value: 82.09910349602109 and parameters: {'x': 1.0483813695507411, 'y': -9, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,996] Trial 61 finished with value: 178.07951236412734 and parameters: {'x': 7.879055296425285, 'y': 4, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,996] Trial 62 finished with value: 127.16213440743377 and parameters: {'x': -1.4704198065293355, 'y': -5, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,997] Trial 63 finished with value: 238.40370209407683 and parameters: {'x': -7.576523087411324, 'y': -9, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,997] Trial 64 finished with value: 127.67303238192035 and parameters: {'x': 8.869781980517917, 'y': 7, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,997] Trial 65 finished with value: 154.6154743258702 and parameters: {'x': -4.314565369289265, 'y': -6, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,998] Trial 66 finished with value: 130.56778157998454 and parameters: {'x': -2.359614710071229, 'y': 5, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,998] Trial 67 finished with value: 20.92800238682124 and parameters: {'x': 4.574713366629787, 'y': 0, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,998] Trial 68 finished with value: 163.42315887351177 and parameters: {'x': -3.7977834158245205, 'y': 7, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,999] Trial 69 finished with value: 139.0258699160478 and parameters: {'x': 5.918265786195127, 'y': -2, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,999] Trial 70 finished with value: 241.45949407659205 and parameters: {'x': -6.438904726472668, 'y': -10, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:49,999] Trial 71 finished with value: 112.82320572291637 and parameters: {'x': 1.9553019518520323, 'y': 3, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,000] Trial 72 finished with value: 209.90218206115233 and parameters: {'x': -7.803985011591983, 'y': -7, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,000] Trial 73 finished with value: 237.05405644672976 and parameters: {'x': 8.54716657417707, 'y': -8, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,000] Trial 74 finished with value: 107.06579797271463 and parameters: {'x': -2.4628840761827657, 'y': -1, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,000] Trial 75 finished with value: 102.11075793130645 and parameters: {'x': 1.0539250121837185, 'y': 1, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,001] Trial 76 finished with value: 48.7049426330899 and parameters: {'x': -6.978892650921771, 'y': 0, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,001] Trial 77 finished with value: 120.93034287057993 and parameters: {'x': 2.2204375403464827, 'y': -4, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,001] Trial 78 finished with value: 177.80237882655712 and parameters: {'x': 3.715155289696126, 'y': 8, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,002] Trial 79 finished with value: 203.67417949124894 and parameters: {'x': -9.730065749585094, 'y': -3, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,002] Trial 80 finished with value: 225.49869545016463 and parameters: {'x': -7.842110395178368, 'y': -8, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,002] Trial 81 finished with value: 15.374140476027772 and parameters: {'x': 2.5247060177430107, 'y': 3, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,003] Trial 82 finished with value: 100.2598465629577 and parameters: {'x': 0.5097514717562959, 'y': -10, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,003] Trial 83 finished with value: 51.27414160203488 and parameters: {'x': 5.939203785191655, 'y': 4, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,003] Trial 84 finished with value: 109.62492071187641 and parameters: {'x': 2.9368215321800566, 'y': -1, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,004] Trial 85 finished with value: 174.36995660060094 and parameters: {'x': 3.2202416990966594, 'y': 8, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,004] Trial 86 finished with value: 116.91064281551213 and parameters: {'x': -4.112255198247324, 'y': 0, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,004] Trial 87 finished with value: 116.57824046912458 and parameters: {'x': -0.7604212445247516, 'y': 4, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,005] Trial 88 finished with value: 105.48103761572007 and parameters: {'x': -2.3411615953880816, 'y': 0, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,005] Trial 89 finished with value: 60.75681489883934 and parameters: {'x': -6.690053430193165, 'y': 4, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,005] Trial 90 finished with value: 90.60395652937841 and parameters: {'x': 9.465936643004664, 'y': 1, 'z': 'b'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,006] Trial 91 finished with value: 187.90410365549394 and parameters: {'x': -2.627566108681938, 'y': -9, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,006] Trial 92 finished with value: 116.56901638450329 and parameters: {'x': 0.7543317469809185, 'y': -4, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,006] Trial 93 finished with value: 233.41674503345163 and parameters: {'x': 5.780721843632648, 'y': -10, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,006] Trial 94 finished with value: 140.28079469456412 and parameters: {'x': 3.9090657060945055, 'y': 5, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,007] Trial 95 finished with value: 164.0000107497937 and parameters: {'x': -0.003278687799285862, 'y': 8, 'z': 'c'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,007] Trial 96 finished with value: 185.6998651025795 and parameters: {'x': -8.348644506899278, 'y': -4, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,007] Trial 97 finished with value: 162.40019195544895 and parameters: {'x': 5.138111711071389, 'y': 6, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,008] Trial 98 finished with value: 177.9291902888853 and parameters: {'x': 8.770928701619077, 'y': 1, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
[I 2025-03-05 07:55:50,008] Trial 99 finished with value: 163.4649033615783 and parameters: {'x': 6.889477727780118, 'y': -4, 'z': 'a'}. Best is trial 37 with value: 5.921488495728907.
In the next recipe, we will show how to register your sampler to OptunaHub. Let’s move on to How to Register Your Package with OptunaHub. See the User-Defined Sampler documentation for more information to implement a sampler.
Total running time of the script: (0 minutes 0.457 seconds)