### Install Optuna and OptunaHub Source: https://github.com/optuna/optunahub/blob/main/docs/source/tutorials_for_users/how_to_use_benchmarks.rst Installs the necessary Optuna and OptunaHub packages for using benchmarks. This is a prerequisite for all subsequent examples. ```console pip install optuna optunahub ``` -------------------------------- ### Install Optuna and Dashboard Packages Source: https://github.com/optuna/optunahub/blob/main/docs/source/tutorials_for_users/plot-in-optuna-dashboard.rst Installs the necessary Python packages for Optuna, Optunahub, and Optuna-Dashboard. This is a prerequisite for running the plotting example. ```console pip install optuna optunahub optuna-dashboard ``` -------------------------------- ### Install OptunaHub Source: https://context7.com/optuna/optunahub/llms.txt Instructions for installing the OptunaHub library using pip or conda. ```bash # Using pip pip install optunahub # Using conda conda install -c conda-forge optunahub ``` -------------------------------- ### Install Benchmark Dependencies Source: https://github.com/optuna/optunahub/blob/main/docs/source/tutorials_for_users/how_to_use_benchmarks.rst Install the required optproblems and diversipy packages via pip to enable benchmark functionality. ```console pip install -U optproblems diversipy ``` -------------------------------- ### Install OptunaHub using pip Source: https://github.com/optuna/optunahub/blob/main/README.md This command installs the OptunaHub Python library from the Python Package Index (PyPI). It supports Linux, macOS, and Windows platforms. ```sh pip install optunahub ``` -------------------------------- ### Install OptunaHub Package Source: https://github.com/optuna/optunahub/blob/main/docs/source/index.rst Instructions for installing the optunahub package using pip or conda. This is a prerequisite for using OptunaHub's functionalities. ```shell pip install optunahub ``` ```shell conda install -c conda-forge optunahub ``` -------------------------------- ### Load Module from OptunaHub Registry Source: https://context7.com/optuna/optunahub/llms.txt Demonstrates how to import and load packages (samplers, pruners, visualizations, benchmarks) from the OptunaHub registry using `optunahub.load_module`. Includes examples for basic usage, loading specific versions, from third-party repositories, forcing reloads, and using authentication for private repositories. ```python import optuna import optunahub # Basic usage: Load AutoSampler from OptunaHub module = optunahub.load_module(package="samplers/auto_sampler") def objective(trial: optuna.Trial) -> float: x = trial.suggest_float("x", -5, 5) y = trial.suggest_float("y", -5, 5) return x**2 + y**2 # Use the loaded sampler study = optuna.create_study(sampler=module.AutoSampler()) study.optimize(objective, n_trials=100) print(f"Best value: {study.best_value}, Best params: {study.best_trial.params}") # Load from a specific version/commit module = optunahub.load_module( package="samplers/simulated_annealing", ref="v1.0.0" # Git branch, tag, or commit SHA ) # Load from a fork or third-party repository module = optunahub.load_module( package="samplers/my_custom_sampler", repo_owner="your_github_username", repo_name="optunahub-registry", ref="feature-branch" ) # Force re-download instead of using cached version module = optunahub.load_module( package="samplers/auto_sampler", force_reload=True ) # Load from private repository with GitHub authentication from github import Auth auth = Auth.Token("your_github_token") module = optunahub.load_module( package="samplers/private_sampler", repo_owner="your_org", repo_name="private-registry", auth=auth ) ``` -------------------------------- ### Load and Use OptunaHub Package in Python Source: https://github.com/optuna/optunahub/blob/main/docs/source/index.rst Example of loading a package, specifically AutoSampler from samplers/auto_sampler, from the OptunaHub registry and using it to create an Optuna study. This demonstrates how to integrate external optimization algorithms into Optuna workflows. ```python import optuna import optunahub def objective(trial: optuna.Trial) -> float: x = trial.suggest_float("x", -5, 5) y = trial.suggest_float("y", -5, 5) return x**2 + y**2 mod = optunahub.load_module("samplers/auto_sampler") study = optuna.create_study(sampler=mod.AutoSampler()) study.optimize(objective, n_trials=10) print(study.best_trial.value, study.best_trial.params) ``` -------------------------------- ### Install OptunaHub using conda Source: https://github.com/optuna/optunahub/blob/main/README.md This command installs the OptunaHub Python library from the conda-forge channel. It is an alternative installation method for users who prefer using Conda package manager. ```sh conda install -c conda-forge optunahub ``` -------------------------------- ### Install COCO Experiment Library Source: https://github.com/optuna/optunahub/blob/main/docs/source/tutorials_for_users/how_to_use_benchmarks.rst Installs the COCO (Comparing Continuous Optimizers) experiment library, which is required for using the black-box optimization benchmarking (bbob) test suite. ```console pip install coco-experiment ``` -------------------------------- ### Implement Custom Random Sampler with SimpleBaseSampler in Python Source: https://context7.com/optuna/optunahub/llms.txt Demonstrates creating a custom random sampler by inheriting from optunahub.samplers.SimpleBaseSampler. This approach simplifies sampler implementation by requiring only the `sample_relative` method. The example shows how to handle different distribution types and provides usage with both automatic and fixed search space inference. ```python from __future__ import annotations from typing import Any import numpy as np import optuna import optunahub class MyRandomSampler(optunahub.samplers.SimpleBaseSampler): """A simple random sampler implementation.""" def __init__( self, search_space: dict[str, optuna.distributions.BaseDistribution] | None = None, seed: int | None = None ) -> None: super().__init__(search_space, seed) self._rng = np.random.RandomState(seed) def sample_relative( self, study: optuna.study.Study, trial: optuna.trial.FrozenTrial, search_space: dict[str, optuna.distributions.BaseDistribution], ) -> dict[str, Any]: if not search_space: return {} params = {} for name, dist in search_space.items(): if isinstance(dist, optuna.distributions.FloatDistribution): params[name] = self._rng.uniform(dist.low, dist.high) elif isinstance(dist, optuna.distributions.IntDistribution): params[name] = self._rng.randint(dist.low, dist.high + 1) elif isinstance(dist, optuna.distributions.CategoricalDistribution): params[name] = dist.choices[self._rng.randint(len(dist.choices))] return params # Use with automatic search space inference def objective(trial: optuna.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 sampler = MyRandomSampler(seed=42) study = optuna.create_study(sampler=sampler) study.optimize(objective, n_trials=100) print(f"Best params: {study.best_params}, Best value: {study.best_value}") # Use with fixed search space for better performance sampler = MyRandomSampler( search_space={ "x": optuna.distributions.FloatDistribution(-10, 10), "y": optuna.distributions.IntDistribution(-10, 10), "z": optuna.distributions.CategoricalDistribution(["a", "b", "c"]), }, seed=42 ) study = optuna.create_study(sampler=sampler) study.optimize(objective, n_trials=100) ``` -------------------------------- ### Implement Constrained Optimization with ConstrainedMixin Source: https://context7.com/optuna/optunahub/llms.txt Shows how to use ConstrainedMixin to define constraints for optimization problems. It includes examples for both multi-objective and single-objective problems, integrating with the TPESampler to handle feasibility. ```python class BinhAndKorn(ConstrainedMixin, BaseProblem): def evaluate(self, params: dict[str, float]) -> tuple[float, float]: x, y = params["x"], params["y"] return 4 * x**2 + 4 * y**2, (x - 5)**2 + (y - 5)**2 def evaluate_constraints(self, params: dict[str, float]) -> tuple[float, float]: x, y = params["x"], params["y"] return (x - 5)**2 + y**2 - 25, -((x - 8)**2) - (y + 3)**2 + 7.7 problem = BinhAndKorn() sampler = optuna.samplers.TPESampler(constraints_func=problem.constraints_func) study = optuna.create_study(sampler=sampler, directions=problem.directions) study.optimize(problem, n_trials=100) ``` -------------------------------- ### Run WFG Benchmark with Optuna Source: https://github.com/optuna/optunahub/blob/main/docs/source/tutorials_for_users/how_to_use_benchmarks.rst Load a WFG benchmark from OptunaHub, define an Optuna study with a TPE sampler, optimize the objective function, and visualize the Pareto front. ```python import optuna import optunahub wfg = optunahub.load_module("benchmarks/wfg") wfg4 = wfg.Problem(function_id=4, n_objectives=2, dimension=3, k=1) study = optuna.create_study( study_name="TPESampler", sampler=optuna.samplers.TPESampler(seed=42), directions=wfg4.directions ) study.optimize(wfg4, n_trials=1000) optuna.visualization.plot_pareto_front(study).show() ``` -------------------------------- ### Optimize Constrained BBOB Problem with Optuna Source: https://github.com/optuna/optunahub/blob/main/docs/source/tutorials_for_users/how_to_use_benchmarks.rst Illustrates optimizing a constrained benchmark problem from BBOB. It shows how to load a constrained module, define the problem, and configure the Optuna sampler with the `constraints_func` argument to handle problem constraints during optimization. ```python import optuna import optunahub import matplotlib.pyplot as plt bbob_constrained = optunahub.load_module("benchmarks/bbob_constrained") constrained_sphere2d = bbob_constrained.Problem(function_id=1, dimension=2, instance_id=1) study = optuna.create_study( sampler=optuna.samplers.TPESampler( constraints_func=constrained_sphere2d.constraints_func, seed=42 ), directions=constrained_sphere2d.directions ) study.optimize(constrained_sphere2d, n_trials=100) optuna.visualization.plot_optimization_history(study).show() plt.show() ``` -------------------------------- ### Launch Optuna-Dashboard Source: https://github.com/optuna/optunahub/blob/main/docs/source/tutorials_for_users/plot-in-optuna-dashboard.rst Command to launch the Optuna-Dashboard, which will serve the visualizations including the plots saved in the previous step. It requires the path to the Optuna storage database. ```console optuna-dashboard sqlite:///db.sqlite3 ``` -------------------------------- ### Load and use an OptunaHub module in Python Source: https://github.com/optuna/optunahub/blob/main/README.md This Python code demonstrates how to load a module, such as an optimization sampler, from OptunaHub and integrate it into an Optuna study. It defines an objective function, loads the AutoSampler module, creates a study with the loaded sampler, and runs the optimization. ```python import optuna import optunahub def objective(trial: optuna.Trial) -> float: x = trial.suggest_float("x", -5, 5) y = trial.suggest_float("y", -5, 5) return x**2 + y**2 module = optunahub.load_module(package="samplers/auto_sampler") study = optuna.create_study(sampler=module.AutoSampler()) study.optimize(objective, n_trials=10) print(study.best_trial.value, study.best_trial.params) ``` -------------------------------- ### Environment Configuration Source: https://context7.com/optuna/optunahub/llms.txt Configure OptunaHub behavior using environment variables for cache management and analytics tracking. ```APIDOC ## Environment Configuration ### Description Configure the OptunaHub environment by setting specific environment variables before initializing the library. ### Configuration Variables - **OPTUNAHUB_CACHE_HOME** (string) - Optional - Path to a custom directory for caching downloaded packages. Defaults to ~/.cache/optunahub/. - **OPTUNAHUB_NO_ANALYTICS** (string) - Optional - Set to '1' to disable anonymous analytics reporting. ### Usage Example import os os.environ["OPTUNAHUB_CACHE_HOME"] = "/path/to/custom/cache" os.environ["OPTUNAHUB_NO_ANALYTICS"] = "1" import optunahub ``` -------------------------------- ### Optimize BBOB Problem with SciPy Source: https://github.com/optuna/optunahub/blob/main/docs/source/tutorials_for_users/how_to_use_benchmarks.rst Demonstrates optimizing a BBOB problem using SciPy's minimize function. It shows how to use the `evaluate` method of the benchmark problem with parameters like initial solution, bounds, and dimension, highlighting flexibility beyond Optuna's direct optimization. ```python import optunahub import scipy bbob = optunahub.load_module("benchmarks/bbob") sphere2d = bbob.Problem(function_id=1, dimension=2, instance_id=1) result = scipy.optimize.minimize( fun=lambda x: sphere2d.evaluate({f"x{d}": x[d] for d in range(sphere2d.dimension)}), x0=sphere2d.initial_solution, bounds=scipy.optimize.Bounds( lb=sphere2d.lower_bounds, ub=sphere2d.upper_bounds ) ) ``` -------------------------------- ### Optimize BBOB Problem with Optuna Source: https://github.com/optuna/optunahub/blob/main/docs/source/tutorials_for_users/how_to_use_benchmarks.rst Loads the BBOB benchmark module, defines a specific problem (sphere function in 2D), creates an Optuna study with TPE sampler, optimizes the problem, and visualizes the optimization history. This demonstrates the core usage of OptunaHub benchmarks with Optuna. ```python import optuna import optunahub bbob = optunahub.load_module("benchmarks/bbob") sphere2d = bbob.Problem(function_id=1, dimension=2, instance_id=1) study = optuna.create_study(directions=sphere2d.directions, sampler=optuna.samplers.TPESampler(seed=42)) study.optimize(sphere2d, n_trials=100) optuna.visualization.plot_optimization_history(study).show() ``` -------------------------------- ### Load Module from Local Directory Source: https://context7.com/optuna/optunahub/llms.txt Illustrates how to use `optunahub.load_local_module` to import packages from a local directory, which is useful for developing and testing custom algorithms before publishing them to OptunaHub. The loaded package is accessible via `optunahub_registry.package.`. ```python import optuna import optunahub # Load a local package during development module = optunahub.load_local_module( package="samplers/my_new_sampler", registry_root="/path/to/optunahub-registry/package" ) # Use the locally loaded sampler def objective(trial: optuna.Trial) -> float: x = trial.suggest_float("x", -10, 10) return x**2 sampler = module.MyNewSampler() study = optuna.create_study(sampler=sampler) study.optimize(objective, n_trials=50) # Test before creating a pull request module = optunahub.load_local_module( package="visualization/my_plot", registry_root="/home/user/optunahub-registry/package" ) fig = module.plot_custom(study) fig.show() ``` -------------------------------- ### Configure OptunaHub Environment Variables Source: https://context7.com/optuna/optunahub/llms.txt Configures OptunaHub settings such as custom cache directories and disabling analytics. These settings should be applied before loading modules. ```python import os import optunahub os.environ["OPTUNAHUB_CACHE_HOME"] = "/path/to/custom/cache" os.environ["OPTUNAHUB_NO_ANALYTICS"] = "1" module = optunahub.load_module(package="samplers/auto_sampler") ``` -------------------------------- ### Define Dynamic Search Space Problems Source: https://context7.com/optuna/optunahub/llms.txt Demonstrates how to create a problem with a conditional search space where parameters are suggested based on previous values. This is useful for scenarios where the search space depends on the current trial's state. ```python class DynamicSearchSpaceProblem(BaseProblem): def __call__(self, trial: optuna.Trial) -> float: x = trial.suggest_float("x", -5, 5) if x < 0: y = trial.suggest_float("y", -5, 5) return x**2 + y return x**2 @property def directions(self) -> list[optuna.study.StudyDirection]: return [optuna.study.StudyDirection.MINIMIZE] dynamic_problem = DynamicSearchSpaceProblem() study = optuna.create_study(directions=dynamic_problem.directions) study.optimize(dynamic_problem, n_trials=50) ``` -------------------------------- ### Define N-Dimensional Sphere Benchmark Problem with BaseProblem in Python Source: https://context7.com/optuna/optunahub/llms.txt Illustrates the implementation of a configurable N-dimensional sphere function benchmark using optunahub.benchmarks.BaseProblem. The class dynamically creates the search space based on the specified dimension, making it flexible for various N-dimensional optimization tasks. ```python from __future__ import annotations import optuna from optunahub.benchmarks import BaseProblem class SphereND(BaseProblem): """N-dimensional sphere function with configurable dimensions.""" def __init__(self, dim: int) -> None: self.dim = dim @property def search_space(self) -> dict[str, optuna.distributions.BaseDistribution]: return { f"x{i}": optuna.distributions.FloatDistribution(low=-5, high=5) for i in range(self.dim) } @property def directions(self) -> list[optuna.study.StudyDirection]: return [optuna.study.StudyDirection.MINIMIZE] def evaluate(self, params: dict[str, float]) -> float: return sum(params[f"x{i}"]**2 for i in range(self.dim)) ``` -------------------------------- ### Constrained Optimization with ConstrainedMixin Source: https://context7.com/optuna/optunahub/llms.txt This section explains how to implement constrained optimization problems by inheriting from ConstrainedMixin and defining the evaluate_constraints method. ```APIDOC ## Constrained Optimization using ConstrainedMixin ### Description Use the ConstrainedMixin to define constraints for optimization problems. The evaluate_constraints method must return a tuple of values where each value <= 0 is considered feasible. ### Method Class Implementation ### Parameters #### Methods - **evaluate_constraints(params: dict[str, float])** (tuple) - Required - Returns a tuple of constraints. A constraint is satisfied if the returned value is <= 0. ### Request Example class MyProblem(ConstrainedMixin, BaseProblem): def evaluate_constraints(self, params): return (params['x'] + params['y'] - 1,) ### Response #### Success Response - **constraints_func** (callable) - A function compatible with Optuna samplers (e.g., TPESampler) to enforce constraints during optimization. ``` -------------------------------- ### Define 2D Sphere Benchmark Problem with BaseProblem in Python Source: https://context7.com/optuna/optunahub/llms.txt Shows how to implement a 2-dimensional sphere function as a benchmark optimization problem by inheriting from optunahub.benchmarks.BaseProblem. This class defines the search space, optimization directions, and the evaluation function, allowing it to be directly used with Optuna studies. ```python from __future__ import annotations import optuna from optunahub.benchmarks import BaseProblem class Sphere2D(BaseProblem): """2-dimensional sphere function benchmark.""" @property def search_space(self) -> dict[str, optuna.distributions.BaseDistribution]: return { "x0": optuna.distributions.FloatDistribution(low=-5, high=5), "x1": optuna.distributions.FloatDistribution(low=-5, high=5), } @property def directions(self) -> list[optuna.study.StudyDirection]: return [optuna.study.StudyDirection.MINIMIZE] def evaluate(self, params: dict[str, float]) -> float: return params["x0"]**2 + params["x1"]**2 # Use the benchmark problem sphere = Sphere2D() study = optuna.create_study(directions=sphere.directions) study.optimize(sphere, n_trials=100) print(f"Best value: {study.best_value}, Best params: {study.best_trial.params}") ``` -------------------------------- ### BaseProblem Source: https://context7.com/optuna/optunahub/llms.txt A base class for implementing benchmark optimization problems. Provides a standardized interface for defining search spaces, optimization directions, and evaluation functions. ```APIDOC ## optunahub.benchmarks.BaseProblem A base class for implementing benchmark optimization problems. Provides a standardized interface for defining search spaces, optimization directions, and evaluation functions that can be directly used with Optuna studies. ### Example Usage (Sphere2D) ```python from __future__ import annotations import optuna from optunahub.benchmarks import BaseProblem class Sphere2D(BaseProblem): """2-dimensional sphere function benchmark.""" @property def search_space(self) -> dict[str, optuna.distributions.BaseDistribution]: return { "x0": optuna.distributions.FloatDistribution(low=-5, high=5), "x1": optuna.distributions.FloatDistribution(low=-5, high=5), } @property def directions(self) -> list[optuna.study.StudyDirection]: return [optuna.study.StudyDirection.MINIMIZE] def evaluate(self, params: dict[str, float]) -> float: return params["x0"]**2 + params["x1"]**2 # Use the benchmark problem sphere = Sphere2D() study = optuna.create_study(directions=sphere.directions) study.optimize(sphere, n_trials=100) print(f"Best value: {study.best_value}, Best params: {study.best_trial.params}") ``` ### Example Usage (SphereND) ```python from __future__ import annotations import optuna from optunahub.benchmarks import BaseProblem class SphereND(BaseProblem): """N-dimensional sphere function with configurable dimensions.""" def __init__(self, dim: int) -> None: self.dim = dim @property def search_space(self) -> dict[str, optuna.distributions.BaseDistribution]: return { f"x{i}": optuna.distributions.FloatDistribution(low=-5, high=5) for i in range(self.dim) } @property def directions(self) -> list[optuna.study.StudyDirection]: return [optuna.study.StudyDirection.MINIMIZE] def evaluate(self, params: dict[str, float]) -> float: return sum(params[f"x{i}"]**2 for i in range(self.dim)) ``` ``` -------------------------------- ### Generate and Save Plots for Optuna-Dashboard Source: https://github.com/optuna/optunahub/blob/main/docs/source/tutorials_for_users/plot-in-optuna-dashboard.rst This Python script demonstrates loading a benchmark problem (WFG), creating multiple Optuna studies with different samplers, optimizing them, and then plotting the Pareto front for these studies. The generated plot is then saved for display in Optuna-Dashboard using `save_plotly_graph_object`. ```python import optuna import optunahub from optuna_dashboard import save_plotly_graph_object wfg = optunahub.load_module("benchmarks/wfg") wfg4 = wfg.Problem(function_id=4, n_objectives=2, dimension=3, k=1) samplers = [ optuna.samplers.RandomSampler(), optuna.samplers.TPESampler(), optuna.samplers.NSGAIISampler(), ] studies = [] for sampler in samplers: study = optuna.create_study( sampler=sampler, study_name=sampler.__class__.__name__, directions=wfg4.directions, storage="sqlite:///db.sqlite3", ) study.optimize(wfg4, n_trials=100) studies.append(study) m = optunahub.load_module( "visualization/plot_pareto_front_multi" ) fig = m.plot_pareto_front(studies) for study in studies: save_plotly_graph_object(study, fig) ``` -------------------------------- ### SimpleBaseSampler Source: https://context7.com/optuna/optunahub/llms.txt A base class for implementing custom samplers with a simplified interface. Developers only need to implement the `sample_relative` method. ```APIDOC ## optunahub.samplers.SimpleBaseSampler A base class for implementing custom samplers with simplified interface. Instead of implementing the complex `BaseSampler` interface from Optuna, developers can inherit from `SimpleBaseSampler` and only implement the `sample_relative` method to create fully functional optimization algorithms. ### Example Usage ```python from __future__ import annotations from typing import Any import numpy as np import optuna import optunahub class MyRandomSampler(optunahub.samplers.SimpleBaseSampler): """A simple random sampler implementation.""" def __init__( self, search_space: dict[str, optuna.distributions.BaseDistribution] | None = None, seed: int | None = None ) -> None: super().__init__(search_space, seed) self._rng = np.random.RandomState(seed) def sample_relative( self, study: optuna.study.Study, trial: optuna.trial.FrozenTrial, search_space: dict[str, optuna.distributions.BaseDistribution], ) -> dict[str, Any]: if not search_space: return {} params = {} for name, dist in search_space.items(): if isinstance(dist, optuna.distributions.FloatDistribution): params[name] = self._rng.uniform(dist.low, dist.high) elif isinstance(dist, optuna.distributions.IntDistribution): params[name] = self._rng.randint(dist.low, dist.high + 1) elif isinstance(dist, optuna.distributions.CategoricalDistribution): params[name] = dist.choices[self._rng.randint(len(dist.choices))] return params # Use with automatic search space inference def objective(trial: optuna.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 sampler = MyRandomSampler(seed=42) study = optuna.create_study(sampler=sampler) study.optimize(objective, n_trials=100) print(f"Best params: {study.best_params}, Best value: {study.best_value}") # Use with fixed search space for better performance sampler = MyRandomSampler( search_space={ "x": optuna.distributions.FloatDistribution(-10, 10), "y": optuna.distributions.IntDistribution(-10, 10), "z": optuna.distributions.CategoricalDistribution(["a", "b", "c"]), }, seed=42 ) study = optuna.create_study(sampler=sampler) study.optimize(objective, n_trials=100) ``` ``` -------------------------------- ### BaseProblem Class Source: https://github.com/optuna/optunahub/blob/main/docs/source/benchmarks.rst Overview of the BaseProblem class used for defining optimization benchmarks. ```APIDOC ## BaseProblem ### Description The `BaseProblem` class serves as the foundational interface for all benchmark problems in OptunaHub. It provides the necessary structure for defining objective functions and search spaces. ### Method N/A (Class Definition) ### Endpoint optunahub.benchmarks.BaseProblem ### Parameters #### Attributes - **objective** (callable) - Required - The function to be optimized. - **search_space** (dict) - Required - The definition of the parameter search space. ``` -------------------------------- ### SimpleBaseSampler Source: https://github.com/optuna/optunahub/blob/main/docs/source/samplers.rst Details about the SimpleBaseSampler class. ```APIDOC ## SimpleBaseSampler ### Description This is a base sampler class for OptunaHub samplers. It provides fundamental functionalities that other samplers can inherit from. ### Class `optunahub.samplers.SimpleBaseSampler` ### Parameters This class does not have direct parameters for instantiation. Parameters are typically handled by subclasses or during the sampling process. ### Methods Refer to the OptunaHub documentation for specific methods inherited or implemented by `SimpleBaseSampler`. ### Example Usage ```python # Example of how a subclass might use SimpleBaseSampler from optunahub.samplers import SimpleBaseSampler class CustomSampler(SimpleBaseSampler): def __init__(self, **kwargs): super().__init__(**kwargs) # Additional initialization for CustomSampler def sample_trial(self, study, trial): # Implementation of sampling logic pass # Instantiate and use the custom sampler # custom_sampler = CustomSampler() ``` ### Inheritance This class is intended to be inherited by other sampler classes within OptunaHub. ``` -------------------------------- ### ConstrainedMixin Class Source: https://github.com/optuna/optunahub/blob/main/docs/source/benchmarks.rst Overview of the ConstrainedMixin class for handling constrained optimization problems. ```APIDOC ## ConstrainedMixin ### Description The `ConstrainedMixin` class provides additional functionality for problems that involve constraints, allowing users to define feasibility conditions alongside the objective function. ### Method N/A (Class Definition) ### Endpoint optunahub.benchmarks.ConstrainedMixin ### Parameters #### Attributes - **constraints** (list) - Required - A list of constraint functions that must be satisfied. ``` -------------------------------- ### OptunaHub Paper Citation in BibTeX Source: https://github.com/optuna/optunahub/blob/main/docs/source/index.rst The BibTeX format for citing the OptunaHub paper, useful for academic and research purposes when referencing the platform in publications. ```bibtex @article{ozaki2025optunahub, title={{OptunaHub}: A Platform for Black-Box Optimization}, author={Ozaki, Yoshihiko and Watanabe, Shuhei and Yanase, Toshihiko}, journal={arXiv preprint arXiv:2510.02798}, year={2025} } ``` -------------------------------- ### Opt-out of Anonymous Analytics Source: https://github.com/optuna/optunahub/blob/main/docs/source/faq.rst Disables anonymous usage data collection by setting an environment variable. This should be set in your shell environment before running OptunaHub. ```shell export OPTUNAHUB_NO_ANALYTICS=1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.