
    (^i              	         d dl mZ d dlmZ d dlmZ d dlmZ d dlZd dlmZ d dl	Z	d dl
mZ d dl
mZ d d	l
mZ d d
l
mZ d dl
mZ d dl
mZ d dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dl m!Z! d dl"m#Z# d dl$m%Z% d dl$m&Z& d dl'm(Z( d dl)m*Z* d dl)m+Z+ d dl,m-Z- d dl.m/Z/ d dl0m1Z1 d dl2m3Z3 d d l4m5Z5 d d!l4m6Z6 d d"l7m8Z8 d d#l7m9Z9  e!d$      Z:erd d%l;m<Z< d d&l7m=Z= d d'l7m>Z> ed(gee?ee?   f   f   Z@d)ZA ej                  eC      ZD G d* d+e	j                        ZF G d, d-      ZG eg d.d/d01      dddddd2dd3	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dBd6       ZH eg d7d/d01      ddd8	 	 	 	 	 	 	 	 	 dCd9       ZI ed5d4gd/d01      	 	 	 	 	 	 dDd:       ZJ eg d;d<d/d0=      dd>	 	 	 	 	 	 	 	 	 dEd?       ZK	 dF	 	 	 	 	 dGd@ZLdHdAZMy)I    )annotations)	Container)Iterable)MappingN)Real)Any)Callable)cast)Sequence)TYPE_CHECKING)Union)
exceptions)logging)pruners)samplers)storages)convert_positional_args)deprecated_func)experimental_func)_LazyImport)JSONSerializable)-_convert_old_distribution_to_new_distribution)BaseDistribution)is_heartbeat_enabled)_CONSTRAINTS_KEY)_get_feasible_trials)_get_pareto_front_trials)	_optimize)StudyDirection)StudySummary)_get_frozen_trial)_tell_with_warning)create_trial)
TrialStatezoptuna.study._dataframe)pd)FrozenTrial)Trialr'   zstudy:metric_namesc                  *    e Zd ZU dZded<   dZded<   y)_ThreadLocalStudyAttributeFboolin_optimize_loopNzlist[FrozenTrial] | Nonecached_all_trials)__name__
__module____qualname__r+   __annotations__r,        S/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/optuna/study/study.pyr)   r)   >   s    "d"26/6r2   r)   c                  r   e Zd ZdZ	 	 d%	 	 	 	 	 	 	 	 	 d&dZd'dZd(dZed)d       Zed*d       Z	ed+d       Z
ed,d	       Zed-d
       Zed.d       Zed,d       Z	 	 d/	 	 	 	 	 d0dZ	 	 	 d1	 	 	 	 	 	 	 d2dZd3dZed)d       Ze edd      d)d              Zed4d       Z	 	 	 	 	 	 	 d5	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d6dZd7d8dZ	 	 	 d9	 	 	 	 	 	 	 	 	 d:dZd;dZ edd      d;d       Z	 	 d<	 	 	 	 	 d=dZd>dZ	 	 d?	 	 	 	 	 	 	 d@dZdAdZdBdZ e d      dCd        Z!dDd!Z"dEd"Z#dFd#Z$	 	 	 	 	 	 	 	 dGd$Z%y)HStudya  A study corresponds to an optimization task, i.e., a set of trials.

    This object provides interfaces to run a new :class:`~optuna.trial.Trial`, access trials'
    history, set/get user-defined attributes of the study itself.

    Note that the direct use of this constructor is not recommended.
    To create and load a study, please refer to the documentation of
    :func:`~optuna.study.create_study` and :func:`~optuna.study.load_study` respectively.

    Nc                F   || _         t        j                  |      }|j                  |      }|| _        || _        |j                  |      | _        |xs t        j                         | _
        |xs t        j                         | _        t               | _        d| _        y NF)
study_namer   get_storageget_study_id_from_name	_study_id_storageget_study_directions_directionsr   
TPESamplersamplerr   MedianPrunerprunerr)   _thread_local
_stop_flag)selfr8   storager@   rB   study_ids         r3   __init__zStudy.__init__O   s     %&&w/11*=!"77A7("5"5"76 4 4 679r2   c                @    | j                   j                         }|d= |S )NrC   )__dict__copyrE   states     r3   __getstate__zStudy.__getstate__c   s!    ""$/"r2   c                X    | j                   j                  |       t               | _        y N)rJ   updater)   rC   rL   s     r3   __setstate__zStudy.__setstate__h   s    U#79r2   c                .    | j                   j                  S )zReturn parameters of the best trial in the study.

        .. note::
            This feature can only be used for single-objective optimization.

        Returns:
            A dictionary containing parameters of the best trial.

        )
best_trialparamsrE   s    r3   best_paramszStudy.best_paramsl   s     %%%r2   c                :    | j                   j                  }|J |S )zReturn the best objective value in the study.

        .. note::
            This feature can only be used for single-objective optimization.

        Returns:
            A float representing the best objective value.

        )rT   value)rE   
best_values     r3   rZ   zStudy.best_valuez   s%     __**
%%%r2   c                &    | j                  d      S )a  Return the best trial in the study.

        .. note::
            This feature can only be used for single-objective optimization.
            If your study is multi-objective,
            use :attr:`~optuna.study.Study.best_trials` instead.

        Returns:
            A :class:`~optuna.trial.FrozenTrial` object of the best trial.

        .. seealso::
            The :ref:`reuse_best_trial` tutorial provides a detailed example of how to use this
            method.

        Tdeepcopy)_get_best_trialrV   s    r3   rT   zStudy.best_trial   s    " ##T#22r2   c                d    | j                  d      }t        d |D              }t        | |      S )a  Return trials located at the Pareto front in the study.

        A trial is located at the Pareto front if there are no trials that dominate the trial.
        It's called that a trial ``t0`` dominates another trial ``t1`` if
        ``all(v0 <= v1) for v0, v1 in zip(t0.values, t1.values)`` and
        ``any(v0 < v1) for v0, v1 in zip(t0.values, t1.values)`` are held.

        Returns:
            A list of :class:`~optuna.trial.FrozenTrial` objects.
        Fr\   c              3  @   K   | ]  }t         |j                  v   y wrP   )r   system_attrs).0trials     r3   	<genexpr>z$Study.best_trials.<locals>.<genexpr>   s     Z%.%2D2DDZs   )consider_constraint)
get_trialsanyr   )rE   trialsis_constraineds      r3   best_trialszStudy.best_trials   s2     %0ZSYZZ'.QQr2   c                V    | j                         rt        d      | j                  d   S )aH  Return the direction of the study.

        .. note::
            This feature can only be used for single-objective optimization.
            If your study is multi-objective,
            use :attr:`~optuna.study.Study.directions` instead.

        Returns:
            A :class:`~optuna.study.StudyDirection` object.

        zA single direction cannot be retrieved from a multi-objective study. Consider using Study.directions to retrieve a list containing all directions.r   )_is_multi_objectiveRuntimeError
