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-02 06:22:22,975] A new study created in memory with name: no-name-1165dd17-e202-44ad-9c60-1a96a6a097ec
[I 2024-10-02 06:22:22,976] Trial 0 finished with value: 213.1535282622138 and parameters: {'x': 9.856648936743856, 'y': 4, 'z': 'c'}. Best is trial 0 with value: 213.1535282622138.
[I 2024-10-02 06:22:22,977] Trial 1 finished with value: 41.21326753153346 and parameters: {'x': 4.026570194536966, 'y': 5, 'z': 'b'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,977] Trial 2 finished with value: 108.20439248418835 and parameters: {'x': -2.0504615295558075, 'y': -2, 'z': 'c'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,978] Trial 3 finished with value: 205.95839579983056 and parameters: {'x': -4.995837847631823, 'y': 9, 'z': 'c'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,978] Trial 4 finished with value: 62.74716094742518 and parameters: {'x': -7.921310557440933, 'y': 0, 'z': 'b'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,979] Trial 5 finished with value: 191.76224506896588 and parameters: {'x': -8.170816670869925, 'y': -5, 'z': 'c'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,979] Trial 6 finished with value: 159.1133004821134 and parameters: {'x': -4.807629403574428, 'y': -6, 'z': 'c'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,980] Trial 7 finished with value: 179.27724287186481 and parameters: {'x': 8.383152323074228, 'y': -3, 'z': 'c'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,980] Trial 8 finished with value: 104.12662052934016 and parameters: {'x': -4.809014507083562, 'y': 9, 'z': 'b'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,980] Trial 9 finished with value: 131.3769563449304 and parameters: {'x': -2.525263618898112, 'y': -5, 'z': 'a'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,981] Trial 10 finished with value: 138.16788431194414 and parameters: {'x': 6.09654691706249, 'y': 1, 'z': 'c'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,981] Trial 11 finished with value: 194.6480220879472 and parameters: {'x': 9.72872150325762, 'y': 0, 'z': 'c'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,982] Trial 12 finished with value: 132.89058360633038 and parameters: {'x': -5.647174834050244, 'y': -1, 'z': 'a'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,982] Trial 13 finished with value: 105.67611586303653 and parameters: {'x': -4.9675060003020155, 'y': -9, 'z': 'b'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,982] Trial 14 finished with value: 248.9670005959942 and parameters: {'x': -9.21775463960688, 'y': -8, 'z': 'c'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,983] Trial 15 finished with value: 125.46683285646114 and parameters: {'x': 0.6832516787108123, 'y': -5, 'z': 'c'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,983] Trial 16 finished with value: 127.78789116689784 and parameters: {'x': 9.580599728978235, 'y': -6, 'z': 'b'}. Best is trial 1 with value: 41.21326753153346.
[I 2024-10-02 06:22:22,983] Trial 17 finished with value: 38.11610756297894 and parameters: {'x': 4.702776580168246, 'y': -4, 'z': 'b'}. Best is trial 17 with value: 38.11610756297894.
[I 2024-10-02 06:22:22,984] Trial 18 finished with value: 60.35050253257926 and parameters: {'x': 7.768558587832061, 'y': 0, 'z': 'b'}. Best is trial 17 with value: 38.11610756297894.
[I 2024-10-02 06:22:22,984] Trial 19 finished with value: 175.85989513555063 and parameters: {'x': 8.17679002638264, 'y': -3, 'z': 'a'}. Best is trial 17 with value: 38.11610756297894.
[I 2024-10-02 06:22:22,985] Trial 20 finished with value: 154.60413972450382 and parameters: {'x': 7.321484803269335, 'y': 1, 'z': 'c'}. Best is trial 17 with value: 38.11610756297894.
[I 2024-10-02 06:22:22,985] Trial 21 finished with value: 81.82659146440211 and parameters: {'x': 4.2221548366210016, 'y': -8, 'z': 'b'}. Best is trial 17 with value: 38.11610756297894.
[I 2024-10-02 06:22:22,985] Trial 22 finished with value: 38.60051980487283 and parameters: {'x': -6.13192627196975, 'y': -1, 'z': 'b'}. Best is trial 17 with value: 38.11610756297894.
[I 2024-10-02 06:22:22,986] Trial 23 finished with value: 44.18556558214188 and parameters: {'x': -2.8610427438508985, 'y': -6, 'z': 'b'}. Best is trial 17 with value: 38.11610756297894.
[I 2024-10-02 06:22:22,986] Trial 24 finished with value: 8.207343281771948 and parameters: {'x': -2.6846495640533696, 'y': -1, 'z': 'b'}. Best is trial 24 with value: 8.207343281771948.
[I 2024-10-02 06:22:22,987] Trial 25 finished with value: 141.81111788702214 and parameters: {'x': -2.410626036327937, 'y': 6, 'z': 'a'}. Best is trial 24 with value: 8.207343281771948.
[I 2024-10-02 06:22:22,987] Trial 26 finished with value: 188.45156071105635 and parameters: {'x': -2.729754697963969, 'y': 9, 'z': 'c'}. Best is trial 24 with value: 8.207343281771948.
[I 2024-10-02 06:22:22,987] Trial 27 finished with value: 25.502355390631845 and parameters: {'x': 0.7087703370146379, 'y': 5, 'z': 'b'}. Best is trial 24 with value: 8.207343281771948.
[I 2024-10-02 06:22:22,988] Trial 28 finished with value: 85.36588151354665 and parameters: {'x': 9.239365861007272, 'y': 0, 'z': 'b'}. Best is trial 24 with value: 8.207343281771948.
[I 2024-10-02 06:22:22,988] Trial 29 finished with value: 201.4275200592964 and parameters: {'x': -4.519681411260796, 'y': -9, 'z': 'a'}. Best is trial 24 with value: 8.207343281771948.
[I 2024-10-02 06:22:22,988] Trial 30 finished with value: 155.13218703079224 and parameters: {'x': 5.489279281544368, 'y': -5, 'z': 'c'}. Best is trial 24 with value: 8.207343281771948.
[I 2024-10-02 06:22:22,989] Trial 31 finished with value: 2.6547004673994605 and parameters: {'x': -1.286351611107733, 'y': -1, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,989] Trial 32 finished with value: 199.14356370705167 and parameters: {'x': 7.9462924503853785, 'y': 6, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,990] Trial 33 finished with value: 201.78436729097234 and parameters: {'x': -4.558987529152976, 'y': 9, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,990] Trial 34 finished with value: 189.6450355290992 and parameters: {'x': 9.468106227176541, 'y': -10, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,990] Trial 35 finished with value: 130.96704725822812 and parameters: {'x': 5.474216588538319, 'y': 1, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,991] Trial 36 finished with value: 19.229387287457374 and parameters: {'x': -4.26958865553315, 'y': -1, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,991] Trial 37 finished with value: 140.40737546878594 and parameters: {'x': 7.707618015235703, 'y': -9, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,991] Trial 38 finished with value: 16.31924190778015 and parameters: {'x': -2.7054097485926505, 'y': 3, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,992] Trial 39 finished with value: 125.70270335334764 and parameters: {'x': 0.8382740323710642, 'y': 5, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,992] Trial 40 finished with value: 126.04494328925645 and parameters: {'x': 4.128552202559204, 'y': -3, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,993] Trial 41 finished with value: 142.60789887477625 and parameters: {'x': 2.5705833724616376, 'y': -6, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,993] Trial 42 finished with value: 166.59361654393334 and parameters: {'x': 8.098988612409165, 'y': -1, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,993] Trial 43 finished with value: 171.03018802863716 and parameters: {'x': 4.693632711305513, 'y': 7, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,994] Trial 44 finished with value: 207.82664787445412 and parameters: {'x': -6.620169776860267, 'y': -8, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,994] Trial 45 finished with value: 180.39721578188608 and parameters: {'x': 6.663123575462642, 'y': 6, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,995] Trial 46 finished with value: 161.99552820138905 and parameters: {'x': 6.782000309745573, 'y': 4, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,995] Trial 47 finished with value: 98.39509093225742 and parameters: {'x': 4.170742251956769, 'y': 9, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,995] Trial 48 finished with value: 207.14733439928614 and parameters: {'x': 2.673449905886798, 'y': -10, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,996] Trial 49 finished with value: 97.4857394300555 and parameters: {'x': -8.513855732278737, 'y': -5, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,996] Trial 50 finished with value: 61.70675627839723 and parameters: {'x': -5.070183061625806, 'y': -6, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,996] Trial 51 finished with value: 164.65488761066462 and parameters: {'x': 7.7881247814005015, 'y': 2, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,997] Trial 52 finished with value: 147.99065224910922 and parameters: {'x': -4.794856853870533, 'y': 5, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,997] Trial 53 finished with value: 171.0118945326234 and parameters: {'x': -4.691683549923564, 'y': 7, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,998] Trial 54 finished with value: 137.4188797929502 and parameters: {'x': -3.524043103162928, 'y': -5, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,998] Trial 55 finished with value: 54.58615473558883 and parameters: {'x': 2.363504756836514, 'y': -7, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,998] Trial 56 finished with value: 121.03834655610616 and parameters: {'x': -4.476421177247083, 'y': 1, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,999] Trial 57 finished with value: 160.05271375655394 and parameters: {'x': -7.14511817652822, 'y': 3, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:22,999] Trial 58 finished with value: 159.42665582274168 and parameters: {'x': 3.2290332644216733, 'y': 7, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,000] Trial 59 finished with value: 187.13741072475227 and parameters: {'x': 2.477379810354538, 'y': -9, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,000] Trial 60 finished with value: 143.52648792734442 and parameters: {'x': -2.743444536954307, 'y': 6, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,000] Trial 61 finished with value: 264.13317648724933 and parameters: {'x': 9.117739658887466, 'y': -9, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,001] Trial 62 finished with value: 143.21293466191744 and parameters: {'x': -2.6856907234299054, 'y': 6, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,001] Trial 63 finished with value: 132.22763568048276 and parameters: {'x': -2.688426246056002, 'y': -5, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,001] Trial 64 finished with value: 251.9855077485603 and parameters: {'x': -8.425289772379363, 'y': 9, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,002] Trial 65 finished with value: 149.00008819416797 and parameters: {'x': -0.009391175004241248, 'y': -7, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,002] Trial 66 finished with value: 132.17705845973086 and parameters: {'x': 2.6790032586264, 'y': -5, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,003] Trial 67 finished with value: 205.6831500604218 and parameters: {'x': 2.3839358339564853, 'y': -10, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,003] Trial 68 finished with value: 159.39314999267685 and parameters: {'x': 4.836646564788133, 'y': -6, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,004] Trial 69 finished with value: 128.00175163504449 and parameters: {'x': -1.732556387262612, 'y': -5, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,004] Trial 70 finished with value: 18.198723985005955 and parameters: {'x': -3.768119422869445, 'y': -2, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,004] Trial 71 finished with value: 163.754217752224 and parameters: {'x': -7.399609297268606, 'y': -3, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,005] Trial 72 finished with value: 50.12908531382494 and parameters: {'x': -1.0625842619881674, 'y': 7, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,005] Trial 73 finished with value: 102.41556628349332 and parameters: {'x': 7.308595370075793, 'y': -7, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,005] Trial 74 finished with value: 67.21568002196665 and parameters: {'x': 4.267983132811873, 'y': 7, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,006] Trial 75 finished with value: 195.61676343801525 and parameters: {'x': -9.306812743255087, 'y': 3, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,006] Trial 76 finished with value: 94.4368243655274 and parameters: {'x': 8.332876116055452, 'y': 5, 'z': 'b'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,007] Trial 77 finished with value: 193.9092592002413 and parameters: {'x': -6.70143709962582, 'y': 7, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,007] Trial 78 finished with value: 111.68584233174225 and parameters: {'x': 1.6388539690107393, 'y': 3, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,007] Trial 79 finished with value: 158.39890864884163 and parameters: {'x': 5.779178890538137, 'y': 5, 'z': 'c'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,008] Trial 80 finished with value: 207.48652911955844 and parameters: {'x': -2.7361522471453315, 'y': -10, 'z': 'a'}. Best is trial 31 with value: 2.6547004673994605.
[I 2024-10-02 06:22:23,008] Trial 81 finished with value: 0.7083194946549095 and parameters: {'x': 0.8416171900899538, 'y': 0, 'z': 'b'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,009] Trial 82 finished with value: 168.29601257204683 and parameters: {'x': 7.700390416858539, 'y': -3, 'z': 'a'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,009] Trial 83 finished with value: 14.806531779735984 and parameters: {'x': -3.2873289734579325, 'y': -2, 'z': 'b'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,009] Trial 84 finished with value: 28.364127060863233 and parameters: {'x': 4.400468959197784, 'y': 3, 'z': 'b'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,010] Trial 85 finished with value: 107.25057114530615 and parameters: {'x': 1.802934037979803, 'y': -2, 'z': 'a'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,010] Trial 86 finished with value: 104.09014275692293 and parameters: {'x': 0.3002378339299092, 'y': -2, 'z': 'a'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,010] Trial 87 finished with value: 131.28160990080357 and parameters: {'x': 8.202536796674767, 'y': 8, 'z': 'b'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,011] Trial 88 finished with value: 36.669947204831445 and parameters: {'x': 0.818503026769875, 'y': 6, 'z': 'b'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,011] Trial 89 finished with value: 136.4824082356204 and parameters: {'x': -3.3885702347185305, 'y': 5, 'z': 'c'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,012] Trial 90 finished with value: 237.443904017463 and parameters: {'x': 6.119142425002298, 'y': -10, 'z': 'c'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,012] Trial 91 finished with value: 236.13604982827775 and parameters: {'x': 7.42536529931543, 'y': 9, 'z': 'c'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,012] Trial 92 finished with value: 193.8139643561958 and parameters: {'x': -9.68576090744531, 'y': 0, 'z': 'c'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,013] Trial 93 finished with value: 126.06161721956514 and parameters: {'x': -9.490079937469712, 'y': 6, 'z': 'b'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,013] Trial 94 finished with value: 258.219282889854 and parameters: {'x': 8.787450306536819, 'y': -9, 'z': 'a'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,014] Trial 95 finished with value: 122.47559138874918 and parameters: {'x': -4.2983242535608195, 'y': -2, 'z': 'a'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,014] Trial 96 finished with value: 117.54740399702935 and parameters: {'x': 3.680679828106399, 'y': 2, 'z': 'c'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,014] Trial 97 finished with value: 166.39704659476075 and parameters: {'x': 5.513351666161043, 'y': -6, 'z': 'a'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,015] Trial 98 finished with value: 90.1803857039888 and parameters: {'x': 3.029915131482861, 'y': -9, 'z': 'b'}. Best is trial 81 with value: 0.7083194946549095.
[I 2024-10-02 06:22:23,015] Trial 99 finished with value: 62.66155655012087 and parameters: {'x': -3.6961542919798234, 'y': 7, 'z': 'b'}. Best is trial 81 with value: 0.7083194946549095.

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.8416171900899538, 'y': 0, 'z': 'b'}, Best value: 0.7083194946549095

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-02 06:22:23,016] A new study created in memory with name: no-name-70565361-4d3c-43fe-a720-56f683289bf0
[I 2024-10-02 06:22:23,017] Trial 0 finished with value: 63.734456271103944 and parameters: {'x': -6.223701171417531, 'y': -5, 'z': 'b'}. Best is trial 0 with value: 63.734456271103944.
[I 2024-10-02 06:22:23,017] Trial 1 finished with value: 204.96924027862394 and parameters: {'x': 7.481259270913149, 'y': 7, 'z': 'c'}. Best is trial 0 with value: 63.734456271103944.
[I 2024-10-02 06:22:23,017] Trial 2 finished with value: 210.1835075387596 and parameters: {'x': -8.612984821695647, 'y': 6, 'z': 'c'}. Best is trial 0 with value: 63.734456271103944.
[I 2024-10-02 06:22:23,018] Trial 3 finished with value: 224.6722763811051 and parameters: {'x': -6.6085003125599595, 'y': 9, 'z': 'a'}. Best is trial 0 with value: 63.734456271103944.
[I 2024-10-02 06:22:23,018] Trial 4 finished with value: 138.27129931312578 and parameters: {'x': -6.105022466226129, 'y': 1, 'z': 'c'}. Best is trial 0 with value: 63.734456271103944.
[I 2024-10-02 06:22:23,018] Trial 5 finished with value: 221.23723815144484 and parameters: {'x': -4.608387803933698, 'y': -10, 'z': 'c'}. Best is trial 0 with value: 63.734456271103944.
[I 2024-10-02 06:22:23,019] Trial 6 finished with value: 48.80814604740408 and parameters: {'x': 6.98628270594628, 'y': 0, 'z': 'b'}. Best is trial 6 with value: 48.80814604740408.
[I 2024-10-02 06:22:23,019] Trial 7 finished with value: 1.3358859059885442 and parameters: {'x': 1.1558053062642273, 'y': 0, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,019] Trial 8 finished with value: 51.64141122631995 and parameters: {'x': -6.902275800511013, 'y': 2, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,020] Trial 9 finished with value: 228.69477192052608 and parameters: {'x': 6.906140160793587, 'y': 9, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,020] Trial 10 finished with value: 289.61695088510186 and parameters: {'x': 9.466622992656983, 'y': -10, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,020] Trial 11 finished with value: 169.37287109634252 and parameters: {'x': -2.3179454472317795, 'y': -8, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,020] Trial 12 finished with value: 59.8651225626452 and parameters: {'x': 6.6230750080793435, 'y': -4, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,021] Trial 13 finished with value: 15.882697075609727 and parameters: {'x': 3.4471288162193368, 'y': 2, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,021] Trial 14 finished with value: 180.35025657134358 and parameters: {'x': 8.907876097664559, 'y': 1, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,021] Trial 15 finished with value: 74.69589311981426 and parameters: {'x': -5.069111669692655, 'y': -7, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,022] Trial 16 finished with value: 112.78125348354418 and parameters: {'x': 3.4323830618892437, 'y': 1, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,022] Trial 17 finished with value: 153.24264403496193 and parameters: {'x': 2.0597679565819824, 'y': -7, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,022] Trial 18 finished with value: 114.48404684480087 and parameters: {'x': -3.672063022988694, 'y': -1, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,023] Trial 19 finished with value: 111.08995797969678 and parameters: {'x': -1.4456686963812881, 'y': 3, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,023] Trial 20 finished with value: 277.64082999907384 and parameters: {'x': 9.830606797094156, 'y': -9, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,023] Trial 21 finished with value: 118.85889326766338 and parameters: {'x': 1.690826208592524, 'y': -4, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,024] Trial 22 finished with value: 280.32966428628674 and parameters: {'x': -8.962681757503539, 'y': -10, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,024] Trial 23 finished with value: 237.38636043999713 and parameters: {'x': -8.56658394227227, 'y': -8, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,024] Trial 24 finished with value: 172.79030906635262 and parameters: {'x': -7.986883564091354, 'y': 3, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,025] Trial 25 finished with value: 65.48627172861849 and parameters: {'x': 1.2191274456013552, 'y': 8, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,025] Trial 26 finished with value: 128.67599981021826 and parameters: {'x': -5.260798400453894, 'y': 1, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,025] Trial 27 finished with value: 132.39778242588426 and parameters: {'x': -4.049417541558819, 'y': -4, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,026] Trial 28 finished with value: 202.11782792295986 and parameters: {'x': 1.4552758923859983, 'y': -10, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,026] Trial 29 finished with value: 158.87842604918814 and parameters: {'x': -3.1429963488983166, 'y': -7, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,026] Trial 30 finished with value: 126.03358097965486 and parameters: {'x': -1.0166518478096904, 'y': -5, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,027] Trial 31 finished with value: 126.37402185156552 and parameters: {'x': -5.0372633295833875, 'y': 1, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,027] Trial 32 finished with value: 214.7353132005028 and parameters: {'x': 8.87329212865793, 'y': 6, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,027] Trial 33 finished with value: 194.6256771400577 and parameters: {'x': -3.6912974873420428, 'y': 9, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,028] Trial 34 finished with value: 37.11481449929866 and parameters: {'x': -1.0558477633156507, 'y': 6, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,028] Trial 35 finished with value: 156.79661415368582 and parameters: {'x': 5.638848654972559, 'y': -5, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,028] Trial 36 finished with value: 37.293841671309416 and parameters: {'x': -1.1374716134081826, 'y': 6, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,029] Trial 37 finished with value: 261.53723534349854 and parameters: {'x': 8.9742540271322, 'y': -9, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,029] Trial 38 finished with value: 117.39726908442881 and parameters: {'x': -6.033014924930056, 'y': 9, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,029] Trial 39 finished with value: 27.396237274487063 and parameters: {'x': 1.5479784476817056, 'y': 5, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,030] Trial 40 finished with value: 267.7027678053147 and parameters: {'x': -8.228169164845525, 'y': -10, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,030] Trial 41 finished with value: 136.0891270818657 and parameters: {'x': -0.2985415915173526, 'y': 6, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,030] Trial 42 finished with value: 131.56866135812388 and parameters: {'x': 3.9457143026483656, 'y': 4, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,030] Trial 43 finished with value: 170.650368325246 and parameters: {'x': -2.5788308058587317, 'y': -8, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,031] Trial 44 finished with value: 101.94984725782659 and parameters: {'x': -1.3963693128347483, 'y': -10, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,031] Trial 45 finished with value: 39.687203994629755 and parameters: {'x': 3.832388810471839, 'y': -5, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,031] Trial 46 finished with value: 181.46287779226014 and parameters: {'x': -0.680351227132082, 'y': -9, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,032] Trial 47 finished with value: 118.3488741226117 and parameters: {'x': -3.7879907764686678, 'y': -2, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,032] Trial 48 finished with value: 183.6748155406454 and parameters: {'x': 1.635486331537317, 'y': 9, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,032] Trial 49 finished with value: 42.358701714426374 and parameters: {'x': -2.5216466275880878, 'y': 6, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,033] Trial 50 finished with value: 135.16153024369476 and parameters: {'x': -5.5822513597736485, 'y': 2, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,033] Trial 51 finished with value: 119.57418698496741 and parameters: {'x': -3.2517975006090722, 'y': -3, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,033] Trial 52 finished with value: 168.20751146512913 and parameters: {'x': 6.573242081737835, 'y': -5, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,034] Trial 53 finished with value: 144.72806116971938 and parameters: {'x': 2.9543292250051234, 'y': 6, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,034] Trial 54 finished with value: 137.17079877623888 and parameters: {'x': -4.601173630307695, 'y': -4, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,034] Trial 55 finished with value: 182.09157468182212 and parameters: {'x': -8.12967248305995, 'y': 4, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,035] Trial 56 finished with value: 145.6829114562467 and parameters: {'x': 6.0566419290103894, 'y': 3, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,035] Trial 57 finished with value: 222.372907109359 and parameters: {'x': 9.867771131788526, 'y': 5, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,035] Trial 58 finished with value: 111.90874361385961 and parameters: {'x': 2.8122488534728944, 'y': -2, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,036] Trial 59 finished with value: 42.58080898292307 and parameters: {'x': 6.448318306575992, 'y': 1, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,036] Trial 60 finished with value: 125.1125823667808 and parameters: {'x': -4.014048127113177, 'y': 3, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,036] Trial 61 finished with value: 163.77448415490923 and parameters: {'x': 3.843759117700955, 'y': -7, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,037] Trial 62 finished with value: 176.55019448750664 and parameters: {'x': 8.218892534125668, 'y': 3, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,037] Trial 63 finished with value: 214.9284558219772 and parameters: {'x': 3.8637359927895147, 'y': -10, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,037] Trial 64 finished with value: 152.55647014870044 and parameters: {'x': -7.180283430944801, 'y': -1, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,038] Trial 65 finished with value: 126.89298404852701 and parameters: {'x': -8.825700201600268, 'y': 7, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,038] Trial 66 finished with value: 132.20610099150028 and parameters: {'x': -5.586242117157139, 'y': 1, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,038] Trial 67 finished with value: 168.63834478399184 and parameters: {'x': 2.153681681212859, 'y': -8, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,038] Trial 68 finished with value: 95.61165731508811 and parameters: {'x': 9.57139787675176, 'y': -2, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,039] Trial 69 finished with value: 103.91753736822044 and parameters: {'x': 4.787226479729201, 'y': 9, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,039] Trial 70 finished with value: 151.76253349766094 and parameters: {'x': 6.539306805591931, 'y': -3, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,039] Trial 71 finished with value: 120.0031920731484 and parameters: {'x': 4.359265084065019, 'y': -1, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,040] Trial 72 finished with value: 139.7271170985117 and parameters: {'x': 6.223111528689785, 'y': -1, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,040] Trial 73 finished with value: 205.15060963118572 and parameters: {'x': 8.315684555776855, 'y': -6, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,040] Trial 74 finished with value: 185.25160566296043 and parameters: {'x': -7.762190777284492, 'y': -5, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,041] Trial 75 finished with value: 6.451303281277658 and parameters: {'x': -1.5656638468322814, 'y': 2, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,041] Trial 76 finished with value: 180.26301408977702 and parameters: {'x': 5.591333838162143, 'y': 7, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,041] Trial 77 finished with value: 210.65823913209158 and parameters: {'x': 8.640499935309968, 'y': -6, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,042] Trial 78 finished with value: 116.00040865774398 and parameters: {'x': -0.02021528490962865, 'y': -4, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,042] Trial 79 finished with value: 107.08612722199605 and parameters: {'x': -2.467007746642893, 'y': 1, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,042] Trial 80 finished with value: 109.81259717278304 and parameters: {'x': 2.968601888563544, 'y': 1, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,043] Trial 81 finished with value: 117.01230984958462 and parameters: {'x': 1.0061360989372297, 'y': -4, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,043] Trial 82 finished with value: 91.80475015083394 and parameters: {'x': -3.2870579780152864, 'y': 9, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,043] Trial 83 finished with value: 59.31298559161134 and parameters: {'x': 3.211383750287613, 'y': -7, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,044] Trial 84 finished with value: 162.9886022191908 and parameters: {'x': -6.163489451535615, 'y': 5, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,044] Trial 85 finished with value: 84.40187567545824 and parameters: {'x': 8.966709300264966, 'y': -2, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,044] Trial 86 finished with value: 176.19446778266274 and parameters: {'x': 9.756765231502843, 'y': -9, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,045] Trial 87 finished with value: 119.0041972716557 and parameters: {'x': -1.733262032023923, 'y': -4, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,045] Trial 88 finished with value: 124.22405909665657 and parameters: {'x': -8.673180448754458, 'y': -7, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,045] Trial 89 finished with value: 203.29535276173016 and parameters: {'x': 7.368538034218876, 'y': -7, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,045] Trial 90 finished with value: 130.91412308357863 and parameters: {'x': -4.681252298646017, 'y': -3, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,046] Trial 91 finished with value: 58.60214113380503 and parameters: {'x': -7.042878753308552, 'y': -3, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,046] Trial 92 finished with value: 191.8266133376526 and parameters: {'x': -9.582620379502288, 'y': 0, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,046] Trial 93 finished with value: 217.54273199051067 and parameters: {'x': -6.045058477013326, 'y': 9, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,047] Trial 94 finished with value: 112.54877976219126 and parameters: {'x': 1.8838205228182598, 'y': -3, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,047] Trial 95 finished with value: 157.20431450640856 and parameters: {'x': 6.419058693173678, 'y': 4, 'z': 'a'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,047] Trial 96 finished with value: 184.3225401100039 and parameters: {'x': -9.128118103421095, 'y': -1, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,048] Trial 97 finished with value: 167.87325029155934 and parameters: {'x': 7.672890608601126, 'y': -3, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,048] Trial 98 finished with value: 129.6269227309907 and parameters: {'x': -8.10104454567377, 'y': 8, 'z': 'b'}. Best is trial 7 with value: 1.3358859059885442.
[I 2024-10-02 06:22:23,048] Trial 99 finished with value: 122.53932947663677 and parameters: {'x': -2.557211269456781, 'y': -4, 'z': 'c'}. Best is trial 7 with value: 1.3358859059885442.

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

Gallery generated by Sphinx-Gallery