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-04-25 10:32:07,485] A new study created in memory with name: no-name-14569bb7-252a-4c1e-87c3-5b2fb2e509dc
[I 2025-04-25 10:32:07,486] Trial 0 finished with value: 156.09176452247772 and parameters: {'x': -5.575998970810316, 'y': -5, 'z': 'c'}. Best is trial 0 with value: 156.09176452247772.
[I 2025-04-25 10:32:07,487] Trial 1 finished with value: 106.13164664093946 and parameters: {'x': 7.558547918809502, 'y': 7, 'z': 'b'}. Best is trial 1 with value: 106.13164664093946.
[I 2025-04-25 10:32:07,487] Trial 2 finished with value: 117.19989834840948 and parameters: {'x': -3.6331664355503275, 'y': 2, 'z': 'c'}. Best is trial 1 with value: 106.13164664093946.
[I 2025-04-25 10:32:07,488] Trial 3 finished with value: 128.12648287866588 and parameters: {'x': -6.864873114535031, 'y': -9, 'z': 'b'}. Best is trial 1 with value: 106.13164664093946.
[I 2025-04-25 10:32:07,488] Trial 4 finished with value: 137.53197891829782 and parameters: {'x': 1.2377313595032735, 'y': -6, 'z': 'a'}. Best is trial 1 with value: 106.13164664093946.
[I 2025-04-25 10:32:07,489] Trial 5 finished with value: 59.206049990193065 and parameters: {'x': -7.629288957051834, 'y': 1, 'z': 'b'}. Best is trial 5 with value: 59.206049990193065.
[I 2025-04-25 10:32:07,489] Trial 6 finished with value: 98.25347939896683 and parameters: {'x': -9.069370397054408, 'y': -4, 'z': 'b'}. Best is trial 5 with value: 59.206049990193065.
[I 2025-04-25 10:32:07,490] Trial 7 finished with value: 164.70276948447494 and parameters: {'x': -0.8383134762575022, 'y': 8, 'z': 'a'}. Best is trial 5 with value: 59.206049990193065.
[I 2025-04-25 10:32:07,490] Trial 8 finished with value: 251.48830785610858 and parameters: {'x': 9.353518474676179, 'y': -8, 'z': 'c'}. Best is trial 5 with value: 59.206049990193065.
[I 2025-04-25 10:32:07,490] Trial 9 finished with value: 255.8956632592755 and parameters: {'x': -9.586222575095755, 'y': -8, 'z': 'a'}. Best is trial 5 with value: 59.206049990193065.
[I 2025-04-25 10:32:07,491] Trial 10 finished with value: 156.03700232067166 and parameters: {'x': 6.327479934434535, 'y': 4, 'z': 'a'}. Best is trial 5 with value: 59.206049990193065.
[I 2025-04-25 10:32:07,491] Trial 11 finished with value: 149.04494193894112 and parameters: {'x': 0.2119951389563397, 'y': 7, 'z': 'a'}. Best is trial 5 with value: 59.206049990193065.
[I 2025-04-25 10:32:07,492] Trial 12 finished with value: 36.51100474923758 and parameters: {'x': 5.959111070389406, 'y': -1, 'z': 'b'}. Best is trial 12 with value: 36.51100474923758.
[I 2025-04-25 10:32:07,492] Trial 13 finished with value: 55.34485112300091 and parameters: {'x': -4.398278199818755, 'y': 6, 'z': 'b'}. Best is trial 12 with value: 36.51100474923758.
[I 2025-04-25 10:32:07,492] Trial 14 finished with value: 152.8598399871934 and parameters: {'x': -6.989981401062051, 'y': -2, 'z': 'c'}. Best is trial 12 with value: 36.51100474923758.
[I 2025-04-25 10:32:07,493] Trial 15 finished with value: 167.30404612925702 and parameters: {'x': -1.817703531728153, 'y': 8, 'z': 'a'}. Best is trial 12 with value: 36.51100474923758.
[I 2025-04-25 10:32:07,493] Trial 16 finished with value: 141.91153641758075 and parameters: {'x': 5.736857712858212, 'y': -3, 'z': 'c'}. Best is trial 12 with value: 36.51100474923758.
[I 2025-04-25 10:32:07,494] Trial 17 finished with value: 194.6261087044022 and parameters: {'x': 8.344226069828299, 'y': -5, 'z': 'a'}. Best is trial 12 with value: 36.51100474923758.
[I 2025-04-25 10:32:07,494] Trial 18 finished with value: 5.334967702008537 and parameters: {'x': 1.1554080240367632, 'y': 2, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,494] Trial 19 finished with value: 43.06765620279272 and parameters: {'x': 4.250606568807882, 'y': 5, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,495] Trial 20 finished with value: 149.31985797197217 and parameters: {'x': 0.5655598747897308, 'y': -7, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,495] Trial 21 finished with value: 115.68374588058902 and parameters: {'x': -2.5852941574584936, 'y': -3, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,495] Trial 22 finished with value: 235.6636619429965 and parameters: {'x': 9.309331981565407, 'y': -7, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,496] Trial 23 finished with value: 256.08686486271444 and parameters: {'x': -8.665267731738842, 'y': -9, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,496] Trial 24 finished with value: 76.4179220644919 and parameters: {'x': -5.236212568688547, 'y': -7, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,497] Trial 25 finished with value: 200.23401606037078 and parameters: {'x': -4.38566027644308, 'y': 9, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,497] Trial 26 finished with value: 9.087209025779678 and parameters: {'x': 0.29531174338261224, 'y': -3, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,497] Trial 27 finished with value: 153.2689464153902 and parameters: {'x': 6.653491295206614, 'y': -3, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,498] Trial 28 finished with value: 192.6461402530237 and parameters: {'x': 7.526363016293043, 'y': 6, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,498] Trial 29 finished with value: 114.14561578105506 and parameters: {'x': 2.2683949790667093, 'y': 3, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,498] Trial 30 finished with value: 265.00639928134217 and parameters: {'x': 8.062654605112524, 'y': -10, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,499] Trial 31 finished with value: 114.90009410245285 and parameters: {'x': -3.3015290552186354, 'y': 2, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,499] Trial 32 finished with value: 106.49085371091539 and parameters: {'x': 2.343257073160217, 'y': -1, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,499] Trial 33 finished with value: 102.21305706737931 and parameters: {'x': 1.4876347224299753, 'y': 0, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,500] Trial 34 finished with value: 150.13808476408136 and parameters: {'x': -1.0668105567912978, 'y': 7, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,500] Trial 35 finished with value: 12.095013962864673 and parameters: {'x': -1.759265176960163, 'y': 3, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,501] Trial 36 finished with value: 83.5072952841934 and parameters: {'x': -1.5834441209570365, 'y': -9, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,501] Trial 37 finished with value: 168.148893416461 and parameters: {'x': -2.0368832603909803, 'y': -8, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,501] Trial 38 finished with value: 68.6942739842655 and parameters: {'x': 8.043275078241791, 'y': 2, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,502] Trial 39 finished with value: 87.40910358628895 and parameters: {'x': -7.89994326475127, 'y': 5, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,502] Trial 40 finished with value: 219.70418931240005 and parameters: {'x': 9.731607745506395, 'y': -5, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,502] Trial 41 finished with value: 155.5316259049264 and parameters: {'x': -9.567216204566844, 'y': 8, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,503] Trial 42 finished with value: 206.73201006763657 and parameters: {'x': -8.410232462163966, 'y': -6, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,503] Trial 43 finished with value: 142.4281423578734 and parameters: {'x': -2.5353781488908966, 'y': -6, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,503] Trial 44 finished with value: 144.50094777252602 and parameters: {'x': 4.41598774596647, 'y': 5, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,504] Trial 45 finished with value: 133.59264978453425 and parameters: {'x': -4.95909767846271, 'y': 3, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,504] Trial 46 finished with value: 170.02114580028308 and parameters: {'x': -8.367863873192674, 'y': 0, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,505] Trial 47 finished with value: 107.15930280098178 and parameters: {'x': 9.064176895944925, 'y': -5, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,505] Trial 48 finished with value: 271.01213944826395 and parameters: {'x': -9.487472764032788, 'y': -9, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,505] Trial 49 finished with value: 189.34496326429945 and parameters: {'x': -2.888765006763176, 'y': -9, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,506] Trial 50 finished with value: 145.34463382282132 and parameters: {'x': -3.0568993805523466, 'y': -6, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,506] Trial 51 finished with value: 104.43106926521368 and parameters: {'x': -1.8523145697245056, 'y': -1, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,506] Trial 52 finished with value: 132.2640348789044 and parameters: {'x': -9.124912869660971, 'y': -7, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,507] Trial 53 finished with value: 174.5269450759159 and parameters: {'x': -8.574785424482405, 'y': -1, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,507] Trial 54 finished with value: 188.34954378837799 and parameters: {'x': -9.184200770256385, 'y': -2, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,507] Trial 55 finished with value: 107.02873888298035 and parameters: {'x': 9.540898222021884, 'y': -4, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,508] Trial 56 finished with value: 161.70983359484165 and parameters: {'x': -3.565085355898459, 'y': 7, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,508] Trial 57 finished with value: 18.40970241820204 and parameters: {'x': 1.5523216220236193, 'y': 4, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,509] Trial 58 finished with value: 163.1183397062301 and parameters: {'x': -3.7574379178144905, 'y': -7, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,509] Trial 59 finished with value: 267.2373120554068 and parameters: {'x': 9.286404689405195, 'y': 9, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,509] Trial 60 finished with value: 94.85159138320873 and parameters: {'x': -6.771380315948051, 'y': -7, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,510] Trial 61 finished with value: 117.54584542027999 and parameters: {'x': -2.9233277989784145, 'y': -3, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,510] Trial 62 finished with value: 116.84577653469731 and parameters: {'x': 0.9196610977405264, 'y': 4, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,510] Trial 63 finished with value: 81.18911359343994 and parameters: {'x': -8.785733526202575, 'y': -2, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,511] Trial 64 finished with value: 35.578475387961426 and parameters: {'x': 3.252456823381584, 'y': 5, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,511] Trial 65 finished with value: 206.20021691600874 and parameters: {'x': -9.497379476256002, 'y': -4, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,512] Trial 66 finished with value: 146.63707248253831 and parameters: {'x': -6.829134094637352, 'y': -10, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,512] Trial 67 finished with value: 10.447560450479125 and parameters: {'x': 1.2031460636510953, 'y': 3, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,512] Trial 68 finished with value: 212.96787370261882 and parameters: {'x': 9.379119025933022, 'y': -5, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,513] Trial 69 finished with value: 184.63424362171642 and parameters: {'x': 5.9694424883498485, 'y': 7, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,513] Trial 70 finished with value: 21.35787446639305 and parameters: {'x': -4.511970131371998, 'y': -1, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,513] Trial 71 finished with value: 99.77339674880851 and parameters: {'x': 9.786388340384235, 'y': 2, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,514] Trial 72 finished with value: 168.06060378379163 and parameters: {'x': 4.365845139694219, 'y': -7, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,514] Trial 73 finished with value: 142.07136422676427 and parameters: {'x': 5.106012556463632, 'y': -4, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,514] Trial 74 finished with value: 236.69013100228966 and parameters: {'x': -8.52585074947302, 'y': 8, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,515] Trial 75 finished with value: 170.44881071669175 and parameters: {'x': 8.151613994583634, 'y': 2, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,515] Trial 76 finished with value: 184.26900276723305 and parameters: {'x': 4.502110923470571, 'y': -8, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,515] Trial 77 finished with value: 169.966355160077 and parameters: {'x': 7.346179630262046, 'y': 4, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,517] Trial 78 finished with value: 149.1767538292276 and parameters: {'x': -6.7213654735647, 'y': 2, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,517] Trial 79 finished with value: 219.43850162436982 and parameters: {'x': -4.408911614488298, 'y': -10, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,517] Trial 80 finished with value: 137.19635144544665 and parameters: {'x': 4.603949548534025, 'y': 4, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,518] Trial 81 finished with value: 48.44205804074706 and parameters: {'x': 3.5273301576046237, 'y': -6, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,518] Trial 82 finished with value: 126.1707965755115 and parameters: {'x': 4.708587535080079, 'y': -2, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,518] Trial 83 finished with value: 175.24925236998865 and parameters: {'x': -9.708205414492868, 'y': 9, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,519] Trial 84 finished with value: 59.42931393351671 and parameters: {'x': 4.840383655612095, 'y': 6, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,519] Trial 85 finished with value: 240.24254065466437 and parameters: {'x': 7.696917607371432, 'y': -9, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,520] Trial 86 finished with value: 139.1694524202711 and parameters: {'x': -6.178143120733861, 'y': -1, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,520] Trial 87 finished with value: 182.2282169493886 and parameters: {'x': 6.799133544017842, 'y': 6, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,520] Trial 88 finished with value: 209.4093499124957 and parameters: {'x': 7.772345200291589, 'y': -7, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,521] Trial 89 finished with value: 120.23707260717 and parameters: {'x': 9.178075648368235, 'y': 6, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,521] Trial 90 finished with value: 16.053524209058313 and parameters: {'x': 0.2313529966486545, 'y': 4, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,521] Trial 91 finished with value: 87.62966003257137 and parameters: {'x': -2.574812620866103, 'y': 9, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,522] Trial 92 finished with value: 180.576579267596 and parameters: {'x': -4.071434546642743, 'y': 8, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,522] Trial 93 finished with value: 150.88581614536463 and parameters: {'x': -3.858214113468124, 'y': 6, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,522] Trial 94 finished with value: 9.114790809689941 and parameters: {'x': 0.3388079244792568, 'y': -3, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,523] Trial 95 finished with value: 57.96849228902293 and parameters: {'x': 6.4783093696598755, 'y': 4, 'z': 'b'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,523] Trial 96 finished with value: 139.15433935498456 and parameters: {'x': -1.776045988983551, 'y': -6, 'z': 'c'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,524] Trial 97 finished with value: 123.97784153159856 and parameters: {'x': 3.8701216429976135, 'y': 3, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,524] Trial 98 finished with value: 116.21577787861776 and parameters: {'x': -0.4645189755195833, 'y': 4, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
[I 2025-04-25 10:32:07,524] Trial 99 finished with value: 139.1807233216099 and parameters: {'x': -5.4936985102579, 'y': -3, 'z': 'a'}. Best is trial 18 with value: 5.334967702008537.
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': 1.1554080240367632, 'y': 2, 'z': 'b'}, Best value: 5.334967702008537
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-04-25 10:32:07,525] A new study created in memory with name: no-name-4ca7e8f6-388d-4d95-9045-0077241ed037
[I 2025-04-25 10:32:07,526] Trial 0 finished with value: 29.838126087406195 and parameters: {'x': -3.7199631836089715, 'y': 4, 'z': 'b'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,526] Trial 1 finished with value: 181.33414433530137 and parameters: {'x': 0.5780521908109826, 'y': -9, 'z': 'c'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,527] Trial 2 finished with value: 242.1881509619078 and parameters: {'x': -7.82228553313594, 'y': -9, 'z': 'a'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,527] Trial 3 finished with value: 111.90701527249429 and parameters: {'x': -3.450654325268512, 'y': -10, 'z': 'b'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,527] Trial 4 finished with value: 110.13737702020386 and parameters: {'x': 3.022809458137223, 'y': -1, 'z': 'a'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,528] Trial 5 finished with value: 169.25359210910415 and parameters: {'x': 7.297505882772835, 'y': -4, 'z': 'c'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,528] Trial 6 finished with value: 151.12942070556448 and parameters: {'x': 5.111694504326769, 'y': -5, 'z': 'c'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,528] Trial 7 finished with value: 178.92779339889967 and parameters: {'x': 8.36228398219647, 'y': 3, 'z': 'c'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,529] Trial 8 finished with value: 198.43546691903126 and parameters: {'x': -7.031035977651605, 'y': 7, 'z': 'a'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,529] Trial 9 finished with value: 107.55371533740825 and parameters: {'x': 1.8851300584862187, 'y': 2, 'z': 'c'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,529] Trial 10 finished with value: 117.38174651486683 and parameters: {'x': 4.047437030376981, 'y': -1, 'z': 'a'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,530] Trial 11 finished with value: 109.05698118751415 and parameters: {'x': -3.009481880243534, 'y': 0, 'z': 'c'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,530] Trial 12 finished with value: 216.10644771835433 and parameters: {'x': -4.013283907021075, 'y': -10, 'z': 'c'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,530] Trial 13 finished with value: 69.17417709957539 and parameters: {'x': -6.6463657061265735, 'y': 5, 'z': 'b'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,530] Trial 14 finished with value: 103.36106000836558 and parameters: {'x': 8.207378388277561, 'y': 6, 'z': 'b'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,531] Trial 15 finished with value: 125.02838333791968 and parameters: {'x': 0.16847355258224006, 'y': 5, 'z': 'a'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,531] Trial 16 finished with value: 169.0522415480677 and parameters: {'x': 7.7493381361292855, 'y': 3, 'z': 'a'}. Best is trial 0 with value: 29.838126087406195.
[I 2025-04-25 10:32:07,531] Trial 17 finished with value: 17.30141839614715 and parameters: {'x': -4.037501504166549, 'y': 1, 'z': 'b'}. Best is trial 17 with value: 17.30141839614715.
[I 2025-04-25 10:32:07,532] Trial 18 finished with value: 59.74584619700723 and parameters: {'x': 5.89456072977514, 'y': 5, 'z': 'b'}. Best is trial 17 with value: 17.30141839614715.
[I 2025-04-25 10:32:07,532] Trial 19 finished with value: 202.4162330648884 and parameters: {'x': 6.198083015327271, 'y': 8, 'z': 'a'}. Best is trial 17 with value: 17.30141839614715.
[I 2025-04-25 10:32:07,532] Trial 20 finished with value: 33.19644496749249 and parameters: {'x': -4.1468596512894536, 'y': -4, 'z': 'b'}. Best is trial 17 with value: 17.30141839614715.
[I 2025-04-25 10:32:07,533] Trial 21 finished with value: 75.25206603682524 and parameters: {'x': 8.139537212693682, 'y': -3, 'z': 'b'}. Best is trial 17 with value: 17.30141839614715.
[I 2025-04-25 10:32:07,533] Trial 22 finished with value: 4.003059501027343 and parameters: {'x': -0.055312756461256996, 'y': -2, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,533] Trial 23 finished with value: 103.35715936398856 and parameters: {'x': 8.207140754488652, 'y': 6, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,534] Trial 24 finished with value: 181.14730519757865 and parameters: {'x': 8.493956981147164, 'y': -3, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,534] Trial 25 finished with value: 131.62178731547522 and parameters: {'x': -4.7562366757211745, 'y': 3, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,534] Trial 26 finished with value: 113.71838222414918 and parameters: {'x': 3.5662840919014265, 'y': -1, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,535] Trial 27 finished with value: 165.7048389343471 and parameters: {'x': -1.3056948090373481, 'y': 8, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,535] Trial 28 finished with value: 225.7820411038987 and parameters: {'x': 7.860155284973619, 'y': -8, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,535] Trial 29 finished with value: 234.79583307433919 and parameters: {'x': 8.414025973001223, 'y': 8, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,536] Trial 30 finished with value: 24.151981382797448 and parameters: {'x': 4.914466541019223, 'y': 0, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,536] Trial 31 finished with value: 164.95387702836283 and parameters: {'x': 5.380880692634136, 'y': -6, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,536] Trial 32 finished with value: 104.8948473249029 and parameters: {'x': 1.9735367553969958, 'y': -1, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,536] Trial 33 finished with value: 47.93199556581315 and parameters: {'x': -3.4542720746653917, 'y': 6, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,537] Trial 34 finished with value: 113.76699817714913 and parameters: {'x': -3.710390569353736, 'y': 0, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,537] Trial 35 finished with value: 174.123828985052 and parameters: {'x': 3.181796502771981, 'y': -8, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,537] Trial 36 finished with value: 161.90265463064748 and parameters: {'x': 3.592026535348463, 'y': -7, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,538] Trial 37 finished with value: 72.80996391267216 and parameters: {'x': 6.067121550840412, 'y': 6, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,538] Trial 38 finished with value: 216.57061099994525 and parameters: {'x': 8.976113357124298, 'y': 6, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,538] Trial 39 finished with value: 111.37148818132526 and parameters: {'x': -2.7150484675830855, 'y': 2, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,539] Trial 40 finished with value: 47.71642940459719 and parameters: {'x': 3.4229270229727646, 'y': -6, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,539] Trial 41 finished with value: 205.73638171552633 and parameters: {'x': 8.985342604237545, 'y': 5, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,539] Trial 42 finished with value: 129.0030215875093 and parameters: {'x': 2.0007552542750666, 'y': 5, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,540] Trial 43 finished with value: 229.61820647195972 and parameters: {'x': 8.978764195141764, 'y': -7, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,540] Trial 44 finished with value: 138.00504281963447 and parameters: {'x': 1.4159953459084775, 'y': 6, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,540] Trial 45 finished with value: 25.748826756029636 and parameters: {'x': 0.8653477659470994, 'y': -5, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,541] Trial 46 finished with value: 181.4002272858088 and parameters: {'x': -0.6326351917248871, 'y': -9, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,541] Trial 47 finished with value: 60.44054765075851 and parameters: {'x': 5.953196422994836, 'y': -5, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,541] Trial 48 finished with value: 130.05029437014002 and parameters: {'x': -2.247286000966504, 'y': 5, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,542] Trial 49 finished with value: 149.28509190088607 and parameters: {'x': -0.5339399787298795, 'y': 7, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,542] Trial 50 finished with value: 183.6530449872614 and parameters: {'x': -1.6288170515013043, 'y': 9, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,542] Trial 51 finished with value: 128.40532247537536 and parameters: {'x': -5.235009309960715, 'y': 1, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,542] Trial 52 finished with value: 204.56836639448545 and parameters: {'x': -4.854726191505085, 'y': -9, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,543] Trial 53 finished with value: 70.11656672854052 and parameters: {'x': 2.4731693691578265, 'y': 8, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,543] Trial 54 finished with value: 194.25644407081484 and parameters: {'x': 9.233441615714849, 'y': -3, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,543] Trial 55 finished with value: 64.60268322633215 and parameters: {'x': -0.7763267522970896, 'y': 8, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,544] Trial 56 finished with value: 71.43701238068178 and parameters: {'x': -7.445603560537036, 'y': 4, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,544] Trial 57 finished with value: 242.49813427279847 and parameters: {'x': -8.859917283631855, 'y': 8, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,544] Trial 58 finished with value: 124.40060142669066 and parameters: {'x': 2.8983791033421866, 'y': -4, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,545] Trial 59 finished with value: 49.65327545664559 and parameters: {'x': 0.8082545741569209, 'y': -7, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,545] Trial 60 finished with value: 181.71209211570678 and parameters: {'x': 5.719448584934284, 'y': 7, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,545] Trial 61 finished with value: 196.09031455997462 and parameters: {'x': 9.332219165877675, 'y': -3, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,546] Trial 62 finished with value: 169.29210098802 and parameters: {'x': 5.769930761111436, 'y': -6, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,546] Trial 63 finished with value: 134.05115784907713 and parameters: {'x': 5.0051131704565, 'y': 3, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,546] Trial 64 finished with value: 43.28936001768781 and parameters: {'x': -4.276606133102254, 'y': 5, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,547] Trial 65 finished with value: 121.25617104406922 and parameters: {'x': 4.610441523766376, 'y': -10, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,547] Trial 66 finished with value: 30.21246187794602 and parameters: {'x': 2.283081662566195, 'y': 5, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,547] Trial 67 finished with value: 27.820885743832854 and parameters: {'x': 1.6795492680576096, 'y': -5, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,547] Trial 68 finished with value: 32.82836407214058 and parameters: {'x': -2.7979213841958783, 'y': 5, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,548] Trial 69 finished with value: 110.49091308780467 and parameters: {'x': -5.430553663099618, 'y': -9, 'z': 'b'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,548] Trial 70 finished with value: 113.07399448566082 and parameters: {'x': 3.012307169871761, 'y': 2, 'z': 'c'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,548] Trial 71 finished with value: 133.5581262469149 and parameters: {'x': -4.955615627438723, 'y': -3, 'z': 'a'}. Best is trial 22 with value: 4.003059501027343.
[I 2025-04-25 10:32:07,549] Trial 72 finished with value: 3.462994806348068 and parameters: {'x': -1.5693931331403448, 'y': -1, 'z': 'b'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,549] Trial 73 finished with value: 180.4861128134426 and parameters: {'x': 5.6112487748666595, 'y': -7, 'z': 'a'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,549] Trial 74 finished with value: 63.50052923083173 and parameters: {'x': -6.892062770378091, 'y': -4, 'z': 'b'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,550] Trial 75 finished with value: 156.98063700884683 and parameters: {'x': 6.926805685801128, 'y': -3, 'z': 'a'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,550] Trial 76 finished with value: 55.436016729261205 and parameters: {'x': 7.1718907360096615, 'y': -2, 'z': 'b'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,550] Trial 77 finished with value: 143.69449848481995 and parameters: {'x': 5.262556269040735, 'y': -4, 'z': 'a'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,551] Trial 78 finished with value: 105.07906173918465 and parameters: {'x': 1.0387789655093354, 'y': -2, 'z': 'a'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,551] Trial 79 finished with value: 154.33488184842852 and parameters: {'x': -7.371219834493374, 'y': -10, 'z': 'b'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,551] Trial 80 finished with value: 170.37959400907627 and parameters: {'x': -5.8634114651008655, 'y': -6, 'z': 'a'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,552] Trial 81 finished with value: 47.29527884908472 and parameters: {'x': 6.188317933742958, 'y': 3, 'z': 'b'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,552] Trial 82 finished with value: 202.58923583598852 and parameters: {'x': 6.212023489652026, 'y': 8, 'z': 'a'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,552] Trial 83 finished with value: 169.4102880234695 and parameters: {'x': -2.3260025845792764, 'y': 8, 'z': 'a'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,553] Trial 84 finished with value: 36.69530807984225 and parameters: {'x': -6.057665233391678, 'y': 0, 'z': 'b'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,553] Trial 85 finished with value: 127.93627526017326 and parameters: {'x': -4.35158307517773, 'y': 3, 'z': 'c'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,553] Trial 86 finished with value: 178.67228048780171 and parameters: {'x': -6.532402351953048, 'y': -6, 'z': 'c'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,554] Trial 87 finished with value: 131.77380694124432 and parameters: {'x': -5.547414437487461, 'y': -1, 'z': 'c'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,554] Trial 88 finished with value: 25.09503012521746 and parameters: {'x': -0.30826956583071663, 'y': -5, 'z': 'b'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,554] Trial 89 finished with value: 144.68313917809428 and parameters: {'x': -6.378333573755317, 'y': 2, 'z': 'a'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,555] Trial 90 finished with value: 203.929520831923 and parameters: {'x': 7.411445259321763, 'y': 7, 'z': 'a'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,555] Trial 91 finished with value: 141.2699285424506 and parameters: {'x': 8.790331537686768, 'y': 8, 'z': 'b'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,555] Trial 92 finished with value: 148.04342241046692 and parameters: {'x': 4.800356487852431, 'y': 5, 'z': 'a'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,556] Trial 93 finished with value: 164.0000373168675 and parameters: {'x': 0.006108753349769458, 'y': 8, 'z': 'c'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,556] Trial 94 finished with value: 257.6522585002778 and parameters: {'x': -8.755127554769137, 'y': -9, 'z': 'c'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,556] Trial 95 finished with value: 125.319250938992 and parameters: {'x': 3.0527448204840173, 'y': -4, 'z': 'c'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,557] Trial 96 finished with value: 175.3106331154508 and parameters: {'x': -8.44456234007724, 'y': 2, 'z': 'c'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,557] Trial 97 finished with value: 237.54007740323664 and parameters: {'x': -6.126995789392762, 'y': -10, 'z': 'a'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,557] Trial 98 finished with value: 120.67661490338337 and parameters: {'x': 3.417106217749657, 'y': 3, 'z': 'c'}. Best is trial 72 with value: 3.462994806348068.
[I 2025-04-25 10:32:07,557] Trial 99 finished with value: 160.78271958744736 and parameters: {'x': 4.978224541686259, 'y': -6, 'z': 'c'}. Best is trial 72 with value: 3.462994806348068.
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.399 seconds)