directionsrV   s    r3   	directionzStudy.direction   s4     ##%W 
 q!!r2   c                    | j                   S )zReturn the directions of the study.

        Returns:
            A list of :class:`~optuna.study.StudyDirection` objects.
        )r>   rV   s    r3   rn   zStudy.directions   s     r2   c                (    | j                  dd      S )ar  Return all trials in the study.

        The returned trials are ordered by trial number.

        This is a short form of ``self.get_trials(deepcopy=True, states=None)``.

        Returns:
            A list of :class:`~optuna.trial.FrozenTrial` objects.

            .. seealso::
                See :func:`~optuna.study.Study.get_trials` for related method.

        TNr]   states)rf   rV   s    r3   rh   zStudy.trials   s      T::r2   c                *    | j                  ||d      S )af  Return all trials in the study.

        The returned trials are ordered by trial number.

        .. seealso::
            See :attr:`~optuna.study.Study.trials` for related property.

        Example:
            .. testcode::

                import optuna


                def objective(trial):
                    x = trial.suggest_float("x", -1, 1)
                    return x**2


                study = optuna.create_study()
                study.optimize(objective, n_trials=3)

                trials = study.get_trials()
                assert len(trials) == 3
        Args:
            deepcopy:
                Flag to control whether to apply ``copy.deepcopy()`` to the trials.
                Note that if you set the flag to :obj:`False`, you shouldn't mutate
                any fields of the returned trial. Otherwise the internal state of
                the study may corrupt and unexpected behavior may happen.
            states:
                Trial states to filter on. If :obj:`None`, include all states.

        Returns:
            A list of :class:`~optuna.trial.FrozenTrial` objects.
        F)	use_cache)_get_trials)rE   r]   rs   s      r3   rf   zStudy.get_trials   s    P &EBBr2   c                   |r| j                   j                  6| j                  j                  | j                  d      | j                   _        | j                   j                  }||D cg c]  }|j
                  |v s| }}n|}|rt        j                  |      S |S | j                  j                  | j                  ||      S c c}w )NFr\   rr   )rC   r,   r<   get_all_trialsr;   rM   rK   r]   )rE   r]   rs   ru   rh   tfiltered_trialss          r3   rv   zStudy._get_trials  s     !!33;7;}}7S7SNNU 8T 8""4 ''99F!.4"J68I1"J"J"(5=4==1R?R}}++DNNXV\+]] #Ks   +C	?C	c                8   | j                         rt        d      | j                  j                  | j                        }|j
                  j                  t              }|t        |D cg c]  }|dkD  	 c}      r| j                  dt        j                  g      }t        |      }t        |      dk(  rt        d      | j                  t         j"                  k(  rt%        |d       }nt'        |d	       }|rt)        j*                  |      S |S c c}w )
a  Return the best trial in the study.

        Args:
            deepcopy:
                Flag to control whether to apply ``copy.deepcopy()`` to the trial.
                If :obj:`False`, returns the trial without deep copying for better performance.
                Note that if you set this to :obj:`False`, you shouldn't mutate any fields
                of the returned trial.

        Returns:
            A :class:`~optuna.trial.FrozenTrial` object of the best trial.
        zA single best trial cannot be retrieved from a multi-objective study. Consider using Study.best_trials to retrieve a list containing the best trials.        Frr   r   z%No feasible trials are completed yet.c                6    t        t        | j                        S rP   r
   floatrY   ry   s    r3   <lambda>z'Study._get_best_trial.<locals>.<lambda>@      UAGG@T r2   keyc                6    t        t        | j                        S rP   r~   r   s    r3   r   z'Study._get_best_trial.<locals>.<lambda>B  r   r2   )rl   rm   r<   get_best_trialr;   ra   getr   rg   rf   r$   COMPLETEr   len
ValueErrorro   r   MAXIMIZEmaxminrK   r]   )rE   r]   rT   constraintsxcomplete_trialsfeasible_trialss          r3   r^   zStudy._get_best_trial!  s     ##%Y 
 ]]11$..A

 !--112BC"s[+IAG+I'J"ooujFYFYEZo[O2?CO?#q( !HII~~!8!88 6TU
 6TU
,4t}}Z(D*D ,Js   +Dc                r    t        j                  | j                  j                  | j                              S )a  Return user attributes.

        .. seealso::

            See :func:`~optuna.study.Study.set_user_attr` for related method.

        Example:

            .. testcode::

                import optuna


                def objective(trial):
                    x = trial.suggest_float("x", 0, 1)
                    y = trial.suggest_float("y", 0, 1)
                    return x**2 + y**2


                study = optuna.create_study()

                study.set_user_attr("objective function", "quadratic function")
                study.set_user_attr("dimensions", 2)
                study.set_user_attr("contributors", ["Akiba", "Sano"])

                assert study.user_attrs == {
                    "objective function": "quadratic function",
                    "dimensions": 2,
                    "contributors": ["Akiba", "Sano"],
                }

        Returns:
            A dictionary containing all user attributes.
        )rK   r]   r<   get_study_user_attrsr;   rV   s    r3   
