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-02-12 03:50:37,564] A new study created in memory with name: no-name-3553a617-9269-4487-b479-b7034c9e57d2
[I 2025-02-12 03:50:37,566] Trial 0 finished with value: 136.15172215635573 and parameters: {'x': 0.38951528385384115, 'y': -6, 'z': 'a'}. Best is trial 0 with value: 136.15172215635573.
[I 2025-02-12 03:50:37,566] Trial 1 finished with value: 220.01862658937685 and parameters: {'x': 6.246489141059708, 'y': 9, 'z': 'c'}. Best is trial 0 with value: 136.15172215635573.
[I 2025-02-12 03:50:37,567] Trial 2 finished with value: 190.9646951323877 and parameters: {'x': -9.484972068086847, 'y': 1, 'z': 'c'}. Best is trial 0 with value: 136.15172215635573.
[I 2025-02-12 03:50:37,567] Trial 3 finished with value: 9.372405828444476 and parameters: {'x': -0.6102506275658186, 'y': 3, 'z': 'b'}. Best is trial 3 with value: 9.372405828444476.
[I 2025-02-12 03:50:37,568] Trial 4 finished with value: 25.010546858226576 and parameters: {'x': 3.001757295023463, 'y': -4, 'z': 'b'}. Best is trial 3 with value: 9.372405828444476.
[I 2025-02-12 03:50:37,568] Trial 5 finished with value: 126.69301017754006 and parameters: {'x': 5.068827298058206, 'y': 1, 'z': 'c'}. Best is trial 3 with value: 9.372405828444476.
[I 2025-02-12 03:50:37,568] Trial 6 finished with value: 137.9014058127703 and parameters: {'x': -5.822491375070493, 'y': 2, 'z': 'a'}. Best is trial 3 with value: 9.372405828444476.
[I 2025-02-12 03:50:37,569] Trial 7 finished with value: 2.6319877676692505 and parameters: {'x': -1.2774927661905764, 'y': 1, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,569] Trial 8 finished with value: 12.486037954349575 and parameters: {'x': 1.8670934508881913, 'y': 3, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,570] Trial 9 finished with value: 180.09791967281967 and parameters: {'x': -5.576550876018227, 'y': 7, 'z': 'a'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,570] Trial 10 finished with value: 135.36038726253437 and parameters: {'x': -5.600034576905251, 'y': -2, 'z': 'c'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,570] Trial 11 finished with value: 81.86873956172732 and parameters: {'x': 0.9320619945729565, 'y': 9, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,571] Trial 12 finished with value: 120.0707363402749 and parameters: {'x': -4.367005420225043, 'y': -1, 'z': 'c'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,571] Trial 13 finished with value: 36.35433583968938 and parameters: {'x': 0.5952611525115508, 'y': -6, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,572] Trial 14 finished with value: 57.4386478271086 and parameters: {'x': 4.630188746380497, 'y': 6, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,572] Trial 15 finished with value: 96.44716368113339 and parameters: {'x': -5.69624118881332, 'y': 8, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,572] Trial 16 finished with value: 119.11270583400193 and parameters: {'x': -3.1800480867436454, 'y': -3, 'z': 'a'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,573] Trial 17 finished with value: 126.40262418039127 and parameters: {'x': -1.184324356074498, 'y': 5, 'z': 'a'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,573] Trial 18 finished with value: 146.26159252356257 and parameters: {'x': 6.801587500250406, 'y': 0, 'z': 'c'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,574] Trial 19 finished with value: 127.28276121834921 and parameters: {'x': 5.126671553586128, 'y': -1, 'z': 'c'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,574] Trial 20 finished with value: 51.318548652846076 and parameters: {'x': -1.5226781185943654, 'y': -7, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,574] Trial 21 finished with value: 201.0937209520967 and parameters: {'x': -1.0458111455213697, 'y': -10, 'z': 'a'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,575] Trial 22 finished with value: 193.19558060346677 and parameters: {'x': -9.17581498306645, 'y': 3, 'z': 'c'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,575] Trial 23 finished with value: 130.1545750057796 and parameters: {'x': -5.39949766235523, 'y': 1, 'z': 'c'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,575] Trial 24 finished with value: 134.71120357415666 and parameters: {'x': -5.070621616148918, 'y': -3, 'z': 'c'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,576] Trial 25 finished with value: 126.980184725723 and parameters: {'x': 1.4071903658435865, 'y': 5, 'z': 'a'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,576] Trial 26 finished with value: 136.28902524277228 and parameters: {'x': 0.5376106795556534, 'y': 6, 'z': 'a'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,577] Trial 27 finished with value: 93.32514469260192 and parameters: {'x': -7.571337047880111, 'y': -6, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,577] Trial 28 finished with value: 54.63696120538354 and parameters: {'x': 7.391681892870089, 'y': 0, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,577] Trial 29 finished with value: 66.05937740969438 and parameters: {'x': -7.553765776729802, 'y': -3, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,578] Trial 30 finished with value: 145.68978598942445 and parameters: {'x': 6.057209422615703, 'y': -3, 'z': 'c'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,578] Trial 31 finished with value: 163.9148169814584 and parameters: {'x': 9.99573994166807, 'y': -8, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,578] Trial 32 finished with value: 130.0667135560393 and parameters: {'x': 9.003705545831632, 'y': -7, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,579] Trial 33 finished with value: 15.77651340055699 and parameters: {'x': -2.603173716938036, 'y': 3, 'z': 'b'}. Best is trial 7 with value: 2.6319877676692505.
[I 2025-02-12 03:50:37,579] Trial 34 finished with value: 1.0058088767944626 and parameters: {'x': -0.07621598778775152, 'y': 1, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,580] Trial 35 finished with value: 102.51554456733555 and parameters: {'x': -1.2310745579921427, 'y': 1, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,580] Trial 36 finished with value: 38.06628053117491 and parameters: {'x': 5.391315287680262, 'y': 3, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,580] Trial 37 finished with value: 48.416882228940764 and parameters: {'x': -3.5237596724153537, 'y': -6, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,581] Trial 38 finished with value: 96.68511971508975 and parameters: {'x': -9.781877105908137, 'y': 1, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,581] Trial 39 finished with value: 121.17411722065518 and parameters: {'x': 2.2746685957860286, 'y': -4, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,581] Trial 40 finished with value: 222.57600659247845 and parameters: {'x': 9.878056822699413, 'y': -5, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,582] Trial 41 finished with value: 133.56236639815268 and parameters: {'x': 2.926152148838586, 'y': 5, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,582] Trial 42 finished with value: 224.19900304144403 and parameters: {'x': -9.391432427560986, 'y': -6, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,582] Trial 43 finished with value: 106.09235070141199 and parameters: {'x': -1.4464960080871254, 'y': 2, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,583] Trial 44 finished with value: 186.2283946721351 and parameters: {'x': 6.101507573717754, 'y': 7, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,583] Trial 45 finished with value: 182.45236629343287 and parameters: {'x': 1.2051416072117256, 'y': -9, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,584] Trial 46 finished with value: 170.04798799152007 and parameters: {'x': -8.309511898512454, 'y': -1, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,584] Trial 47 finished with value: 215.73111712223758 and parameters: {'x': 7.192434714492553, 'y': -8, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,584] Trial 48 finished with value: 213.5618783658814 and parameters: {'x': 5.706301636426293, 'y': -9, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,585] Trial 49 finished with value: 199.40826547617823 and parameters: {'x': 7.0998778493843275, 'y': 7, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,585] Trial 50 finished with value: 103.01057706439802 and parameters: {'x': -1.7351014565142933, 'y': 0, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,585] Trial 51 finished with value: 203.75033796580112 and parameters: {'x': 1.9365789335323065, 'y': -10, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,586] Trial 52 finished with value: 240.0106279151586 and parameters: {'x': -6.325395475000644, 'y': -10, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,586] Trial 53 finished with value: 25.33577117753941 and parameters: {'x': 0.5794576581074828, 'y': -5, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,587] Trial 54 finished with value: 41.75173735973844 and parameters: {'x': -2.398277998843845, 'y': -6, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,587] Trial 55 finished with value: 108.80505251826358 and parameters: {'x': 9.633537902466756, 'y': 4, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,587] Trial 56 finished with value: 34.80388759257441 and parameters: {'x': 5.550125006932223, 'y': -2, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,588] Trial 57 finished with value: 100.15737890712553 and parameters: {'x': -0.3967101046425885, 'y': 0, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,588] Trial 58 finished with value: 116.39141652538403 and parameters: {'x': -4.04863143857082, 'y': 0, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,588] Trial 59 finished with value: 110.78278669928363 and parameters: {'x': 3.1277446665742445, 'y': 1, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,589] Trial 60 finished with value: 5.829594762573331 and parameters: {'x': 2.1976339009428596, 'y': 1, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,589] Trial 61 finished with value: 128.83751117620398 and parameters: {'x': -8.052174313575431, 'y': -8, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,590] Trial 62 finished with value: 174.32233890979762 and parameters: {'x': -7.022986466582262, 'y': 5, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,590] Trial 63 finished with value: 185.78600077531516 and parameters: {'x': 9.043561288304247, 'y': 2, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,590] Trial 64 finished with value: 181.24337371197691 and parameters: {'x': -8.49961020941413, 'y': -3, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,591] Trial 65 finished with value: 105.73915106352858 and parameters: {'x': 2.1769591322596256, 'y': -1, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,591] Trial 66 finished with value: 137.47768842816095 and parameters: {'x': -5.785990704119817, 'y': -2, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,591] Trial 67 finished with value: 70.47344785077912 and parameters: {'x': -2.5442971231322664, 'y': 8, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,592] Trial 68 finished with value: 100.81819756022203 and parameters: {'x': 4.451763421412018, 'y': -9, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,592] Trial 69 finished with value: 42.5235981970198 and parameters: {'x': -4.18611970648473, 'y': 5, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,592] Trial 70 finished with value: 178.2815164338026 and parameters: {'x': -8.32355191212277, 'y': 3, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,593] Trial 71 finished with value: 124.15034651193253 and parameters: {'x': -4.488913734071143, 'y': -2, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,593] Trial 72 finished with value: 187.835640620008 and parameters: {'x': 2.6145058079889587, 'y': 9, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,594] Trial 73 finished with value: 102.43402369747129 and parameters: {'x': -1.1975072849345363, 'y': -1, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,594] Trial 74 finished with value: 287.83038241001424 and parameters: {'x': 9.371786511120185, 'y': -10, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,594] Trial 75 finished with value: 194.01606156098688 and parameters: {'x': 9.220415476592521, 'y': 3, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,595] Trial 76 finished with value: 151.92719185469875 and parameters: {'x': -6.551884603280094, 'y': -3, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,595] Trial 77 finished with value: 153.7289725512405 and parameters: {'x': -6.687972230148724, 'y': -3, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,595] Trial 78 finished with value: 186.56998482347768 and parameters: {'x': 2.3600815289895554, 'y': 9, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,596] Trial 79 finished with value: 50.85462429888335 and parameters: {'x': 6.845043776257633, 'y': 2, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,596] Trial 80 finished with value: 180.3243221181455 and parameters: {'x': 5.596813568285572, 'y': 7, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,596] Trial 81 finished with value: 18.51648155171491 and parameters: {'x': 1.5863421925029009, 'y': 4, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,597] Trial 82 finished with value: 100.3845342225653 and parameters: {'x': -0.6201082345569269, 'y': 0, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,597] Trial 83 finished with value: 167.44711260779312 and parameters: {'x': 4.2950101987996625, 'y': -7, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,598] Trial 84 finished with value: 106.36530743947446 and parameters: {'x': -1.5379556038697828, 'y': 2, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,598] Trial 85 finished with value: 160.76867678087314 and parameters: {'x': -5.980691998495922, 'y': -5, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,598] Trial 86 finished with value: 210.43787673057577 and parameters: {'x': -7.838231734937144, 'y': 7, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,599] Trial 87 finished with value: 219.6450345438677 and parameters: {'x': -8.405060055934621, 'y': 7, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,599] Trial 88 finished with value: 130.81013198017297 and parameters: {'x': 5.550687523196832, 'y': -10, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,599] Trial 89 finished with value: 149.71379626258525 and parameters: {'x': -0.8448646415759384, 'y': 7, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,600] Trial 90 finished with value: 174.98313710647534 and parameters: {'x': -3.314081638474729, 'y': -8, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,600] Trial 91 finished with value: 138.44254527185456 and parameters: {'x': -3.6664076794397182, 'y': 5, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,601] Trial 92 finished with value: 79.00881356650046 and parameters: {'x': 3.8741210056605695, 'y': 8, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,601] Trial 93 finished with value: 51.51078733901595 and parameters: {'x': 7.177101597373131, 'y': 0, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,601] Trial 94 finished with value: 27.383458245747946 and parameters: {'x': -4.287593526180851, 'y': 3, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,602] Trial 95 finished with value: 34.87238221287007 and parameters: {'x': -3.1420347249624836, 'y': 5, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,602] Trial 96 finished with value: 175.03328106467058 and parameters: {'x': 5.1022819468028775, 'y': 7, 'z': 'a'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,602] Trial 97 finished with value: 118.25830783767847 and parameters: {'x': -7.366023882508017, 'y': -8, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,603] Trial 98 finished with value: 82.63630847959266 and parameters: {'x': 7.59185803868807, 'y': -5, 'z': 'b'}. Best is trial 34 with value: 1.0058088767944626.
[I 2025-02-12 03:50:37,603] Trial 99 finished with value: 110.61386428598895 and parameters: {'x': 2.571743433157545, 'y': 2, 'z': 'c'}. Best is trial 34 with value: 1.0058088767944626.

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.07621598778775152, 'y': 1, 'z': 'b'}, Best value: 1.0058088767944626

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-02-12 03:50:37,604] A new study created in memory with name: no-name-a0b0980d-935a-4544-8ac2-821bd7ba70cd
[I 2025-02-12 03:50:37,605] Trial 0 finished with value: 222.9093617398561 and parameters: {'x': -6.473744027983814, 'y': 9, 'z': 'c'}. Best is trial 0 with value: 222.9093617398561.
[I 2025-02-12 03:50:37,605] Trial 1 finished with value: 120.427809082074 and parameters: {'x': 3.380504264466177, 'y': 3, 'z': 'a'}. Best is trial 1 with value: 120.427809082074.
[I 2025-02-12 03:50:37,606] Trial 2 finished with value: 114.41156634862854 and parameters: {'x': -8.855030567345803, 'y': 6, 'z': 'b'}. Best is trial 2 with value: 114.41156634862854.
[I 2025-02-12 03:50:37,606] Trial 3 finished with value: 180.2043320092198 and parameters: {'x': -7.4299617771035535, 'y': -5, 'z': 'c'}. Best is trial 2 with value: 114.41156634862854.
[I 2025-02-12 03:50:37,606] Trial 4 finished with value: 118.05816539323048 and parameters: {'x': -1.4346307515282408, 'y': 4, 'z': 'c'}. Best is trial 2 with value: 114.41156634862854.
[I 2025-02-12 03:50:37,607] Trial 5 finished with value: 85.91920062014592 and parameters: {'x': 2.2179270998267526, 'y': -9, 'z': 'b'}. Best is trial 5 with value: 85.91920062014592.
[I 2025-02-12 03:50:37,607] Trial 6 finished with value: 10.257239112848191 and parameters: {'x': -1.1212667447348075, 'y': 3, 'z': 'b'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,607] Trial 7 finished with value: 200.70033670394784 and parameters: {'x': -9.576029276477168, 'y': 3, 'z': 'c'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,608] Trial 8 finished with value: 165.19661064668574 and parameters: {'x': -4.024501291674005, 'y': -7, 'z': 'a'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,608] Trial 9 finished with value: 46.14157573072571 and parameters: {'x': -5.490134400060322, 'y': 4, 'z': 'b'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,608] Trial 10 finished with value: 73.48528524192427 and parameters: {'x': -4.94826083002142, 'y': -7, 'z': 'b'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,609] Trial 11 finished with value: 48.57093483109091 and parameters: {'x': 6.290543285845104, 'y': 3, 'z': 'b'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,609] Trial 12 finished with value: 59.74468127951599 and parameters: {'x': 7.664507895456563, 'y': 1, 'z': 'b'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,609] Trial 13 finished with value: 51.93000655814309 and parameters: {'x': 5.189412930008855, 'y': 5, 'z': 'b'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,609] Trial 14 finished with value: 123.13351446177207 and parameters: {'x': 4.704626920572137, 'y': -1, 'z': 'a'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,610] Trial 15 finished with value: 134.8084890716297 and parameters: {'x': -4.336875496440924, 'y': 4, 'z': 'c'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,610] Trial 16 finished with value: 205.8539138140345 and parameters: {'x': 6.4694600867487, 'y': 8, 'z': 'a'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,610] Trial 17 finished with value: 110.64226321131983 and parameters: {'x': 1.2815081784053604, 'y': 3, 'z': 'c'}. Best is trial 6 with value: 10.257239112848191.
[I 2025-02-12 03:50:37,611] Trial 18 finished with value: 4.208547739685752 and parameters: {'x': -2.0514745281591367, 'y': 0, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,611] Trial 19 finished with value: 137.4103174637816 and parameters: {'x': 4.62712842525271, 'y': -4, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,611] Trial 20 finished with value: 133.80676110587578 and parameters: {'x': 5.72771866504246, 'y': -1, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,612] Trial 21 finished with value: 268.3714655747981 and parameters: {'x': 8.268703983986732, 'y': -10, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,612] Trial 22 finished with value: 125.11744537276581 and parameters: {'x': -0.3427030387461052, 'y': -5, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,612] Trial 23 finished with value: 34.33774567874919 and parameters: {'x': -3.055772517506692, 'y': -5, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,613] Trial 24 finished with value: 191.87584211313035 and parameters: {'x': 6.547964730596092, 'y': 7, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,613] Trial 25 finished with value: 66.79295334407483 and parameters: {'x': 4.2181694304609, 'y': -7, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,613] Trial 26 finished with value: 176.34184792210658 and parameters: {'x': 8.20620788928154, 'y': -3, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,614] Trial 27 finished with value: 233.87587960656276 and parameters: {'x': 9.212810624698783, 'y': 7, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,614] Trial 28 finished with value: 156.95698050920038 and parameters: {'x': 6.399764097933641, 'y': -4, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,614] Trial 29 finished with value: 193.78869562267968 and parameters: {'x': 5.457902126520747, 'y': -8, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,615] Trial 30 finished with value: 117.14279094266708 and parameters: {'x': 4.017809221785807, 'y': 1, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,615] Trial 31 finished with value: 181.12212869492257 and parameters: {'x': 0.3494691616188348, 'y': 9, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,615] Trial 32 finished with value: 134.21170222661738 and parameters: {'x': -5.762959502427323, 'y': 1, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,616] Trial 33 finished with value: 106.77077392250273 and parameters: {'x': 2.4022435185681594, 'y': 1, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,616] Trial 34 finished with value: 45.505266160160744 and parameters: {'x': 6.041958801594127, 'y': 3, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,616] Trial 35 finished with value: 75.7971742554575 and parameters: {'x': 8.70615726112603, 'y': 0, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,617] Trial 36 finished with value: 18.617863624577076 and parameters: {'x': -3.1012680671907544, 'y': -3, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,617] Trial 37 finished with value: 101.69606493217131 and parameters: {'x': -4.549292794728792, 'y': -9, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,617] Trial 38 finished with value: 108.15742435656868 and parameters: {'x': -2.038976301129731, 'y': -2, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,617] Trial 39 finished with value: 151.67343553711544 and parameters: {'x': -3.9589689992617316, 'y': -6, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,618] Trial 40 finished with value: 123.95241911977521 and parameters: {'x': 3.866835802018908, 'y': -3, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,618] Trial 41 finished with value: 116.77122592562642 and parameters: {'x': -3.9713002814728604, 'y': 1, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,618] Trial 42 finished with value: 198.3399417215777 and parameters: {'x': 4.164125565058974, 'y': 9, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,619] Trial 43 finished with value: 188.13149854752626 and parameters: {'x': 4.912382166273941, 'y': 8, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,619] Trial 44 finished with value: 109.24350762998534 and parameters: {'x': -2.87115092427851, 'y': -1, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,619] Trial 45 finished with value: 191.63270937266967 and parameters: {'x': 9.520121289808742, 'y': -1, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,620] Trial 46 finished with value: 135.7488869768241 and parameters: {'x': 5.63461506909071, 'y': -2, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,620] Trial 47 finished with value: 212.99804612021234 and parameters: {'x': -7.999877881581215, 'y': -7, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,620] Trial 48 finished with value: 170.80397804404936 and parameters: {'x': 2.6084436056869933, 'y': -8, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,621] Trial 49 finished with value: 117.23503573260479 and parameters: {'x': 4.15151005449882, 'y': 0, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,621] Trial 50 finished with value: 59.40684134918388 and parameters: {'x': -4.838061734742942, 'y': 6, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,621] Trial 51 finished with value: 101.43573760962097 and parameters: {'x': 8.089235910122845, 'y': -6, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,622] Trial 52 finished with value: 102.21172688002528 and parameters: {'x': -1.1007846656023546, 'y': 1, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,622] Trial 53 finished with value: 224.08567196681673 and parameters: {'x': 6.563967700013212, 'y': 9, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,622] Trial 54 finished with value: 62.64916050534621 and parameters: {'x': -7.851697937729534, 'y': 1, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,622] Trial 55 finished with value: 77.48202067895761 and parameters: {'x': -7.841047167244795, 'y': -4, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,623] Trial 56 finished with value: 132.3992544211372 and parameters: {'x': 5.692034295499033, 'y': -10, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,623] Trial 57 finished with value: 107.51311340752378 and parameters: {'x': -5.149088599696434, 'y': 9, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,623] Trial 58 finished with value: 125.09831263449811 and parameters: {'x': 0.3135484563797224, 'y': -5, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,624] Trial 59 finished with value: 141.70953554723746 and parameters: {'x': -4.087729876990098, 'y': 5, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,624] Trial 60 finished with value: 35.450404217756656 and parameters: {'x': 5.608065996201958, 'y': -2, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,624] Trial 61 finished with value: 83.71492523817383 and parameters: {'x': -7.662566491598872, 'y': 5, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,625] Trial 62 finished with value: 157.15950719549232 and parameters: {'x': -7.291056658365256, 'y': -2, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,625] Trial 63 finished with value: 9.372892611373574 and parameters: {'x': 2.893595101491149, 'y': 1, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,625] Trial 64 finished with value: 142.8410274084447 and parameters: {'x': 9.687157860200518, 'y': -7, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,626] Trial 65 finished with value: 36.198551896992626 and parameters: {'x': -5.215223091775904, 'y': -3, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,627] Trial 66 finished with value: 40.66254106237742 and parameters: {'x': -4.96613945257052, 'y': 4, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,627] Trial 67 finished with value: 42.30845083874999 and parameters: {'x': -2.511662962809698, 'y': 6, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,627] Trial 68 finished with value: 66.73269439233385 and parameters: {'x': -6.460084704733666, 'y': -5, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,628] Trial 69 finished with value: 144.83613988892978 and parameters: {'x': -2.972564530658632, 'y': -6, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,628] Trial 70 finished with value: 233.5540905281703 and parameters: {'x': -7.249420013226596, 'y': -9, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,628] Trial 71 finished with value: 244.84846430373966 and parameters: {'x': 8.99157740909456, 'y': 8, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,628] Trial 72 finished with value: 155.15194911811304 and parameters: {'x': 7.3588007934794, 'y': 1, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,629] Trial 73 finished with value: 132.06471483253554 and parameters: {'x': 5.662571397566262, 'y': 0, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,629] Trial 74 finished with value: 130.8466706034901 and parameters: {'x': -4.674042212420648, 'y': 3, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,629] Trial 75 finished with value: 199.2072952337258 and parameters: {'x': -9.96028590120413, 'y': 0, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,630] Trial 76 finished with value: 137.07258085334695 and parameters: {'x': -6.088725716711744, 'y': 0, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,630] Trial 77 finished with value: 174.23171414170326 and parameters: {'x': 6.183179937677963, 'y': -6, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,630] Trial 78 finished with value: 79.69776598730766 and parameters: {'x': -6.610428578186718, 'y': 6, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,631] Trial 79 finished with value: 104.68471294363015 and parameters: {'x': -1.9195606121271993, 'y': 1, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,631] Trial 80 finished with value: 74.06591005830808 and parameters: {'x': 8.066344280918592, 'y': 3, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,631] Trial 81 finished with value: 138.4153146211057 and parameters: {'x': -7.577289398004123, 'y': 9, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,632] Trial 82 finished with value: 155.76688667297782 and parameters: {'x': -2.601324023065528, 'y': 7, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,632] Trial 83 finished with value: 168.94914203115295 and parameters: {'x': 5.740134321699532, 'y': -6, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,632] Trial 84 finished with value: 104.5354104176354 and parameters: {'x': -1.8802687088912045, 'y': 1, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,633] Trial 85 finished with value: 109.62697878043926 and parameters: {'x': -2.372125371990119, 'y': 2, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,633] Trial 86 finished with value: 150.17475256255742 and parameters: {'x': 6.41675561031877, 'y': -3, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,633] Trial 87 finished with value: 177.55032267401958 and parameters: {'x': -6.445953977032383, 'y': 6, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,634] Trial 88 finished with value: 204.60772509700556 and parameters: {'x': 2.1465612260090694, 'y': -10, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,634] Trial 89 finished with value: 194.64741783771387 and parameters: {'x': -8.868337941109026, 'y': 4, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,634] Trial 90 finished with value: 166.79106295463083 and parameters: {'x': -1.6706474656943122, 'y': 8, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,634] Trial 91 finished with value: 162.3477250143299 and parameters: {'x': 6.807916348952144, 'y': 4, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,635] Trial 92 finished with value: 219.61382110900382 and parameters: {'x': 4.428749384307473, 'y': -10, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,635] Trial 93 finished with value: 110.45354905133493 and parameters: {'x': -3.2331948675164845, 'y': 0, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,635] Trial 94 finished with value: 157.68215440739561 and parameters: {'x': -6.9772598064996565, 'y': -3, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,636] Trial 95 finished with value: 231.03739028608246 and parameters: {'x': 9.057449436021294, 'y': 7, 'z': 'a'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,636] Trial 96 finished with value: 105.9925786336831 and parameters: {'x': 2.447974394000699, 'y': 0, 'z': 'c'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,636] Trial 97 finished with value: 49.56803240616708 and parameters: {'x': -0.753679246209602, 'y': 7, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,637] Trial 98 finished with value: 114.33085627321664 and parameters: {'x': 9.45150021283482, 'y': -5, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.
[I 2025-02-12 03:50:37,637] Trial 99 finished with value: 29.128768059599714 and parameters: {'x': -2.031937021563344, 'y': -5, 'z': 'b'}. Best is trial 18 with value: 4.208547739685752.

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.200 seconds)

Gallery generated by Sphinx-Gallery