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-01-17 09:30:51,091] A new study created in memory with name: no-name-d67013d9-70f9-4767-8d50-280a0c302b36
[I 2025-01-17 09:30:51,092] Trial 0 finished with value: 55.820947779353524 and parameters: {'x': 5.551661713338946, 'y': 5, 'z': 'b'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,093] Trial 1 finished with value: 127.49691533335996 and parameters: {'x': 8.859848493815228, 'y': 7, 'z': 'b'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,093] Trial 2 finished with value: 146.71033228806337 and parameters: {'x': -5.54169038182966, 'y': 4, 'z': 'a'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,094] Trial 3 finished with value: 83.17652519674354 and parameters: {'x': -1.4753051198797955, 'y': 9, 'z': 'b'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,094] Trial 4 finished with value: 86.24056552002409 and parameters: {'x': -2.289228149404094, 'y': 9, 'z': 'b'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,094] Trial 5 finished with value: 162.6884809303381 and parameters: {'x': -9.03816800741932, 'y': -9, 'z': 'b'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,095] Trial 6 finished with value: 126.00818681408535 and parameters: {'x': -4.691288395961748, 'y': -2, 'z': 'a'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,095] Trial 7 finished with value: 249.49006654195256 and parameters: {'x': -9.24608384895749, 'y': 8, 'z': 'c'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,096] Trial 8 finished with value: 132.5307232580393 and parameters: {'x': 4.065799215165365, 'y': 4, 'z': 'a'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,096] Trial 9 finished with value: 116.43847041369054 and parameters: {'x': -3.929181901323804, 'y': -1, 'z': 'a'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,096] Trial 10 finished with value: 225.04562571704548 and parameters: {'x': -9.436398980386823, 'y': 6, 'z': 'c'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,097] Trial 11 finished with value: 168.8494970201387 and parameters: {'x': -2.2021573558986844, 'y': -8, 'z': 'c'}. Best is trial 0 with value: 55.820947779353524.
[I 2025-01-17 09:30:51,097] Trial 12 finished with value: 17.30971532005738 and parameters: {'x': 4.038528855914908, 'y': 1, 'z': 'b'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,098] Trial 13 finished with value: 101.85065326894744 and parameters: {'x': -9.265562760509878, 'y': -4, 'z': 'b'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,098] Trial 14 finished with value: 159.23274826414487 and parameters: {'x': -7.431873805719851, 'y': -2, 'z': 'a'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,098] Trial 15 finished with value: 163.63575139436094 and parameters: {'x': -7.722418752849456, 'y': 2, 'z': 'c'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,099] Trial 16 finished with value: 182.47263001269775 and parameters: {'x': 4.297979759456499, 'y': -8, 'z': 'a'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,099] Trial 17 finished with value: 143.04728298355087 and parameters: {'x': -4.248209385558919, 'y': -5, 'z': 'a'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,099] Trial 18 finished with value: 172.86514793814922 and parameters: {'x': -8.298502752795184, 'y': 2, 'z': 'c'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,100] Trial 19 finished with value: 81.57757713048176 and parameters: {'x': 0.7599849541153816, 'y': 9, 'z': 'b'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,100] Trial 20 finished with value: 196.7316592513631 and parameters: {'x': -9.835225429615893, 'y': 0, 'z': 'c'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,101] Trial 21 finished with value: 184.46144902802297 and parameters: {'x': -8.274143401465977, 'y': 4, 'z': 'c'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,101] Trial 22 finished with value: 191.14627213082784 and parameters: {'x': 9.335216769353984, 'y': 2, 'z': 'a'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,101] Trial 23 finished with value: 26.67800507108111 and parameters: {'x': -1.295378350552884, 'y': 5, 'z': 'b'}. Best is trial 12 with value: 17.30971532005738.
[I 2025-01-17 09:30:51,102] Trial 24 finished with value: 15.281114588590443 and parameters: {'x': -3.358737052612253, 'y': 2, 'z': 'b'}. Best is trial 24 with value: 15.281114588590443.
[I 2025-01-17 09:30:51,102] Trial 25 finished with value: 110.59699547037084 and parameters: {'x': 1.2637228613785734, 'y': -3, 'z': 'a'}. Best is trial 24 with value: 15.281114588590443.
[I 2025-01-17 09:30:51,102] Trial 26 finished with value: 4.849556454469736 and parameters: {'x': -1.9620286579124517, 'y': 1, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,103] Trial 27 finished with value: 51.325387340639544 and parameters: {'x': 1.524922076907389, 'y': 7, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,103] Trial 28 finished with value: 155.06103714994302 and parameters: {'x': -4.365894770827971, 'y': -6, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,104] Trial 29 finished with value: 48.682047961080535 and parameters: {'x': 6.684463176731587, 'y': -2, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,104] Trial 30 finished with value: 167.85634381406774 and parameters: {'x': 7.201134897644103, 'y': 4, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,104] Trial 31 finished with value: 129.92487277796613 and parameters: {'x': 5.470363130356716, 'y': -10, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,105] Trial 32 finished with value: 113.95502321405453 and parameters: {'x': -2.22598814328705, 'y': -3, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,105] Trial 33 finished with value: 143.36324006972512 and parameters: {'x': -7.897039956194036, 'y': 9, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,105] Trial 34 finished with value: 127.2815138600824 and parameters: {'x': -4.275688700090594, 'y': 3, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,106] Trial 35 finished with value: 197.88988040936528 and parameters: {'x': -9.89393149407076, 'y': 0, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,106] Trial 36 finished with value: 43.32024792441402 and parameters: {'x': 4.280215873576241, 'y': 5, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,106] Trial 37 finished with value: 81.56592271506582 and parameters: {'x': -5.706656001115348, 'y': 7, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,107] Trial 38 finished with value: 165.6085803951731 and parameters: {'x': 8.099912369598396, 'y': -10, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,107] Trial 39 finished with value: 104.03954265670197 and parameters: {'x': 0.1988533547666833, 'y': 2, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,108] Trial 40 finished with value: 36.95885407517373 and parameters: {'x': -5.287613268306764, 'y': -3, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,108] Trial 41 finished with value: 22.040316588117516 and parameters: {'x': -4.586972486086822, 'y': 1, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,108] Trial 42 finished with value: 43.588471441389224 and parameters: {'x': -2.7547180330097714, 'y': -6, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,109] Trial 43 finished with value: 59.74209475771893 and parameters: {'x': 4.872586044157551, 'y': 6, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,109] Trial 44 finished with value: 184.30388684246887 and parameters: {'x': -6.9500997721233375, 'y': 6, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,109] Trial 45 finished with value: 179.49826091952215 and parameters: {'x': 9.924629006644135, 'y': 9, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,110] Trial 46 finished with value: 206.29516162573077 and parameters: {'x': 5.029429552715772, 'y': 9, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,110] Trial 47 finished with value: 170.07092981416938 and parameters: {'x': -6.713488647057457, 'y': -5, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,110] Trial 48 finished with value: 169.9391955086486 and parameters: {'x': -2.437046472402322, 'y': -8, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,111] Trial 49 finished with value: 169.3491541779069 and parameters: {'x': -9.399423076865245, 'y': 9, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,111] Trial 50 finished with value: 106.75742090925607 and parameters: {'x': -2.399462629268494, 'y': 1, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,112] Trial 51 finished with value: 109.99673205001187 and parameters: {'x': -2.4488225844294798, 'y': -2, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,112] Trial 52 finished with value: 148.19774498702134 and parameters: {'x': 6.648138460277533, 'y': 2, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,112] Trial 53 finished with value: 184.90507615340897 and parameters: {'x': -6.993216438335724, 'y': 6, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,113] Trial 54 finished with value: 153.62713147448318 and parameters: {'x': -2.151076817429627, 'y': -7, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,113] Trial 55 finished with value: 203.6761857893357 and parameters: {'x': 7.394334709041491, 'y': -7, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,113] Trial 56 finished with value: 236.29582551812155 and parameters: {'x': 6.024601689582603, 'y': -10, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,114] Trial 57 finished with value: 163.8451180394721 and parameters: {'x': 7.927491282837977, 'y': -1, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,114] Trial 58 finished with value: 171.49716420223493 and parameters: {'x': 8.215665779608791, 'y': -2, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,114] Trial 59 finished with value: 223.52727113722636 and parameters: {'x': -4.850491844877832, 'y': -10, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,115] Trial 60 finished with value: 159.7723697643865 and parameters: {'x': -5.896810134673364, 'y': 5, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,115] Trial 61 finished with value: 166.12253927727963 and parameters: {'x': -7.881785284900853, 'y': -2, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,115] Trial 62 finished with value: 106.74015269848603 and parameters: {'x': -9.041026086594709, 'y': -5, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,116] Trial 63 finished with value: 234.67362095696214 and parameters: {'x': -8.406760431757416, 'y': 8, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,116] Trial 64 finished with value: 125.02862231567084 and parameters: {'x': -7.812081817010805, 'y': -8, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,117] Trial 65 finished with value: 16.052588215730985 and parameters: {'x': 0.22932120645719678, 'y': 4, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,117] Trial 66 finished with value: 25.845062421850326 and parameters: {'x': 0.9192727679259978, 'y': 5, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,117] Trial 67 finished with value: 115.69082483254014 and parameters: {'x': 3.9611645803399966, 'y': 0, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,118] Trial 68 finished with value: 127.5331931658956 and parameters: {'x': 3.396055530449347, 'y': 4, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,118] Trial 69 finished with value: 131.91321381650653 and parameters: {'x': -5.559965271160112, 'y': -1, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,118] Trial 70 finished with value: 103.35213585894995 and parameters: {'x': 1.533667453834095, 'y': 1, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,119] Trial 71 finished with value: 17.49360617355542 and parameters: {'x': 1.2221318151310108, 'y': 4, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,119] Trial 72 finished with value: 146.1707876396228 and parameters: {'x': -3.189167232934455, 'y': 6, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,119] Trial 73 finished with value: 173.11534837094274 and parameters: {'x': -6.092236729719449, 'y': -6, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,120] Trial 74 finished with value: 44.10085829874227 and parameters: {'x': -5.301024268831663, 'y': -4, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,120] Trial 75 finished with value: 95.6564228521167 and parameters: {'x': -3.8283707829985207, 'y': -9, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,121] Trial 76 finished with value: 16.27309248760511 and parameters: {'x': -0.5225825175081056, 'y': 4, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,121] Trial 77 finished with value: 219.56521251523773 and parameters: {'x': -9.724464639003925, 'y': 5, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,121] Trial 78 finished with value: 220.96572481698507 and parameters: {'x': 9.217685437081538, 'y': 6, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,122] Trial 79 finished with value: 125.12613543826032 and parameters: {'x': -6.642750592808699, 'y': -9, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,122] Trial 80 finished with value: 195.23746689921052 and parameters: {'x': -3.773256802711755, 'y': 9, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,122] Trial 81 finished with value: 159.95361859439174 and parameters: {'x': 4.894243413888578, 'y': -6, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,123] Trial 82 finished with value: 93.51491778060078 and parameters: {'x': 3.537642969633989, 'y': -9, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,123] Trial 83 finished with value: 100.15359647439435 and parameters: {'x': 0.3919138609367483, 'y': -10, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,123] Trial 84 finished with value: 190.20148778466495 and parameters: {'x': -9.011186813326253, 'y': 3, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,124] Trial 85 finished with value: 95.9843326514964 and parameters: {'x': -9.326539157238145, 'y': -3, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,124] Trial 86 finished with value: 164.10617320624954 and parameters: {'x': -9.116258728571143, 'y': 9, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,125] Trial 87 finished with value: 110.9030486248699 and parameters: {'x': -3.301976472488848, 'y': 0, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,125] Trial 88 finished with value: 202.83584339223043 and parameters: {'x': 8.822462433597007, 'y': 5, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,125] Trial 89 finished with value: 47.69487873751676 and parameters: {'x': -6.833365110801322, 'y': -1, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,126] Trial 90 finished with value: 105.35616736504346 and parameters: {'x': -1.1645459909524654, 'y': -2, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,126] Trial 91 finished with value: 224.35406421160926 and parameters: {'x': 8.680671875587123, 'y': 7, 'z': 'c'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,126] Trial 92 finished with value: 127.94519578930483 and parameters: {'x': 4.893382857421319, 'y': -2, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,127] Trial 93 finished with value: 106.09952541971462 and parameters: {'x': -1.4489739196116087, 'y': 2, 'z': 'a'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,127] Trial 94 finished with value: 73.72300525388853 and parameters: {'x': -6.980186620276605, 'y': -5, 'z': 'b'}. Best is trial 26 with value: 4.849556454469736.
[I 2025-01-17 09:30:51,127] Trial 95 finished with value: 2.8806471773028592 and parameters: {'x': -1.3713669010526903, 'y': 1, 'z': 'b'}. Best is trial 95 with value: 2.8806471773028592.
[I 2025-01-17 09:30:51,128] Trial 96 finished with value: 175.16126601458683 and parameters: {'x': 5.114808502240022, 'y': -7, 'z': 'a'}. Best is trial 95 with value: 2.8806471773028592.
[I 2025-01-17 09:30:51,128] Trial 97 finished with value: 154.8348415412804 and parameters: {'x': 9.530731427402642, 'y': -8, 'z': 'b'}. Best is trial 95 with value: 2.8806471773028592.
[I 2025-01-17 09:30:51,129] Trial 98 finished with value: 11.070257680687483 and parameters: {'x': -1.4388390044363835, 'y': 3, 'z': 'b'}. Best is trial 95 with value: 2.8806471773028592.
[I 2025-01-17 09:30:51,129] Trial 99 finished with value: 159.08217345795975 and parameters: {'x': 7.621166148166548, 'y': -1, 'z': 'c'}. Best is trial 95 with value: 2.8806471773028592.

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

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-01-17 09:30:51,130] A new study created in memory with name: no-name-43cbd68f-52c5-4e36-9db8-7ea05b281a70
[I 2025-01-17 09:30:51,131] Trial 0 finished with value: 250.99744312732332 and parameters: {'x': -8.366447461576707, 'y': 9, 'z': 'c'}. Best is trial 0 with value: 250.99744312732332.
[I 2025-01-17 09:30:51,131] Trial 1 finished with value: 147.02347933834326 and parameters: {'x': -6.857366793335709, 'y': -10, 'z': 'b'}. Best is trial 1 with value: 147.02347933834326.
[I 2025-01-17 09:30:51,131] Trial 2 finished with value: 131.14575871382775 and parameters: {'x': 5.490515341370767, 'y': -1, 'z': 'a'}. Best is trial 2 with value: 131.14575871382775.
[I 2025-01-17 09:30:51,132] Trial 3 finished with value: 65.53799504451426 and parameters: {'x': 1.2401592819127156, 'y': 8, 'z': 'b'}. Best is trial 3 with value: 65.53799504451426.
[I 2025-01-17 09:30:51,132] Trial 4 finished with value: 42.4919337194269 and parameters: {'x': -5.787221588934271, 'y': 3, 'z': 'b'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,132] Trial 5 finished with value: 140.76032828212323 and parameters: {'x': 4.9759751086719906, 'y': 4, 'z': 'a'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,132] Trial 6 finished with value: 120.20269858735381 and parameters: {'x': -3.3470432604544875, 'y': 3, 'z': 'c'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,133] Trial 7 finished with value: 88.22822210027284 and parameters: {'x': 2.688535307611348, 'y': 9, 'z': 'b'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,133] Trial 8 finished with value: 152.59479062204625 and parameters: {'x': -8.461370493132081, 'y': -9, 'z': 'b'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,133] Trial 9 finished with value: 114.06216971260099 and parameters: {'x': -9.902634483439293, 'y': -4, 'z': 'b'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,134] Trial 10 finished with value: 174.53851256862657 and parameters: {'x': -8.633568935766169, 'y': -10, 'z': 'b'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,134] Trial 11 finished with value: 245.04995994445935 and parameters: {'x': 8.003121887392403, 'y': 9, 'z': 'a'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,134] Trial 12 finished with value: 60.87696759387281 and parameters: {'x': -3.4462976647226533, 'y': -7, 'z': 'b'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,135] Trial 13 finished with value: 154.86960957528416 and parameters: {'x': -7.407402350033658, 'y': 0, 'z': 'a'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,135] Trial 14 finished with value: 134.00463995172524 and parameters: {'x': -7.2804285554989985, 'y': -9, 'z': 'b'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,135] Trial 15 finished with value: 203.12252166762994 and parameters: {'x': 8.19283355546968, 'y': 6, 'z': 'a'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,136] Trial 16 finished with value: 92.3271334027999 and parameters: {'x': 8.736540127693566, 'y': 4, 'z': 'b'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,136] Trial 17 finished with value: 105.86607776421172 and parameters: {'x': -1.3660445688965357, 'y': -2, 'z': 'a'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,136] Trial 18 finished with value: 77.55616001340611 and parameters: {'x': -3.6818690923776902, 'y': 8, 'z': 'b'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,136] Trial 19 finished with value: 123.86642049868554 and parameters: {'x': 7.737339368199223, 'y': 8, 'z': 'b'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,137] Trial 20 finished with value: 238.49164806547395 and parameters: {'x': -9.460002540458113, 'y': -7, 'z': 'a'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,137] Trial 21 finished with value: 199.12686048097993 and parameters: {'x': -4.2575650882846094, 'y': -9, 'z': 'a'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,137] Trial 22 finished with value: 197.43032029813753 and parameters: {'x': 7.8377496960631206, 'y': -6, 'z': 'c'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,138] Trial 23 finished with value: 138.48146556871234 and parameters: {'x': 3.671711531249745, 'y': 5, 'z': 'c'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,138] Trial 24 finished with value: 104.8444294530004 and parameters: {'x': -1.9607216663770508, 'y': -1, 'z': 'a'}. Best is trial 4 with value: 42.4919337194269.
[I 2025-01-17 09:30:51,138] Trial 25 finished with value: 39.20291560534279 and parameters: {'x': 1.7896691329245158, 'y': -6, 'z': 'b'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,139] Trial 26 finished with value: 83.98046666776725 and parameters: {'x': 5.914428684815402, 'y': -7, 'z': 'b'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,139] Trial 27 finished with value: 136.60783940607584 and parameters: {'x': -3.407027943248462, 'y': -5, 'z': 'c'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,139] Trial 28 finished with value: 125.0120300587018 and parameters: {'x': 0.10968162426675576, 'y': -5, 'z': 'c'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,140] Trial 29 finished with value: 196.8521073145282 and parameters: {'x': 5.731675785887422, 'y': 8, 'z': 'c'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,140] Trial 30 finished with value: 72.69715467044651 and parameters: {'x': -7.981049722338942, 'y': 3, 'z': 'b'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,140] Trial 31 finished with value: 134.74350978627157 and parameters: {'x': -9.936976893717302, 'y': -6, 'z': 'b'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,140] Trial 32 finished with value: 117.36240588869694 and parameters: {'x': 4.045047081147132, 'y': 1, 'z': 'c'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,141] Trial 33 finished with value: 39.66099545027575 and parameters: {'x': -5.537237167602247, 'y': -3, 'z': 'b'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,141] Trial 34 finished with value: 173.755150846069 and parameters: {'x': -6.9824888718900935, 'y': 5, 'z': 'c'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,141] Trial 35 finished with value: 133.16389893854495 and parameters: {'x': -4.1429336150299285, 'y': -4, 'z': 'c'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,142] Trial 36 finished with value: 133.49830178876832 and parameters: {'x': 7.245571184438692, 'y': 9, 'z': 'b'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,142] Trial 37 finished with value: 133.44852926842714 and parameters: {'x': -9.189588090247959, 'y': 7, 'z': 'b'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,143] Trial 38 finished with value: 153.3773694152925 and parameters: {'x': -4.168617206615702, 'y': -6, 'z': 'c'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,143] Trial 39 finished with value: 198.53925370785362 and parameters: {'x': 9.876196317806446, 'y': 1, 'z': 'c'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,143] Trial 40 finished with value: 66.24859948280105 and parameters: {'x': 8.077660520398283, 'y': -1, 'z': 'b'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,144] Trial 41 finished with value: 104.30325116645584 and parameters: {'x': -0.5506824551915948, 'y': -2, 'z': 'c'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,144] Trial 42 finished with value: 64.4867826756425 and parameters: {'x': -7.448945071326712, 'y': -3, 'z': 'b'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,144] Trial 43 finished with value: 92.70247569209482 and parameters: {'x': 9.576140960329209, 'y': 1, 'z': 'b'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,145] Trial 44 finished with value: 108.69269743909393 and parameters: {'x': -5.262385147354185, 'y': -9, 'z': 'b'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,145] Trial 45 finished with value: 149.8123726026801 and parameters: {'x': -0.9013171487773448, 'y': -7, 'z': 'c'}. Best is trial 25 with value: 39.20291560534279.
[I 2025-01-17 09:30:51,145] Trial 46 finished with value: 28.235744306902838 and parameters: {'x': -3.497962879577603, 'y': 4, 'z': 'b'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,146] Trial 47 finished with value: 152.15564546534165 and parameters: {'x': 1.7764136526557266, 'y': -7, 'z': 'a'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,146] Trial 48 finished with value: 171.4329517039278 and parameters: {'x': -5.952558416674951, 'y': 6, 'z': 'a'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,146] Trial 49 finished with value: 165.6496366499734 and parameters: {'x': -1.2843818162732585, 'y': 8, 'z': 'c'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,147] Trial 50 finished with value: 177.9607484527677 and parameters: {'x': 5.381519158450306, 'y': 7, 'z': 'a'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,147] Trial 51 finished with value: 276.6068018123528 and parameters: {'x': 8.752531166031503, 'y': -10, 'z': 'c'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,147] Trial 52 finished with value: 225.42725463612138 and parameters: {'x': -6.665377306358686, 'y': -9, 'z': 'c'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,148] Trial 53 finished with value: 86.63323206477375 and parameters: {'x': 9.25382256501462, 'y': -1, 'z': 'b'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,148] Trial 54 finished with value: 143.4194371741953 and parameters: {'x': 6.513020587576499, 'y': -1, 'z': 'c'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,148] Trial 55 finished with value: 157.23167359887856 and parameters: {'x': -8.731075168550467, 'y': -9, 'z': 'b'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,148] Trial 56 finished with value: 104.88593265895427 and parameters: {'x': -0.9412399582222761, 'y': -2, 'z': 'a'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,149] Trial 57 finished with value: 173.86031973120564 and parameters: {'x': -8.535825661950087, 'y': -1, 'z': 'c'}. Best is trial 46 with value: 28.235744306902838.
[I 2025-01-17 09:30:51,149] Trial 58 finished with value: 6.649968740871116 and parameters: {'x': -2.3769662893846677, 'y': -1, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,149] Trial 59 finished with value: 95.54989207547717 and parameters: {'x': -6.822748132202827, 'y': -7, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,150] Trial 60 finished with value: 159.68098210874572 and parameters: {'x': -5.889056130548063, 'y': 5, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,150] Trial 61 finished with value: 93.50408943916815 and parameters: {'x': 5.431766695944162, 'y': -8, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,150] Trial 62 finished with value: 205.64365900855316 and parameters: {'x': 6.453189832056172, 'y': 8, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,151] Trial 63 finished with value: 94.86639878623166 and parameters: {'x': 7.6724441207630605, 'y': -6, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,151] Trial 64 finished with value: 86.73565569590451 and parameters: {'x': 2.3949228997828964, 'y': 9, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,152] Trial 65 finished with value: 79.60552302032455 and parameters: {'x': 8.922192724903702, 'y': 0, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,152] Trial 66 finished with value: 128.69242984071596 and parameters: {'x': 1.9215696294217288, 'y': -5, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,152] Trial 67 finished with value: 152.05054664225605 and parameters: {'x': 4.006313347986655, 'y': -6, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,153] Trial 68 finished with value: 170.3926148649736 and parameters: {'x': -4.62521511553502, 'y': 7, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,153] Trial 69 finished with value: 93.8298365168989 and parameters: {'x': -5.461669755386067, 'y': 8, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,153] Trial 70 finished with value: 130.8112463912153 and parameters: {'x': -2.4106526898778435, 'y': -5, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,154] Trial 71 finished with value: 161.36365051798634 and parameters: {'x': -6.030228065171858, 'y': -5, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,154] Trial 72 finished with value: 165.61308474586542 and parameters: {'x': 1.2700727325100036, 'y': -8, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,154] Trial 73 finished with value: 129.1823545538943 and parameters: {'x': -9.653100774046353, 'y': 6, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,155] Trial 74 finished with value: 156.02996519302224 and parameters: {'x': -6.326923833350788, 'y': 4, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,155] Trial 75 finished with value: 185.14406694835938 and parameters: {'x': -9.008000163652273, 'y': 2, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,155] Trial 76 finished with value: 37.41028836155781 and parameters: {'x': -1.1875556246163015, 'y': 6, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,156] Trial 77 finished with value: 9.16506919621027 and parameters: {'x': -2.857458520470642, 'y': -1, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,156] Trial 78 finished with value: 104.82744860365037 and parameters: {'x': -1.9563866191656398, 'y': 1, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,156] Trial 79 finished with value: 181.43203893697287 and parameters: {'x': 4.175169330335343, 'y': 8, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,157] Trial 80 finished with value: 183.71863965959972 and parameters: {'x': -4.4405674929675065, 'y': -8, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,157] Trial 81 finished with value: 153.1176166924521 and parameters: {'x': 7.008396156928637, 'y': 2, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,157] Trial 82 finished with value: 159.5211944347401 and parameters: {'x': -4.849865403775664, 'y': 6, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,157] Trial 83 finished with value: 267.45591368775706 and parameters: {'x': -8.213154916824415, 'y': -10, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,158] Trial 84 finished with value: 95.6991812325059 and parameters: {'x': 5.6302025924922, 'y': 8, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,158] Trial 85 finished with value: 152.7741600757811 and parameters: {'x': 6.064170188556808, 'y': -4, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,158] Trial 86 finished with value: 263.9287519626025 and parameters: {'x': -9.106522495585377, 'y': -9, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,159] Trial 87 finished with value: 131.1462891598339 and parameters: {'x': -4.705984398596527, 'y': 3, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,159] Trial 88 finished with value: 148.2494534466258 and parameters: {'x': 6.873823786410721, 'y': 1, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,159] Trial 89 finished with value: 81.648022350546 and parameters: {'x': 0.8049983543747175, 'y': 9, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,160] Trial 90 finished with value: 146.20193330736143 and parameters: {'x': 6.4963015098871, 'y': 2, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,160] Trial 91 finished with value: 131.21290134681547 and parameters: {'x': -5.4966263604883565, 'y': 1, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,160] Trial 92 finished with value: 115.94074348401556 and parameters: {'x': 2.634529082021217, 'y': -3, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,161] Trial 93 finished with value: 109.19015211643746 and parameters: {'x': 2.861844181019899, 'y': -1, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,161] Trial 94 finished with value: 168.89461866372415 and parameters: {'x': -4.460338402377577, 'y': 7, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,161] Trial 95 finished with value: 135.69214401201123 and parameters: {'x': 5.629577605114902, 'y': -2, 'z': 'c'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,161] Trial 96 finished with value: 21.111604059525646 and parameters: {'x': -2.260885680330973, 'y': 4, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,162] Trial 97 finished with value: 152.5057488525043 and parameters: {'x': -7.176750577559757, 'y': -1, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,162] Trial 98 finished with value: 108.66711336628322 and parameters: {'x': -2.1603502878661196, 'y': 2, 'z': 'a'}. Best is trial 58 with value: 6.649968740871116.
[I 2025-01-17 09:30:51,162] Trial 99 finished with value: 79.32290827028442 and parameters: {'x': -3.9144486547002266, 'y': 8, 'z': 'b'}. Best is trial 58 with value: 6.649968740871116.

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

Gallery generated by Sphinx-Gallery