user_attrszStudy.user_attrsF  s'    J }}T]]??OPPr2   z3.1.05.0.0c                r    t        j                  | j                  j                  | j                              S )zoReturn system attributes.

        Returns:
            A dictionary containing all system attributes.
        )rK   r]   r<   get_study_system_attrsr;   rV   s    r3   ra   zStudy.system_attrsm  s&     }}T]]AA$..QRRr2   c                r    | j                   j                  | j                        j                  t              S )a  Return metric names.

        .. note::
            Use :meth:`~optuna.study.Study.set_metric_names` to set the metric names first.

        Returns:
            A list with names for each dimension of the returned values of the objective function.
        )r<   r   r;   r   _SYSTEM_ATTR_METRIC_NAMESrV   s    r3   metric_nameszStudy.metric_namesx  s)     }}33DNNCGGHabbr2   c	                d    t        | ||||t        |t              rt        |      n|f|||	       y)a@  Optimize an objective function.

        Optimization is done by choosing a suitable set of hyperparameter values from a given
        range. Uses a sampler which implements the task of value suggestion based on a specified
        distribution. The sampler is specified in :func:`~optuna.study.create_study` and the
        default choice for the sampler is TPE.
        See also :class:`~optuna.samplers.TPESampler` for more details on 'TPE'.

        Optimization will be stopped when receiving a termination signal such as SIGINT and
        SIGTERM. Unlike other signals, a trial is automatically and cleanly failed when receiving
        SIGINT (Ctrl+C). If ``n_jobs`` is greater than one or if another signal than SIGINT
        is used, the interrupted trial state won't be properly updated.

        Example:

            .. testcode::

                import optuna


                def objective(trial):
                    x = trial.suggest_float("x", -1, 1)
                    return x**2


                study = optuna.create_study()
                study.optimize(objective, n_trials=3)

        Args:
            func:
                A callable that implements objective function.
            n_trials:
                The number of trials for each process. :obj:`None` represents no limit in terms of
                the number of trials. The study continues to create trials until the number of
                trials reaches ``n_trials``, ``timeout`` period elapses,
                :func:`~optuna.study.Study.stop` is called, or a termination signal such as
                SIGTERM or Ctrl+C is received.

                .. seealso::
                    :class:`optuna.study.MaxTrialsCallback` can ensure how many times trials
                    will be performed across all processes.
            timeout:
                Stop study after the given number of second(s). :obj:`None` represents no limit in
                terms of elapsed time. The study continues to create trials until the number of
                trials reaches ``n_trials``, ``timeout`` period elapses,
                :func:`~optuna.study.Study.stop` is called or, a termination signal such as
                SIGTERM or Ctrl+C is received.
            n_jobs:
                The number of parallel jobs. If this argument is set to ``-1``, the number is
                set to CPU count.

                .. note::
                    ``n_jobs`` allows parallelization using :obj:`threading` and may suffer from
                    `Python's GIL <https://wiki.python.org/moin/GlobalInterpreterLock>`__.
                    It is recommended to use :ref:`process-based parallelization<distributed>`
                    if ``func`` is CPU bound.

            catch:
                A study continues to run even when a trial raises one of the exceptions specified
                in this argument. Default is an empty tuple, i.e. the study will stop for any
                exception except for :class:`~optuna.exceptions.TrialPruned`.
            callbacks:
                List of callback functions that are invoked at the end of each trial. Each function
                must accept two parameters with the following types in this order:
                :class:`~optuna.study.Study` and :class:`~optuna.trial.FrozenTrial`.

                .. seealso::

                    See the tutorial of :ref:`optuna_callback` for how to use and implement
                    callback functions.

            gc_after_trial:
                Flag to determine whether to automatically run garbage collection after each trial.
                Set to :obj:`True` to run the garbage collection, :obj:`False` otherwise.
                When it runs, it runs a full collection by internally calling :func:`gc.collect`.
                If you see an increase in memory consumption over several trials, try setting this
                flag to :obj:`True`.

                .. seealso::

                    :ref:`out-of-memory-gc-collect`

            show_progress_bar:
                Flag to show progress bars or not. To show progress bar, set this :obj:`True`.
                Note that it is disabled when ``n_trials`` is :obj:`None`,
                ``timeout`` is not :obj:`None`, and ``n_jobs`` :math:`\ne 1`.

        Raises:
            RuntimeError:
                If nested invocation of this method occurs.
        )	studyfuncn_trialstimeoutn_jobscatch	callbacksgc_after_trialshow_progress_barN)r   
isinstancer   tuple)	rE   r   r   r   r   r   r   r   r   s	            r3   optimizezStudy.optimize  s9    L 	",UH"=%,E8)/
	
r2   c                   | j                   j                  s*t        | j                        rt	        j
                  d       |xs i }|j                         D ci c]  \  }}|t        |       }}}d| j                   _        | j                         }|%| j                  j                  | j                        }t        j                  | |      }|j                         D ]  \  }}|j                  ||        |S c c}}w )aC  Create a new trial from which hyperparameters can be suggested.

        This method is part of an alternative to :func:`~optuna.study.Study.optimize` that allows
        controlling the lifetime of a trial outside the scope of ``func``. Each call to this
        method should be followed by a call to :func:`~optuna.study.Study.tell` to finish the
        created trial.

        .. seealso::

            The :ref:`ask_and_tell` tutorial provides use-cases with examples.

        Example:

            Getting the trial object with the :func:`~optuna.study.Study.ask` method.

            .. testcode::

                import optuna


                study = optuna.create_study()

                trial = study.ask()

                x = trial.suggest_float("x", -1, 1)

                study.tell(trial, x**2)

        Example:

            Passing previously defined distributions to the :func:`~optuna.study.Study.ask`
            method.

            .. testcode::

                import optuna


                study = optuna.create_study()

                distributions = {
                    "optimizer": optuna.distributions.CategoricalDistribution(["adam", "sgd"]),
                    "lr": optuna.distributions.FloatDistribution(0.0001, 0.1, log=True),
                }

                # You can pass the distributions previously defined.
                trial = study.ask(fixed_distributions=distributions)

                # `optimizer` and `lr` are already suggested and accessible with `trial.params`.
                assert "optimizer" in trial.params
                assert "lr" in trial.params

        Args:
            fixed_distributions:
                A dictionary containing the parameter names and parameter's distributions. Each
                parameter in this dictionary is automatically suggested for the returned trial,
                even when the suggest method is not explicitly invoked by the user. If this
                argument is set to :obj:`None`, no parameter is automatically suggested.

        Returns:
            A :class:`~optuna.trial.Trial`.
        z@Heartbeat of storage is supposed to be used with Study.optimize.N)rC   r+   r   r<   warningswarnitemsr   r,   _pop_waiting_trial_idcreate_new_trialr;   optunar'   _suggest)rE   fixed_distributionsr   disttrial_idrc   nameparams           r3   askz	Study.ask  s    @ !!227KDMM7ZMM\]17R 1668
