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 2024-10-15 04:18:01,318] A new study created in memory with name: no-name-f5afb52c-27fa-4de8-8d50-8d2ab2960830
[I 2024-10-15 04:18:01,320] Trial 0 finished with value: 99.98100482386099 and parameters: {'x': 7.140098376343353, 'y': -7, 'z': 'b'}. Best is trial 0 with value: 99.98100482386099.
[I 2024-10-15 04:18:01,320] Trial 1 finished with value: 101.0105908297807 and parameters: {'x': 0.10291175725203416, 'y': 1, 'z': 'a'}. Best is trial 0 with value: 99.98100482386099.
[I 2024-10-15 04:18:01,321] Trial 2 finished with value: 40.497621232120835 and parameters: {'x': -3.936701821591373, 'y': 5, 'z': 'b'}. Best is trial 2 with value: 40.497621232120835.
[I 2024-10-15 04:18:01,321] Trial 3 finished with value: 181.66807179252132 and parameters: {'x': -0.8173565883513234, 'y': -9, 'z': 'c'}. Best is trial 2 with value: 40.497621232120835.
[I 2024-10-15 04:18:01,322] Trial 4 finished with value: 184.91154812607596 and parameters: {'x': 9.160324673616977, 'y': 1, 'z': 'c'}. Best is trial 2 with value: 40.497621232120835.
[I 2024-10-15 04:18:01,322] Trial 5 finished with value: 60.78162442581604 and parameters: {'x': 7.535358281184514, 'y': -2, 'z': 'b'}. Best is trial 2 with value: 40.497621232120835.
[I 2024-10-15 04:18:01,322] Trial 6 finished with value: 119.47234951303423 and parameters: {'x': 1.8634241366458237, 'y': 4, 'z': 'c'}. Best is trial 2 with value: 40.497621232120835.
[I 2024-10-15 04:18:01,323] Trial 7 finished with value: 137.70301834503124 and parameters: {'x': 6.058301605650815, 'y': -1, 'z': 'a'}. Best is trial 2 with value: 40.497621232120835.
[I 2024-10-15 04:18:01,323] Trial 8 finished with value: 106.73067656745557 and parameters: {'x': 2.3938831566005003, 'y': -1, 'z': 'a'}. Best is trial 2 with value: 40.497621232120835.
[I 2024-10-15 04:18:01,324] Trial 9 finished with value: 62.29033493908001 and parameters: {'x': 7.8288144018797645, 'y': -1, 'z': 'b'}. Best is trial 2 with value: 40.497621232120835.
[I 2024-10-15 04:18:01,324] Trial 10 finished with value: 75.39581861442232 and parameters: {'x': -7.7068682754035915, 'y': 4, 'z': 'b'}. Best is trial 2 with value: 40.497621232120835.
[I 2024-10-15 04:18:01,325] Trial 11 finished with value: 59.31201152575079 and parameters: {'x': -4.8282513942162115, 'y': -6, 'z': 'b'}. Best is trial 2 with value: 40.497621232120835.
[I 2024-10-15 04:18:01,325] Trial 12 finished with value: 28.719387163944152 and parameters: {'x': 5.264920432821768, 'y': -1, 'z': 'b'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,325] Trial 13 finished with value: 100.9480679857729 and parameters: {'x': 0.9736878276803544, 'y': 0, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,326] Trial 14 finished with value: 285.2831115614416 and parameters: {'x': -9.234885573814198, 'y': -10, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,326] Trial 15 finished with value: 199.11979274650315 and parameters: {'x': 5.9261954698189925, 'y': -8, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,326] Trial 16 finished with value: 254.4408589931213 and parameters: {'x': 8.56976423206154, 'y': 9, 'z': 'c'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,327] Trial 17 finished with value: 116.2997382590177 and parameters: {'x': -0.547483569632643, 'y': -4, 'z': 'c'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,327] Trial 18 finished with value: 225.3376406294167 and parameters: {'x': 6.658651562397353, 'y': -9, 'z': 'c'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,328] Trial 19 finished with value: 104.00380579321553 and parameters: {'x': -0.061691111317012215, 'y': 2, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,328] Trial 20 finished with value: 113.3516086063848 and parameters: {'x': 3.6539853046208055, 'y': 0, 'z': 'c'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,328] Trial 21 finished with value: 170.7981686785598 and parameters: {'x': 5.898997260429928, 'y': 6, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,329] Trial 22 finished with value: 52.99282481449542 and parameters: {'x': 1.9982053984751964, 'y': 7, 'z': 'b'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,329] Trial 23 finished with value: 147.4423469759911 and parameters: {'x': -3.3826538362639287, 'y': -6, 'z': 'c'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,329] Trial 24 finished with value: 151.1709868186366 and parameters: {'x': -6.493919218671927, 'y': -3, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,330] Trial 25 finished with value: 138.1901574861514 and parameters: {'x': -1.479918067377854, 'y': -6, 'z': 'c'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,330] Trial 26 finished with value: 149.38934638512654 and parameters: {'x': 0.6239762696822115, 'y': 7, 'z': 'c'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,330] Trial 27 finished with value: 151.27103577506404 and parameters: {'x': -3.9078172647993714, 'y': -6, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,331] Trial 28 finished with value: 172.69342122289248 and parameters: {'x': -9.57566818675817, 'y': 9, 'z': 'b'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,331] Trial 29 finished with value: 140.8920262584118 and parameters: {'x': -6.07388065888784, 'y': 2, 'z': 'c'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,332] Trial 30 finished with value: 136.88078255686105 and parameters: {'x': -0.9385001634848287, 'y': 6, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,332] Trial 31 finished with value: 178.23693998894026 and parameters: {'x': 8.845164780202811, 'y': 0, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,332] Trial 32 finished with value: 155.8168302368124 and parameters: {'x': -5.55129086220605, 'y': 5, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,333] Trial 33 finished with value: 204.1092241927849 and parameters: {'x': -6.333184364345071, 'y': -8, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,333] Trial 34 finished with value: 162.20118326738708 and parameters: {'x': 6.099277274184793, 'y': -5, 'z': 'c'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,333] Trial 35 finished with value: 233.4950976623105 and parameters: {'x': -9.873960586426833, 'y': 6, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,334] Trial 36 finished with value: 115.68330397509808 and parameters: {'x': 5.889253261246122, 'y': 9, 'z': 'b'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,334] Trial 37 finished with value: 132.52463599365205 and parameters: {'x': -2.743106996391509, 'y': 5, 'z': 'c'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,335] Trial 38 finished with value: 68.46247515825151 and parameters: {'x': 7.243098450128336, 'y': -4, 'z': 'b'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,335] Trial 39 finished with value: 178.11565221331165 and parameters: {'x': 7.881348375329672, 'y': 4, 'z': 'a'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,335] Trial 40 finished with value: 149.30620496064265 and parameters: {'x': -0.5533578956178751, 'y': -7, 'z': 'c'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,336] Trial 41 finished with value: 104.56190151222981 and parameters: {'x': -2.1358608363444027, 'y': -10, 'z': 'b'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,336] Trial 42 finished with value: 59.79018234133149 and parameters: {'x': 4.877518051358855, 'y': -6, 'z': 'b'}. Best is trial 12 with value: 28.719387163944152.
[I 2024-10-15 04:18:01,336] Trial 43 finished with value: 10.35979744175943 and parameters: {'x': -1.1661035296059392, 'y': 3, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,337] Trial 44 finished with value: 228.70761629358924 and parameters: {'x': -9.628479438290828, 'y': -6, 'z': 'c'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,337] Trial 45 finished with value: 197.87248454910505 and parameters: {'x': 9.893052337327699, 'y': 0, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,338] Trial 46 finished with value: 161.59945006656258 and parameters: {'x': -5.0595899109080555, 'y': 6, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,338] Trial 47 finished with value: 129.83639632168172 and parameters: {'x': 9.686918824976377, 'y': 6, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,338] Trial 48 finished with value: 172.63580319805067 and parameters: {'x': 8.522664090415077, 'y': -10, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,339] Trial 49 finished with value: 219.29343404402985 and parameters: {'x': 6.188168876495684, 'y': -9, 'z': 'c'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,339] Trial 50 finished with value: 167.18317301782668 and parameters: {'x': -7.627789523697325, 'y': -3, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,339] Trial 51 finished with value: 143.1095925513232 and parameters: {'x': 6.253766269323087, 'y': -2, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,340] Trial 52 finished with value: 104.42921581099527 and parameters: {'x': -0.6551456410564516, 'y': -2, 'z': 'c'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,340] Trial 53 finished with value: 69.3330233676899 and parameters: {'x': 8.266379096538575, 'y': -1, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,341] Trial 54 finished with value: 219.96957050275546 and parameters: {'x': 9.163491174369923, 'y': 6, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,341] Trial 55 finished with value: 16.864568743445542 and parameters: {'x': -3.5867211689014162, 'y': -2, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,341] Trial 56 finished with value: 168.81418445651337 and parameters: {'x': 2.194124986529566, 'y': 8, 'z': 'c'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,342] Trial 57 finished with value: 162.29363312515957 and parameters: {'x': -7.829025043079092, 'y': 1, 'z': 'c'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,342] Trial 58 finished with value: 137.74409178056632 and parameters: {'x': -1.3206406704953206, 'y': -6, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,342] Trial 59 finished with value: 125.63276883408065 and parameters: {'x': 5.062881475413052, 'y': 0, 'z': 'c'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,343] Trial 60 finished with value: 100.7251787661789 and parameters: {'x': -0.8515742869408989, 'y': 0, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,343] Trial 61 finished with value: 100.35315559617493 and parameters: {'x': -9.184397399730422, 'y': 4, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,343] Trial 62 finished with value: 181.35675924803004 and parameters: {'x': -9.019798182222818, 'y': 0, 'z': 'c'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,344] Trial 63 finished with value: 163.54286667245194 and parameters: {'x': -7.385314256851359, 'y': -3, 'z': 'c'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,344] Trial 64 finished with value: 151.3597779506394 and parameters: {'x': 5.134177436614301, 'y': -5, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,344] Trial 65 finished with value: 190.213663222858 and parameters: {'x': -7.362992816977211, 'y': -6, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,345] Trial 66 finished with value: 111.77241320307853 and parameters: {'x': -1.6650565164818047, 'y': -3, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,345] Trial 67 finished with value: 118.42027315345655 and parameters: {'x': 3.0692463494246525, 'y': 3, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,346] Trial 68 finished with value: 146.6077404000485 and parameters: {'x': 4.648412675317083, 'y': -5, 'z': 'c'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,346] Trial 69 finished with value: 67.19875729497448 and parameters: {'x': -7.628811001392974, 'y': -3, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,346] Trial 70 finished with value: 83.60309503944073 and parameters: {'x': 6.899499622395869, 'y': 6, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,347] Trial 71 finished with value: 36.45354726338241 and parameters: {'x': -0.6734591772204261, 'y': 6, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,347] Trial 72 finished with value: 124.13769710078572 and parameters: {'x': 3.8907193551817265, 'y': 3, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,347] Trial 73 finished with value: 98.43518720356116 and parameters: {'x': -5.8681502369623395, 'y': -8, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,348] Trial 74 finished with value: 125.12007673089369 and parameters: {'x': 0.34652089532045594, 'y': 5, 'z': 'c'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,348] Trial 75 finished with value: 159.35199423268952 and parameters: {'x': -7.6388477032003665, 'y': 1, 'z': 'a'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,348] Trial 76 finished with value: 29.457842153300962 and parameters: {'x': 4.523034617742933, 'y': 3, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,349] Trial 77 finished with value: 62.18847998870027 and parameters: {'x': -7.885967283009756, 'y': 0, 'z': 'b'}. Best is trial 43 with value: 10.35979744175943.
[I 2024-10-15 04:18:01,349] Trial 78 finished with value: 6.056549243756672 and parameters: {'x': -1.4340673776906971, 'y': -2, 'z': 'b'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,350] Trial 79 finished with value: 111.58571517277203 and parameters: {'x': -3.4037795423282073, 'y': -10, 'z': 'b'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,350] Trial 80 finished with value: 118.71084415251931 and parameters: {'x': 3.1162227379504355, 'y': 3, 'z': 'c'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,350] Trial 81 finished with value: 128.16516261965967 and parameters: {'x': -3.4878593176416484, 'y': -4, 'z': 'a'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,351] Trial 82 finished with value: 165.4909785635969 and parameters: {'x': -1.2210563310498461, 'y': 8, 'z': 'a'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,351] Trial 83 finished with value: 131.27183892773868 and parameters: {'x': -4.719304919979073, 'y': 3, 'z': 'a'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,351] Trial 84 finished with value: 232.6201345760096 and parameters: {'x': -8.28372709449132, 'y': 8, 'z': 'c'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,352] Trial 85 finished with value: 41.84029975180712 and parameters: {'x': 5.730645666223582, 'y': 3, 'z': 'b'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,352] Trial 86 finished with value: 111.9399004130953 and parameters: {'x': 1.7146137795711596, 'y': -3, 'z': 'a'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,353] Trial 87 finished with value: 223.72344117354956 and parameters: {'x': -8.644272159849525, 'y': -7, 'z': 'c'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,353] Trial 88 finished with value: 179.89197094684286 and parameters: {'x': -7.9932453325819335, 'y': 4, 'z': 'c'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,353] Trial 89 finished with value: 100.0716155911432 and parameters: {'x': 0.2676108950382954, 'y': 0, 'z': 'c'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,354] Trial 90 finished with value: 146.06634111289867 and parameters: {'x': -6.485857006818656, 'y': 2, 'z': 'a'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,354] Trial 91 finished with value: 192.5563128328836 and parameters: {'x': -7.5203931302082605, 'y': 6, 'z': 'a'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,354] Trial 92 finished with value: 102.18827386446978 and parameters: {'x': -9.908999639947, 'y': 2, 'z': 'b'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,355] Trial 93 finished with value: 127.81271497033183 and parameters: {'x': 7.9882861096941085, 'y': 8, 'z': 'b'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,355] Trial 94 finished with value: 55.02525705475714 and parameters: {'x': 4.361795164236526, 'y': -6, 'z': 'b'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,356] Trial 95 finished with value: 35.03633891621629 and parameters: {'x': -5.83406709904988, 'y': -1, 'z': 'b'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,356] Trial 96 finished with value: 182.5681795917369 and parameters: {'x': -1.252269775941631, 'y': -9, 'z': 'c'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,356] Trial 97 finished with value: 149.7735740687305 and parameters: {'x': -0.8795305956761812, 'y': -7, 'z': 'a'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,357] Trial 98 finished with value: 101.2920469907077 and parameters: {'x': -0.5404137217981226, 'y': -1, 'z': 'c'}. Best is trial 78 with value: 6.056549243756672.
[I 2024-10-15 04:18:01,357] Trial 99 finished with value: 132.05017747871534 and parameters: {'x': -2.6552170304356153, 'y': -5, 'z': 'a'}. Best is trial 78 with value: 6.056549243756672.
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.4340673776906971, 'y': -2, 'z': 'b'}, Best value: 6.056549243756672
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 2024-10-15 04:18:01,358] A new study created in memory with name: no-name-4192508b-0308-448f-bbd0-af411a67b601
[I 2024-10-15 04:18:01,359] Trial 0 finished with value: 116.23274836250314 and parameters: {'x': 0.4824400092271972, 'y': -4, 'z': 'c'}. Best is trial 0 with value: 116.23274836250314.
[I 2024-10-15 04:18:01,359] Trial 1 finished with value: 161.62544614944392 and parameters: {'x': 5.062158250138367, 'y': -6, 'z': 'c'}. Best is trial 0 with value: 116.23274836250314.
[I 2024-10-15 04:18:01,360] Trial 2 finished with value: 164.40778170340917 and parameters: {'x': 0.6385778757592142, 'y': -8, 'z': 'c'}. Best is trial 0 with value: 116.23274836250314.
[I 2024-10-15 04:18:01,360] Trial 3 finished with value: 258.96344729128884 and parameters: {'x': 9.744919050012104, 'y': 8, 'z': 'a'}. Best is trial 0 with value: 116.23274836250314.
[I 2024-10-15 04:18:01,360] Trial 4 finished with value: 128.02527178460969 and parameters: {'x': -1.7393308439194861, 'y': 5, 'z': 'a'}. Best is trial 0 with value: 116.23274836250314.
[I 2024-10-15 04:18:01,361] Trial 5 finished with value: 52.79757229194922 and parameters: {'x': -6.066100254030527, 'y': 4, 'z': 'b'}. Best is trial 5 with value: 52.79757229194922.
[I 2024-10-15 04:18:01,361] Trial 6 finished with value: 15.039908470894439 and parameters: {'x': -3.322635771626863, 'y': -2, 'z': 'b'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,361] Trial 7 finished with value: 179.67061248325388 and parameters: {'x': 7.393957836183127, 'y': 5, 'z': 'a'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,361] Trial 8 finished with value: 149.29609118562843 and parameters: {'x': 6.347920225209862, 'y': -3, 'z': 'c'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,362] Trial 9 finished with value: 118.4621982192688 and parameters: {'x': -1.5691393243650502, 'y': 4, 'z': 'c'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,362] Trial 10 finished with value: 109.9882164882225 and parameters: {'x': 2.998035438119853, 'y': 1, 'z': 'a'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,362] Trial 11 finished with value: 155.04586890830853 and parameters: {'x': 2.4588348680439136, 'y': 7, 'z': 'a'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,363] Trial 12 finished with value: 50.62742626523005 and parameters: {'x': -3.824581841878933, 'y': 6, 'z': 'b'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,363] Trial 13 finished with value: 106.94425279430179 and parameters: {'x': -2.4380838366023827, 'y': 1, 'z': 'c'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,363] Trial 14 finished with value: 152.3749276173467 and parameters: {'x': -4.046594570419271, 'y': -6, 'z': 'a'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,364] Trial 15 finished with value: 210.7615351154198 and parameters: {'x': -9.734553668012715, 'y': -4, 'z': 'c'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,364] Trial 16 finished with value: 127.27526910468237 and parameters: {'x': -7.954575356653701, 'y': -8, 'z': 'b'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,364] Trial 17 finished with value: 109.56383519287519 and parameters: {'x': 0.7508896009901793, 'y': 3, 'z': 'c'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,365] Trial 18 finished with value: 248.15302938894564 and parameters: {'x': 8.194695198050116, 'y': -9, 'z': 'a'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,365] Trial 19 finished with value: 236.27637795356827 and parameters: {'x': 6.022987460850992, 'y': -10, 'z': 'c'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,365] Trial 20 finished with value: 166.38719678764585 and parameters: {'x': 8.147833870891443, 'y': 0, 'z': 'a'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,365] Trial 21 finished with value: 233.21012137233703 and parameters: {'x': 8.319262068978055, 'y': 8, 'z': 'c'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,366] Trial 22 finished with value: 121.1221056199856 and parameters: {'x': -3.4816814357413017, 'y': -3, 'z': 'c'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,366] Trial 23 finished with value: 107.55664673092927 and parameters: {'x': 8.459116190887158, 'y': 6, 'z': 'b'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,366] Trial 24 finished with value: 123.80349417737791 and parameters: {'x': 4.450111703921365, 'y': -2, 'z': 'a'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,367] Trial 25 finished with value: 106.30858069424735 and parameters: {'x': 6.504504646339132, 'y': -8, 'z': 'b'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,367] Trial 26 finished with value: 124.24071196955094 and parameters: {'x': 4.923485753970549, 'y': 0, 'z': 'a'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,367] Trial 27 finished with value: 136.088856805663 and parameters: {'x': -0.2980885869385137, 'y': 6, 'z': 'c'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,368] Trial 28 finished with value: 146.52677488195255 and parameters: {'x': -4.639695559188399, 'y': -5, 'z': 'a'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,368] Trial 29 finished with value: 211.37593864166672 and parameters: {'x': 9.293865645772307, 'y': -5, 'z': 'a'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,368] Trial 30 finished with value: 135.3591188824236 and parameters: {'x': -7.372863682615025, 'y': 9, 'z': 'b'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,369] Trial 31 finished with value: 133.99494993022194 and parameters: {'x': -5.476764549460014, 'y': -2, 'z': 'c'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,369] Trial 32 finished with value: 26.57591324605773 and parameters: {'x': 1.2553538330119238, 'y': 5, 'z': 'b'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,369] Trial 33 finished with value: 223.182530286133 and parameters: {'x': 4.814824014035505, 'y': -10, 'z': 'c'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,370] Trial 34 finished with value: 125.76805127644761 and parameters: {'x': 0.876385347006444, 'y': -5, 'z': 'a'}. Best is trial 6 with value: 15.039908470894439.
[I 2024-10-15 04:18:01,370] Trial 35 finished with value: 10.50811985490001 and parameters: {'x': -2.5511016943469755, 'y': 2, 'z': 'b'}. Best is trial 35 with value: 10.50811985490001.
[I 2024-10-15 04:18:01,370] Trial 36 finished with value: 1.5028863943573447 and parameters: {'x': 0.7091448331316705, 'y': -1, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,371] Trial 37 finished with value: 125.01792674900142 and parameters: {'x': -0.133890809996144, 'y': -5, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,371] Trial 38 finished with value: 69.22129801432682 and parameters: {'x': 2.28501597682091, 'y': 8, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,371] Trial 39 finished with value: 230.87357991871318 and parameters: {'x': -7.062122904531836, 'y': -9, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,372] Trial 40 finished with value: 105.31504649285166 and parameters: {'x': -8.325565836197061, 'y': 6, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,372] Trial 41 finished with value: 177.42505927344854 and parameters: {'x': -3.664022280697612, 'y': 8, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,372] Trial 42 finished with value: 149.49879931290158 and parameters: {'x': 0.7062572568841858, 'y': -7, 'z': 'c'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,373] Trial 43 finished with value: 165.94972407783325 and parameters: {'x': 1.3963252048979342, 'y': 8, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,373] Trial 44 finished with value: 16.654116423647334 and parameters: {'x': 0.8087746433014171, 'y': 4, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,373] Trial 45 finished with value: 164.70929372170713 and parameters: {'x': -0.8421957739784176, 'y': 8, 'z': 'c'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,374] Trial 46 finished with value: 146.8736916459845 and parameters: {'x': 8.116260939988592, 'y': -9, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,374] Trial 47 finished with value: 136.9427756815731 and parameters: {'x': -0.9709663648000912, 'y': -6, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,374] Trial 48 finished with value: 212.03480048778962 and parameters: {'x': -9.799734715174163, 'y': -4, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,374] Trial 49 finished with value: 108.46753717258255 and parameters: {'x': 5.240948117715206, 'y': -9, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,375] Trial 50 finished with value: 50.31728845419058 and parameters: {'x': 1.1477318738235773, 'y': -7, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,375] Trial 51 finished with value: 113.11425844416507 and parameters: {'x': -8.781472453077848, 'y': 6, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,375] Trial 52 finished with value: 116.02893592266884 and parameters: {'x': 0.17010562209647695, 'y': 4, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,376] Trial 53 finished with value: 161.7989658699085 and parameters: {'x': 7.266289690750604, 'y': 3, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,376] Trial 54 finished with value: 153.23770412708416 and parameters: {'x': 5.313916082051369, 'y': 5, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,376] Trial 55 finished with value: 85.87477271980843 and parameters: {'x': -7.802228702095859, 'y': -5, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,377] Trial 56 finished with value: 45.136769046459825 and parameters: {'x': 3.022708892113137, 'y': -6, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,377] Trial 57 finished with value: 116.18300657746234 and parameters: {'x': 3.8965377680015294, 'y': -1, 'z': 'c'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,377] Trial 58 finished with value: 98.26267665864238 and parameters: {'x': 9.447892709945556, 'y': -3, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,378] Trial 59 finished with value: 107.32843181647789 and parameters: {'x': 1.8243990288524827, 'y': -2, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,378] Trial 60 finished with value: 130.82718588926775 and parameters: {'x': -5.179496683005769, 'y': -2, 'z': 'c'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,378] Trial 61 finished with value: 67.5805653434113 and parameters: {'x': 1.8922381835834763, 'y': -8, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,379] Trial 62 finished with value: 152.36969917549885 and parameters: {'x': 4.045948488982386, 'y': -6, 'z': 'c'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,379] Trial 63 finished with value: 24.696614750457627 and parameters: {'x': -2.9490023313754143, 'y': 4, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,379] Trial 64 finished with value: 133.15900633266622 and parameters: {'x': -5.670891140964198, 'y': 1, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,380] Trial 65 finished with value: 158.25373393275362 and parameters: {'x': 4.717386345504639, 'y': -6, 'z': 'c'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,380] Trial 66 finished with value: 151.23933128803807 and parameters: {'x': -1.496439537047209, 'y': -7, 'z': 'c'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,380] Trial 67 finished with value: 172.67183331798464 and parameters: {'x': 8.524777611057349, 'y': 0, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,380] Trial 68 finished with value: 97.22639484498728 and parameters: {'x': 4.0281999509690785, 'y': -9, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,381] Trial 69 finished with value: 179.07917958175915 and parameters: {'x': 3.883191932129952, 'y': 8, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,381] Trial 70 finished with value: 90.04053332015025 and parameters: {'x': 9.488969033575263, 'y': 0, 'z': 'b'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,381] Trial 71 finished with value: 224.6341324670783 and parameters: {'x': -9.98168986029311, 'y': 5, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,382] Trial 72 finished with value: 149.43110273223525 and parameters: {'x': 6.358545645997616, 'y': -3, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,382] Trial 73 finished with value: 171.98721197750245 and parameters: {'x': -8.245435827019845, 'y': -2, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,382] Trial 74 finished with value: 249.93785135669725 and parameters: {'x': 9.270267059621165, 'y': -8, 'z': 'a'}. Best is trial 36 with value: 1.5028863943573447.
[I 2024-10-15 04:18:01,383] Trial 75 finished with value: 0.5719961750500487 and parameters: {'x': 0.7563042873407824, 'y': 0, 'z': 'b'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,383] Trial 76 finished with value: 49.14402653519367 and parameters: {'x': -0.379508280797225, 'y': -7, 'z': 'b'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,383] Trial 77 finished with value: 119.29018116760676 and parameters: {'x': 4.392058875699046, 'y': 0, 'z': 'a'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,384] Trial 78 finished with value: 162.68204625361693 and parameters: {'x': -9.0378120280086, 'y': -9, 'z': 'b'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,384] Trial 79 finished with value: 152.287879456299 and parameters: {'x': 1.8132510737068426, 'y': -7, 'z': 'a'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,384] Trial 80 finished with value: 145.2260309117205 and parameters: {'x': -4.497335979412758, 'y': -5, 'z': 'a'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,385] Trial 81 finished with value: 233.78360162786944 and parameters: {'x': -7.265232386363801, 'y': -9, 'z': 'c'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,385] Trial 82 finished with value: 210.34340884538108 and parameters: {'x': 9.238149644024016, 'y': 5, 'z': 'a'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,385] Trial 83 finished with value: 1.010169167111481 and parameters: {'x': -0.10084228830942443, 'y': -1, 'z': 'b'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,386] Trial 84 finished with value: 227.2822767469 and parameters: {'x': -6.803107874119005, 'y': -9, 'z': 'c'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,386] Trial 85 finished with value: 237.46118964234321 and parameters: {'x': 6.120554684204954, 'y': -10, 'z': 'c'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,386] Trial 86 finished with value: 192.6392649087009 and parameters: {'x': 5.351566584534002, 'y': 8, 'z': 'a'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,386] Trial 87 finished with value: 125.9820969792631 and parameters: {'x': -4.688506902977013, 'y': -2, 'z': 'c'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,387] Trial 88 finished with value: 156.22124382122294 and parameters: {'x': 7.4980826763395285, 'y': 0, 'z': 'a'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,387] Trial 89 finished with value: 19.358185490756583 and parameters: {'x': 4.399793800936196, 'y': 0, 'z': 'b'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,387] Trial 90 finished with value: 149.07335577849852 and parameters: {'x': 6.330351947443248, 'y': 3, 'z': 'c'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,388] Trial 91 finished with value: 113.84764289495064 and parameters: {'x': -3.5843608767743573, 'y': -1, 'z': 'c'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,388] Trial 92 finished with value: 75.7370183296007 and parameters: {'x': -7.122992231471315, 'y': -5, 'z': 'b'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,388] Trial 93 finished with value: 208.2339866674969 and parameters: {'x': 6.650863603134326, 'y': -8, 'z': 'a'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,389] Trial 94 finished with value: 68.95358964477771 and parameters: {'x': 8.243396729793957, 'y': -1, 'z': 'b'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,389] Trial 95 finished with value: 256.9247332300183 and parameters: {'x': -9.63974757086607, 'y': 8, 'z': 'c'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,389] Trial 96 finished with value: 158.63747679889644 and parameters: {'x': -7.391716769391021, 'y': 2, 'z': 'a'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,390] Trial 97 finished with value: 120.61282593926424 and parameters: {'x': 2.1477490401032036, 'y': -4, 'z': 'a'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,390] Trial 98 finished with value: 180.4077551115314 and parameters: {'x': 5.604262227227721, 'y': -7, 'z': 'a'}. Best is trial 75 with value: 0.5719961750500487.
[I 2024-10-15 04:18:01,390] Trial 99 finished with value: 235.8482526468109 and parameters: {'x': 9.319240990918246, 'y': 7, 'z': 'c'}. Best is trial 75 with value: 0.5719961750500487.
In the next recipe, we will show how to register your sampler to OptunaHub. Let’s move on to How to Register Your Algorithm with OptunaHub. See the User-Defined Sampler documentation for more information to implement a sampler.
Total running time of the script: (0 minutes 0.666 seconds)