T >tDD
 
 04,--/}}55dnnEHT8,.446 	(KD%NN4'	( !
s   C=c                `    t        | ||||       t        j                  t        | |            S )a5  Finish a trial created with :func:`~optuna.study.Study.ask`.

        .. seealso::

            The :ref:`ask_and_tell` tutorial provides use-cases with examples.

        Example:

            .. testcode::

                import optuna
                from optuna.trial import TrialState


                def f(x):
                    return (x - 2) ** 2


                def df(x):
                    return 2 * x - 4


                study = optuna.create_study()

                n_trials = 30

                for _ in range(n_trials):
                    trial = study.ask()

                    lr = trial.suggest_float("lr", 1e-5, 1e-1, log=True)

                    # Iterative gradient descent objective function.
                    x = 3  # Initial value.
                    for step in range(128):
                        y = f(x)

                        trial.report(y, step=step)

                        if trial.should_prune():
                            # Finish the trial with the pruned state.
                            study.tell(trial, state=TrialState.PRUNED)
                            break

                        gy = df(x)
                        x -= gy * lr
                    else:
                        # Finish the trial with the final value after all iterations.
                        study.tell(trial, y)

        Args:
            trial:
                A :class:`~optuna.trial.Trial` object or a trial number.
            values:
                Optional objective value or a sequence of such values in case the study is used
                for multi-objective optimization. Argument must be provided if ``state`` is
                :class:`~optuna.trial.TrialState.COMPLETE` and should be :obj:`None` if ``state``
                is :class:`~optuna.trial.TrialState.FAIL` or
                :class:`~optuna.trial.TrialState.PRUNED`.
            state:
                State to be reported. Must be :obj:`None`,
                :class:`~optuna.trial.TrialState.COMPLETE`,
                :class:`~optuna.trial.TrialState.FAIL` or
                :class:`~optuna.trial.TrialState.PRUNED`.
                If ``state`` is :obj:`None`,
                it will be updated to :class:`~optuna.trial.TrialState.COMPLETE`
                or :class:`~optuna.trial.TrialState.FAIL` depending on whether
                validation for ``values`` reported succeed or not.
            skip_if_finished:
                Flag to control whether exception should be raised when values for already
                finished trial are told. If :obj:`True`, tell is skipped without any error
                when the trial is already finished.

        Returns:
            A :class:`~optuna.trial.FrozenTrial` representing the resulting trial.
            A returned trial is deep copied thus user can modify it as needed.
        )r   rc   value_or_valuesrM   skip_if_finished)r"   rK   r]   r!   )rE   rc   valuesrM   r   s        r3   tellz
Study.tellL  s5    h 	"-	
 }}.tU;<<r2   c                R    | j                   j                  | j                  ||       y)aN  Set a user attribute to the study.

        .. seealso::

            See :attr:`~optuna.study.Study.user_attrs` for related attribute.

        .. seealso::

            See the recipe on :ref:`attributes`.

        Example:

            .. testcode::

                import optuna


                def objective(trial):
                    x = trial.suggest_float("x", 0, 1)
                    y = trial.suggest_float("y", 0, 1)
                    return x**2 + y**2


                study = optuna.create_study()

                study.set_user_attr("objective function", "quadratic function")
                study.set_user_attr("dimensions", 2)
                study.set_user_attr("contributors", ["Akiba", "Sano"])

                assert study.user_attrs == {
                    "objective function": "quadratic function",
                    "dimensions": 2,
                    "contributors": ["Akiba", "Sano"],
                }

        Args:
            key: A key string of the attribute.
            value: A value of the attribute. The value should be JSON serializable.

        N)r<   set_study_user_attrr;   rE   r   rY   s      r3   set_user_attrzStudy.set_user_attr  s    T 	))$..#uEr2   c                R    | j                   j                  | j                  ||       y)ag  Set a system attribute to the study.

        Note that Optuna internally uses this method to save system messages. Please use
        :func:`~optuna.study.Study.set_user_attr` to set users' attributes.

        Args:
            key: A key string of the attribute.
            value: A value of the attribute. The value should be JSON serializable.

        N)r<   set_study_system_attrr;   r   s      r3   set_system_attrzStudy.set_system_attr  s     	++DNNCGr2   c                0    t         j                  | ||      S )a  Export trials as a pandas DataFrame_.

        The DataFrame_ provides various features to analyze studies. It is also useful to draw a
        histogram of objective values and to export trials as a CSV file.
        If there are no trials, an empty DataFrame_ is returned.

        Example:

            .. testcode::

                import optuna
                import pandas


                def objective(trial):
                    x = trial.suggest_float("x", -1, 1)
                    return x**2


                study = optuna.create_study()
                study.optimize(objective, n_trials=3)

                # Create a dataframe from the study.
                df = study.trials_dataframe()
                assert isinstance(df, pandas.DataFrame)
                assert df.shape[0] == 3  # n_trials.

        Args:
            attrs:
                Specifies field names of :class:`~optuna.trial.FrozenTrial` to include them to a
                DataFrame of trials.
            multi_index:
                Specifies whether the returned DataFrame_ employs MultiIndex_ or not. Columns that
                are hierarchical by nature such as ``(params, x)`` will be flattened to
                ``params_x`` when set to :obj:`False`.

        Returns:
            A pandas DataFrame_ of trials in the :class:`~optuna.study.Study`.

        .. _DataFrame: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html
        .. _MultiIndex: https://pandas.pydata.org/pandas-docs/stable/advanced.html

        Note:
            If ``value`` is in ``attrs`` during multi-objective optimization, it is implicitly
            replaced with ``values``.

        Note:
            If :meth:`~optuna.study.Study.set_metric_names` is called, the ``value`` or ``values``
            is implicitly replaced with the dictionary with the objective name as key and the
            objective value as value.
        )
_dataframe_trials_dataframe)rE   attrsmulti_indexs      r3   trials_dataframezStudy.trials_dataframe  s    D ++D%EEr2   c                T    | j                   j                  st        d      d| _        y)a  Exit from the current optimization loop after the running trials finish.

        This method lets the running :meth:`~optuna.study.Study.optimize` method return
        immediately after all trials which the :meth:`~optuna.study.Study.optimize` method
        spawned finishes.
        This method does not affect any behaviors of parallel or successive study processes.
        This method only works when it is called inside an objective function or callback.

        Example:

            .. testcode::

                import optuna


                def objective(trial):
                    if trial.number == 4:
                        trial.study.stop()
                    x = trial.suggest_float("x", 0, 10)
                    return x**2


                study = optuna.create_study()
                study.optimize(objective, n_trials=10)
                assert len(study.trials) == 5

        zR`Study.stop` is supposed to be invoked inside an objective function or a callback.TN)rC   r+   rm   rD   rV   s    r3   stopz
Study.stop(  s.    : !!22 
 r2   c                    t        |t              st        d      |r+| j                  |      rt        j                  d| d       y| j                  t        t        j                  d|i|             y)a  Enqueue a trial with given parameter values.

        You can fix the next sampling parameters which will be evaluated in your
        objective function.

        Example:

            .. testcode::

                import optuna


                def objective(trial):
                    x = trial.suggest_float("x", 0, 10)
                    return x**2


                study = optuna.create_study()
                study.enqueue_trial({"x": 5})
                study.enqueue_trial({"x": 0}, user_attrs={"memo": "optimal"})
                study.optimize(objective, n_trials=2)

                assert study.trials[0].params == {"x": 5}
                assert study.trials[1].params == {"x": 0}
                assert study.trials[1].user_attrs == {"memo": "optimal"}

        Args:
            params:
                Parameter values to pass your objective function.
            user_attrs:
                A dictionary of user-specific attributes other than ``params``.
            skip_if_exists:
                When :obj:`True`, prevents duplicate trials from being enqueued again.

                .. note::
                    This method might produce duplicated trials if called simultaneously
                    by multiple processes at the same time with same ``params`` dict.

        .. seealso::

            Please refer to :ref:`enqueue_trial_tutorial` for the tutorial of specifying
            hyperparameters manually.
        zparams must be a dictionary.zTrial with params z" already exists. Skipping enqueue.Nfixed_params)rM   ra   r   )
r   dict	TypeError_should_skip_enqueue_loggerinfo	add_trialr#   r$   WAITING)rE   rU   r   skip_if_existss       r3   enqueue_trialzStudy.enqueue_trialM  sm    d &$':;;d77?LL-fX5WXY ((,f5%	
r2   c                P   |j                          |j                  ct        | j                        t        |j                        k7  r8t	        dt        |j                         dt        | j                         d      | j
                  j                  | j                  |       y)a  Add trial to study.

        The trial is validated before being added.

        Example:

            .. testcode::

                import optuna
                from optuna.distributions import FloatDistribution


                def objective(trial):
                    x = trial.suggest_float("x", 0, 10)
                    return x**2


                study = optuna.create_study()
                assert len(study.trials) == 0

                trial = optuna.trial.create_trial(
                    params={"x": 2.0},
                    distributions={"x": FloatDistribution(0, 10)},
                    value=4.0,
                )

                study.add_trial(trial)
                assert len(study.trials) == 1

                study.optimize(objective, n_trials=3)
                assert len(study.trials) == 4

                other_study = optuna.create_study()

                for trial in study.trials:
                    other_study.add_trial(trial)
                assert len(other_study.trials) == len(study.trials)

                other_study.optimize(objective, n_trials=2)
                assert len(other_study.trials) == len(study.trials) + 2

        .. seealso::

            This method should in general be used to add already evaluated trials
            (``trial.state.is_finished() == True``). To queue trials for evaluation,
            please refer to :func:`~optuna.study.Study.enqueue_trial`.

        .. seealso::

            See :func:`~optuna.trial.create_trial` for how to create trials.

        .. seealso::
            Please refer to :ref:`add_trial_tutorial` for the tutorial of specifying
            hyperparameters with the evaluated value manually.

        Args:
            trial: Trial to add.

        NThe added trial has : values, which is different from the number of objectives / in the study (determined by Study.directions).template_trial)	_validater   r   rn   r   r<   r   r;   rE   rc   s     r3   r   zStudy.add_trial  s    z 	<<#DOO(<ELL@Q(Q&s5<<'8&9 :((+DOO(<'= >%%  	&&t~~e&Lr2   c                4    |D ]  }| j                  |        y)a  Add trials to study.

        The trials are validated before being added.

        Example:

            .. testcode::

                import optuna


                def objective(trial):
                    x = trial.suggest_float("x", 0, 10)
                    return x**2


                study = optuna.create_study()
                study.optimize(objective, n_trials=3)
                assert len(study.trials) == 3

                other_study = optuna.create_study()
                other_study.add_trials(study.trials)
                assert len(other_study.trials) == len(study.trials)

                other_study.optimize(objective, n_trials=2)
                assert len(other_study.trials) == len(study.trials) + 2

        .. seealso::

            See :func:`~optuna.study.Study.add_trial` for addition of each trial.

        Args:
            trials: Trials to add.

        N)r   )rE   rh   rc   s      r3   
add_trialszStudy.add_trials  s     J  	"ENN5!	"r2   z3.2.0c                    t        | j                        t        |      k7  rt        d      | j                  j	                  | j
                  t        |       y)a  Set metric names.

        This method names each dimension of the returned values of the objective function.
        It is particularly useful in multi-objective optimization. The metric names are
        mainly referenced by the visualization functions.

        Example:

            .. testcode::

                import optuna
                import pandas


                def objective(trial):
                    x = trial.suggest_float("x", 0, 10)
                    return x**2, x + 1


                study = optuna.create_study(directions=["minimize", "minimize"])
                study.set_metric_names(["x**2", "x+1"])
                study.optimize(objective, n_trials=3)

                df = study.trials_dataframe(multi_index=True)
                assert isinstance(df, pandas.DataFrame)
                assert list(df.get("values").keys()) == ["x**2", "x+1"]

        .. seealso::
            The names set by this method are used in :meth:`~optuna.study.Study.trials_dataframe`
            and :func:`~optuna.visualization.plot_pareto_front`.

        Args:
            metric_names: A list of metric names for the objective function.
        zCThe number of objectives must match the length of the metric names.N)r   rn   r   r<   r   r;   r   )rE   r   s     r3   set_metric_nameszStudy.set_metric_names  sE    H t3|#44bcc++NN5|	
r2   c                2    t        | j                        dkD  S )zReturn :obj:`True` if the study has multiple objectives.

        Returns:
            A boolean value indicates if `self.directions` has more than 1 element or not.
           )r   rn   rV   s    r3   rl   zStudy._is_multi_objective)  s     4??#a''r2   c                ~   | j                   j                  | j                  dt        j                  f      D ]j  }	 | j                   j                  |j                  t        j                        s:	 t        j                  d|j                   d       |j                  c S  y # t        j                  $ r Y w xY w)NFrr   )rM   Trial z popped from the trial queue.)r<   rx   r;   r$   r   set_trial_state_values	_trial_idRUNNINGr   UpdateFinishedTrialErrorr   debugnumberr   s     r3   r   zStudy._pop_waiting_trial_id2  s    ]]11NNUJ4F4F3H 2 
 	#E}};;OO$,, <  	 MMF5<<.0MNO??"%	#(  66 s   5B&&B<;B<c                ^   | j                  d      D ]  }|j                  j                  d|j                        }|j	                         |j	                         k7  rLg }|j                         D ]  \  }}||   }t        |t        |            s|j                  d       2t        |t              rJt        j                  t        |            xs/ t        j                  t        |      t        |      d      n||k(  }|j                  t        |              t        |      s y y)NFr\   r   r|   )atolT)rf   ra   r   rU   keysr   r   typeappendr   npisnanr   iscloser*   all)	rE   rU   rc   trial_paramsrepeated_params
param_nameparam_valueexisting_paramis_repeateds	            r3   r   zStudy._should_skip_enqueueI  s   __e_4 	E --11.%,,OL  "fkkm3*,O+1<<> :'
K!-j!9!+tN/CD
 $**51
 "+t4 HHU;/0 Wzz%"4eN6KRUV$6	   &&tK'89!:$ ?#5	8 r2   c           	     (   t         j                  t        j                        sy | j                  }t        |      dkD  rD||}nt        ||      D ci c]  \  }}||
 }}}t         j                  d| d| d| d       y t        |      dk(  rg||d   }n
|d   |d   i}d| d| d| d}		 | j                  d	      }
|	d
|
j                   d|
j                   dz  }	t         j                  |	       y J d       c c}}w # t        $ r Y .w xY w)Nr   r   z finished with values: z and parameters: .r   z finished with value: Fr\   z Best is trial z with value: zShould not reach.)r   isEnabledForr   INFOr   r   zipr   r^   r   rY   r   )rE   r   r   rU   r   trial_valuesr   rY   trial_valuemessagerT   s              r3   _log_completed_trialzStudy._log_completed_trialh  sL    ##GLL1((v;?#%?B<QW?XYeeYYLL 7~EVW]V^^_` [A#$Qi+Aq	:  6{mCTY_X``ab !1151A
_Z->->,?}ZM]M]L^^_`` LL!---5-  Z"  s   C?02D 	DD)NN)
r8   strrF   str | storages.BaseStorager@   'samplers.BaseSampler' | NonerB   pruners.BasePruner | NonereturnNone)r  dict[Any, Any])rM   r	  r  r  )r  dict[str, Any])r  r   )r  r&   )r  list[FrozenTrial])r  r   )r  zlist[StudyDirection])TN)r]   r*   rs   Container[TrialState] | Noner  r  )TNF)r]   r*   rs   r  ru   r*   r  r  )r]   r*   r  r&   )r  zlist[str] | None)NNr   r1   NFF)r   ObjectiveFuncTyper   
int | Noner   zfloat | Noner   intr   z+Iterable[type[Exception]] | type[Exception]r   z5Iterable[Callable[[Study, FrozenTrial], None]] | Noner   r*   r   r*   r  r  rP   )r   z"dict[str, BaseDistribution] | Noner  r'   )NNF)
rc   zTrial | intr   zfloat | Sequence[float] | NonerM   zTrialState | Noner   r*   r  r&   )r   r  rY   r   r  r  ))	r   rY   datetime_startdatetime_completedurationrU   r   ra   rM   F)r   ztuple[str, ...]r   r*   r  z'pd.DataFrame')r  r  r7   )rU   r
  r   zdict[str, Any] | Noner   r*   r  r  )rc   r&   r  r  )rh   zIterable[FrozenTrial]r  r  )r   	list[str]r  r  )r  r*   )r  r  )rU   zMapping[str, JSONSerializable]r  r*   )r   zlist[float]r   r  rU   r
  r  r  )&r-   r.   r/   __doc__rH   rN   rR   propertyrW   rZ   rT   rj   ro   rn   rh   rf   rv   r^   r   r   ra   r   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r  r1   r2   r3   r5   r5   C   sZ   	 26,0   ,  /	 
 *  
 (
: & &    3 3$ R R$ " "*     ; ;& /3(C(C -(C 
	(CX /3	^^ -^ 	^
 
^(#EJ $Q $QL Wg&S ' S 	c 	c  $ $=?KO$"'p
p
 p
 	p

 p
 ;p
 Ip
 p
  p
 
p
dTr 26#'!&[=[= /[= !	[=
 [= 
[=z*FX Wg&H 'H 
"
 "BFBF BF 
BFH#P -1$	?
?
 *?
 	?

 
?
BFMP&"P w(
  (
T(.>#.!#.+.#.8F#.	#.r2   r5   )rF   r@   rB   r8   ro   load_if_existsz3.0.0r   )previous_positional_arg_namesdeprecated_versionremoved_versionF)rF   r@   rB   r8   ro   r  rn   rF   r8   c                   ||dg}nP||t        d      |/t        |t              rt        |t              st        d      |g}n|t	        |      }nJ t        |      dk  rt        d      t        d |D              rt        d| d      |D cg c]+  }t        |t              r|nt        |j                            - }}t        j                  |       } 	 | j                  ||      }	|"t        |      dkD  rt#        j$                         }| j'                  |	      }t)        || ||      }
|
S c c}w # t        j                  $ r5 |r/|J t        j                  d	| d
       | j!                  |      }	n Y w xY w)a=  Create a new :class:`~optuna.study.Study`.

    Example:

        .. testcode::

            import optuna


            def objective(trial):
                x = trial.suggest_float("x", 0, 10)
                return x**2


            study = optuna.create_study()
            study.optimize(objective, n_trials=3)

    Args:
        storage:
            Database URL. If this argument is set to None,
            :class:`~optuna.storages.InMemoryStorage` is used, and the
            :class:`~optuna.study.Study` will not be persistent.

            .. note::
                When a database URL is passed, Optuna internally uses `SQLAlchemy`_ to handle
                the database. Please refer to `SQLAlchemy's document`_ for further details.
                If you want to specify non-default options to `SQLAlchemy Engine`_, you can
                instantiate :class:`~optuna.storages.RDBStorage` with your desired options and
                pass it to the ``storage`` argument instead of a URL.

             .. _SQLAlchemy: https://www.sqlalchemy.org/
             .. _SQLAlchemy's document:
                 https://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls
             .. _SQLAlchemy Engine: https://docs.sqlalchemy.org/en/latest/core/engines.html

        sampler:
            A sampler object that implements background algorithm for value suggestion.
            If :obj:`None` is specified, :class:`~optuna.samplers.TPESampler` is used during
            single-objective optimization and :class:`~optuna.samplers.NSGAIISampler` during
            multi-objective optimization. See also :class:`~optuna.samplers`.
        pruner:
            A pruner object that decides early stopping of unpromising trials. If :obj:`None`
            is specified, :class:`~optuna.pruners.MedianPruner` is used as the default. See
            also :class:`~optuna.pruners`.
        study_name:
            Study's name. If this argument is set to None, a unique name is generated
            automatically.
        direction:
            Direction of optimization. Set ``minimize`` for minimization and ``maximize`` for
            maximization. You can also pass the corresponding :class:`~optuna.study.StudyDirection`
            object. ``direction`` and ``directions`` must not be specified at the same time.

            .. note::
                If none of `direction` and `directions` are specified, the direction of the study
                is set to "minimize".
        load_if_exists:
            Flag to control the behavior to handle a conflict of study names.
            In the case where a study named ``study_name`` already exists in the ``storage``,
            a :class:`~optuna.exceptions.DuplicatedStudyError` is raised if ``load_if_exists`` is
            set to :obj:`False`.
            Otherwise, the creation of the study is skipped, and the existing one is returned.
        directions:
            A sequence of directions during multi-objective optimization.
            ``direction`` and ``directions`` must not be specified at the same time.

    Returns:
        A :class:`~optuna.study.Study` object.

    See also:
        :func:`optuna.create_study` is an alias of :func:`optuna.study.create_study`.

    See also:
        The :ref:`rdb` tutorial provides concrete examples to save and resume optimization using
        RDB.

    minimizez1Specify only one of `direction` and `directions`.zIUse `directions` instead of `direction` for multi-objective optimization.r   z0The number of objectives must be greater than 0.c              3  d   K   | ](  }|d dt         j                  t         j                  fv * yw)r  maximizeN)r   MINIMIZEr   )rb   ds     r3   rd   zcreate_study.<locals>.<genexpr>  s2       	
*j.*A*A>CZCZ[[s   .0zA`directions` must be a list of `minimize` or `maximize`, but got zT. For single-objective optimization, please use `direction` instead of `directions`.z#Using an existing study with name 'z ' instead of creating a new one.r8   rF   r@   rB   )r   r   r   r  listr   rg   r   upperr   r9   create_new_studyr   DuplicatedStudyErrorr   r   r:   r   NSGAIISamplerget_study_name_from_idr5   )rF   r@   rB   r8   ro   r  rn   r  direction_objectsrG   r   s              r3   create_studyr(    s   F Z/ \
		:#9LMM		i*:i3M[   [
		*%
u
:KLL	  
 OPZ| \a a
 	
 T^NOZ>*qwwy0II  ""7+G++,=zJ 301A5((*//9JZ'RXYEL3 ** 
)))LL5j\ B& & 55jAH 
s   0D7D< <AFFr   )r@   rB   c                   | Ft        |      }t        |      dk7  rt        d| d      |d   } t        j	                  d|  d       t        | |||      }|1t        |j                        dkD  rt        j                         |_	        |S )a  Load the existing :class:`~optuna.study.Study` that has the specified name.

    Example:

        .. testsetup::

            import os

            if os.path.exists("example.db"):
                raise RuntimeError("'example.db' already exists. Please remove it.")

        .. testcode::

            import optuna


            def objective(trial):
                x = trial.suggest_float("x", 0, 10)
                return x**2


            study = optuna.create_study(storage="sqlite:///example.db", study_name="my_study")
            study.optimize(objective, n_trials=3)

            loaded_study = optuna.load_study(study_name="my_study", storage="sqlite:///example.db")
            assert len(loaded_study.trials) == len(study.trials)

        .. testcleanup::

            os.remove("example.db")

    Args:
        study_name:
            Study's name. Each study has a unique name as an identifier. If :obj:`None`, checks
            whether the storage contains a single study, and if so loads that study.
            ``study_name`` is required if there are multiple studies in the storage.
        storage:
            Database URL such as ``sqlite:///example.db``. Please see also the documentation of
            :func:`~optuna.study.create_study` for further details.
        sampler:
            A sampler object that implements background algorithm for value suggestion.
            If :obj:`None` is specified, :class:`~optuna.samplers.TPESampler` is used
            as the default. See also :class:`~optuna.samplers`.
        pruner:
            A pruner object that decides early stopping of unpromising trials.
            If :obj:`None` is specified, :class:`~optuna.pruners.MedianPruner` is used
            as the default. See also :class:`~optuna.pruners`.

    Returns:
        A :class:`~optuna.study.Study` object.

    See also:
        :func:`optuna.load_study` is an alias of :func:`optuna.study.load_study`.

    r   z5Could not determine the study name since the storage z8 does not contain exactly 1 study. Specify `study_name`.r   z+Study name was omitted but trying to load 'z7' because that was the only study found in the storage.r   )
get_all_study_namesr   r   r   r   r5   rn   r   r%  r@   )r8   rF   r@   rB   study_namesr   s         r3   
load_studyr,  '  s    P )'2{q Gy QA A  !^
9* F* *	

 Z'RXYE3u//014 ..0Lr2   c                r    t        j                  |      }|j                  |       }|j                  |       y)a*  Delete a :class:`~optuna.study.Study` object.

    Example:

        .. testsetup::

            import os

            if os.path.exists("example.db"):
                raise RuntimeError("'example.db' already exists. Please remove it.")

        .. testcode::

            import optuna


            def objective(trial):
                x = trial.suggest_float("x", -10, 10)
                return (x - 2) ** 2


            study = optuna.create_study(study_name="example-study", storage="sqlite:///example.db")
            study.optimize(objective, n_trials=3)

            optuna.delete_study(study_name="example-study", storage="sqlite:///example.db")

        .. testcleanup::

            os.remove("example.db")

    Args:
        study_name:
            Study's name.
        storage:
            Database URL such as ``sqlite:///example.db``. Please see also the documentation of
            :func:`~optuna.study.create_study` for further details.

    See also:
        :func:`optuna.delete_study` is an alias of :func:`optuna.study.delete_study`.

    N)r   r9   r:   delete_study)r8   rF   rG   s      r3   r.  r.    s3    n ""7+G--j9H"r2   )from_study_namefrom_storage
to_storageto_study_name   )r  warning_stacklevelr  r  )r2  c           	        t        | |      }t        |xs | ||j                  d      }|j                  j	                  |j
                        j                         D ],  \  }}|j                  j                  |j
                  ||       . |j                  j                         D ]  \  }}|j                  ||        |j                  d      D ]  }|j                  ct        |j                        t        |j                        k7  r8t        dt        |j                         dt        |j                         d      |j                  j                  |j
                  |	        y)
a,  Copy study from one storage to another.

    The direction(s) of the objective(s) in the study, trials, user attributes and system
    attributes are copied.

    .. note::
        :func:`~optuna.copy_study` copies a study even if the optimization is working on.
        It means users will get a copied study that contains a trial that is not finished.

    Example:

        .. testsetup::

            import os

            if os.path.exists("example.db"):
                raise RuntimeError("'example.db' already exists. Please remove it.")
            if os.path.exists("example_copy.db"):
                raise RuntimeError("'example_copy.db' already exists. Please remove it.")

        .. testcode::

            import optuna


            def objective(trial):
                x = trial.suggest_float("x", -10, 10)
                return (x - 2) ** 2


            study = optuna.create_study(
                study_name="example-study",
                storage="sqlite:///example.db",
            )
            study.optimize(objective, n_trials=3)

            optuna.copy_study(
                from_study_name="example-study",
                from_storage="sqlite:///example.db",
                to_storage="sqlite:///example_copy.db",
            )

            study = optuna.load_study(
                study_name=None,
                storage="sqlite:///example_copy.db",
            )

        .. testcleanup::

            os.remove("example.db")
            os.remove("example_copy.db")

    Args:
        from_study_name:
            Name of study.
        from_storage:
            Source database URL such as ``sqlite:///example.db``. Please see also the
            documentation of :func:`~optuna.study.create_study` for further details.
        to_storage:
            Destination database URL.
        to_study_name:
            Name of the created study. If omitted, ``from_study_name`` is used.

    Raises:
        :class:`~optuna.exceptions.DuplicatedStudyError`:
            If a study with a conflicting name already exists in the destination storage.

    )r8   rF   F)r8   rF   rn   r  r\   Nr   r   r   r   )r,  r(  rn   r<   r   r;   r   r   r   r   rf   r   r   r   r   )	r/  r0  r1  r2  
from_studyto_studyr   rY   rc   s	            r3   
copy_studyr8    sa   n MJ 3O((	H !))@@AUAUV\\^ P
U//0B0BCOP !++113 +
UsE*+ &&&6 U<<#H,?,?(@CDU(U&s5<<'8&9 :((+H,?,?(@'A B%% 
 	**8+=+=e*TUr2   c                   t        j                  |       } | j                         }g }|D ]M  }| j                  |j                        }|D cg c]"  }|j
                  t        j                  k(  s!|$ }}t        |      }t        |j                        dk(  rR|j                  }	d}
|r?t        |      dk7  r1|	t        j                  k(  rt        |d       }n"t        |d       }nd}nd}	|j                  }
d}t        |D cg c]  }|j                  |j                   c}d      }|j!                  t#        |j$                  |	||j&                  |j(                  |||j                  |
	             P |S c c}w c c}w )	a  Get all history of studies stored in a specified storage.

    Example:

        .. testsetup::

            import os

            if os.path.exists("example.db"):
                raise RuntimeError("'example.db' already exists. Please remove it.")

        .. testcode::

            import optuna


            def objective(trial):
                x = trial.suggest_float("x", -10, 10)
                return (x - 2) ** 2


            study = optuna.create_study(study_name="example-study", storage="sqlite:///example.db")
            study.optimize(objective, n_trials=3)

            study_summaries = optuna.study.get_all_study_summaries(storage="sqlite:///example.db")
            assert len(study_summaries) == 1

            study_summary = study_summaries[0]
            assert study_summary.study_name == "example-study"

        .. testcleanup::

            os.remove("example.db")

    Args:
        storage:
            Database URL such as ``sqlite:///example.db``. Please see also the documentation of
            :func:`~optuna.study.create_study` for further details.
        include_best_trial:
            Include the best trials if exist. It potentially increases the number of queries and
            may take longer to fetch summaries depending on the storage.

    Returns:
        List of study history summarized as :class:`~optuna.study.StudySummary` objects.

    See also:
        :func:`optuna.get_all_study_summaries` is an alias of
        :func:`optuna.study.get_all_study_summaries`.

    r   Nr   c                6    t        t        | j                        S rP   r~   r   s    r3   r   z)get_all_study_summaries.<locals>.<lambda>s      T%QRQXQXEY r2   r   c                6    t        t        | j                        S rP   r~   r   s    r3   r   z)get_all_study_summaries.<locals>.<lambda>u  r;  r2   )default)	r8   ro   rT   r   ra   r   r  rG   rn   )r   r9   get_all_studiesrx   r;   rM   r$   r   r   rn   ro   r   r   r   r   r  r   r    r8   r   ra   )rF   include_best_trialfrozen_studiesstudy_summariess
all_trialsry   completed_trialsr   ro   rn   rT   r  s                r3   get_all_study_summariesrE  .  so   l ""7+G,,.NO %
++AKK8
'1T!QWW
@S@S5SATTz?q||!IJ!c*:&;q&@ 7 77!$%5;Y!ZJ!$%5;Y!ZJ!
IJJ'1R!Q5E5E5QQR\`
 	<<#%<<^^!-%
	
3%
N K U( Ss   "E=0E=F
F
c                    t        j                  |       } | j                         D cg c]  }|j                   }}|S c c}w )a  Get all study names stored in a specified storage.

    Example:

        .. testsetup::

            import os

            if os.path.exists("example.db"):
                raise RuntimeError("'example.db' already exists. Please remove it.")

        .. testcode::

            import optuna


            def objective(trial):
                x = trial.suggest_float("x", -10, 10)
                return (x - 2) ** 2


            study = optuna.create_study(study_name="example-study", storage="sqlite:///example.db")
            study.optimize(objective, n_trials=3)

            study_names = optuna.study.get_all_study_names(storage="sqlite:///example.db")
            assert len(study_names) == 1

            assert study_names[0] == "example-study"

        .. testcleanup::

            os.remove("example.db")

    Args:
        storage:
            Database URL such as ``sqlite:///example.db``. Please see also the documentation of
            :func:`~optuna.study.create_study` for further details.

    Returns:
        List of all study names in the storage.

    See also:
        :func:`optuna.get_all_study_names` is an alias of
        :func:`optuna.study.get_all_study_names`.

    )r   r9   r>  r8   )rF   r   r+  s      r3   r*  r*    sC    ` ""7+G181H1H1JK5##KKK Ls   ?)rF   z!str | storages.BaseStorage | Noner@   r  rB   r  r8   
str | Nonero   zstr | StudyDirection | Noner  r*   rn   z%Sequence[str | StudyDirection] | Noner  r5   )
r8   rG  rF   r  r@   r  rB   r  r  r5   )r8   r  rF   r  r  r  )
r/  r  r0  r  r1  r  r2  rG  r  r  )T)rF   r  r?  r*   r  zlist[StudySummary])rF   r  r  r  )N
__future__r   collections.abcr   r   r   rK   numbersr   	threadingtypingr   r	   r
   r   r   r   r   numpyr   r   r   r   r   r   r   optuna._convert_positional_argsr   optuna._deprecatedr   optuna._experimentalr   optuna._importsr   optuna._typingr   optuna.distributionsr   r   optuna.storages._heartbeatr   &optuna.study._constrained_optimizationr   r   optuna.study._multi_objectiver   optuna.study._optimizer   optuna.study._study_directionr   optuna.study._study_summaryr    optuna.study._tellr!   r"   optuna.trialr#   r$   r   optuna.study._dataframer%   r&   r'   r   r  r   
get_loggerr-   r   localr)   r5   r(  r,  r.  r8  rE  r*  r1   r2   r3   <module>r_     s   " % $ #                   C . 2 ' + N 1 ; C G B , 8 4 0 1 % # 23
*(" gYeXe_.D(EEF  1  '

X
&7 7
H. H.V" #  26-1(,!-1 8<J.J +J &	J
 J +J J 6J JJZ # 	 .2(,NN (N +	N
 &N N	Nb # 1#1# (1# 
	1#1#h # 
  !%bUbU -bU +	bU
 bU 
bU
bUL EIa'a=AaaH3r2   