
    Q-j~n                       U 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	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& erHd dl'm(Z( d dlm)Z) d dl*Z*d dlm+Z+ d dl%m,Z, e*jZ                  e*j\                  z  e*j^                  z  Z0de1d<   n ed      Z* ejd                  e3      Z4dZ5dZ6 G d de      Z7	 	 	 	 	 	 d!d Z8y)"    )annotationsN)Any)cast)TYPE_CHECKING)_deprecated)logging)convert_positional_args)warn_experimental_argument)_LazyImport)_SearchSpaceTransform)optuna_warn)FloatDistribution)IntDistribution)BaseSampler)&_INDEPENDENT_SAMPLING_WARNING_TEMPLATE)LazyRandomState)IntersectionSearchSpace)StudyDirection)
TrialState)Sequence)	TypeAlias)BaseDistribution)FrozenTrialr   CmaClasscmaesg|=i  c                     e Zd ZdZ eg ddd      ddddddd	ddd
d	d	d	dd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       ZddZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 ddZe	d d       Z
e	d d       Zd!dZd"dZ	 	 	 	 d#dZ	 	 	 	 	 	 d$dZ	 	 	 	 	 	 	 	 	 	 d%dZd&dZd'dZ	 	 	 	 	 	 d(dZd)dZ	 	 	 	 	 	 	 	 	 	 d*dZy)+CmaEsSampleru(  A sampler using `cmaes <https://github.com/CyberAgentAILab/cmaes>`__ as the backend.

    Example:

        Optimize a simple quadratic function by using :class:`~optuna.samplers.CmaEsSampler`.

        .. code-block:: console

           $ pip install cmaes

        .. testcode::

            import optuna


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


            sampler = optuna.samplers.CmaEsSampler()
            study = optuna.create_study(sampler=sampler)
            study.optimize(objective, n_trials=20)

    Please note that this sampler does not support CategoricalDistribution.
    If your search space includes categorical parameters, it is recommended to use
    `CatCmawmSampler <https://hub.optuna.org/samplers/catcmawm/>`__ available on
    `OptunaHub <https://hub.optuna.org/>`__.

    Furthermore, there is room for performance improvements in parallel
    optimization settings. This sampler cannot use some trials for updating
    the parameters of multivariate normal distribution.

    For further information about CMA-ES algorithm, please refer to the following papers:

    - `N. Hansen, The CMA Evolution Strategy: A Tutorial. arXiv:1604.00772, 2016.
      <https://arxiv.org/abs/1604.00772>`__
    - `A. Auger and N. Hansen. A restart CMA evolution strategy with increasing population
      size. In Proceedings of the IEEE Congress on Evolutionary Computation (CEC 2005),
      pages 1769–1776. IEEE Press, 2005. <https://doi.org/10.1109/CEC.2005.1554902>`__
    - `N. Hansen. Benchmarking a BI-Population CMA-ES on the BBOB-2009 Function Testbed.
      GECCO Workshop, 2009. <https://doi.org/10.1145/1570256.1570333>`__
    - `Raymond Ros, Nikolaus Hansen. A Simple Modification in CMA-ES Achieving Linear Time and
      Space Complexity. 10th International Conference on Parallel Problem Solving From Nature,
      Sep 2008, Dortmund, Germany. inria-00287367. <https://doi.org/10.1007/978-3-540-87700-4_30>`__
    - `Masahiro Nomura, Shuhei Watanabe, Youhei Akimoto, Yoshihiko Ozaki, Masaki Onishi.
      Warm Starting CMA-ES for Hyperparameter Optimization, AAAI. 2021.
      <https://doi.org/10.1609/aaai.v35i10.17109>`__
    - `R. Hamano, S. Saito, M. Nomura, S. Shirakawa. CMA-ES with Margin: Lower-Bounding Marginal
      Probability for Mixed-Integer Black-Box Optimization, GECCO. 2022.
      <https://doi.org/10.1145/3512290.3528827>`__
    - `M. Nomura, Y. Akimoto, I. Ono. CMA-ES with Learning Rate Adaptation: Can CMA-ES with
      Default Population Size Solve Multimodal and Noisy Problems?, GECCO. 2023.
      <https://doi.org/10.1145/3583131.3590358>`__

    .. seealso::
        You can also use `optuna_integration.PyCmaSampler <https://optuna-integration.readthedocs.io/en/stable/reference/generated/optuna_integration.PyCmaSampler.html#optuna_integration.PyCmaSampler>`__ which is a sampler using cma
        library as the backend.

    Args:

        x0:
            A dictionary of an initial parameter values for CMA-ES. By default, the mean of ``low``
            and ``high`` for each distribution is used. Note that ``x0`` is sampled uniformly
            within the search space domain for each restart if you specify ``restart_strategy``
            argument.

            .. warning::
                Deprecated in v4.9.0. ``x0`` argument will be removed in the future.
                The removal of this feature is currently scheduled for v6.0.0,
                but this schedule is subject to change.

        sigma0:
            Initial standard deviation of CMA-ES. By default, ``sigma0`` is set to
            ``min_range / 6``, where ``min_range`` denotes the minimum range of the distributions
            in the search space.

            .. warning::
                Deprecated in v4.9.0. ``sigma0`` argument will be removed in the future.
                The removal of this feature is currently scheduled for v6.0.0,
                but this schedule is subject to change.

        seed:
            A random seed for CMA-ES.

        n_startup_trials:
            The independent sampling is used instead of the CMA-ES algorithm until the given number
            of trials finish in the same study.

        independent_sampler:
            A :class:`~optuna.samplers.BaseSampler` instance that is used for independent
            sampling. The parameters not contained in the relative search space are sampled
            by this sampler.
            The search space for :class:`~optuna.samplers.CmaEsSampler` is determined by
            :func:`~optuna.search_space.intersection_search_space()`.

            If :obj:`None` is specified, :class:`~optuna.samplers.RandomSampler` is used
            as the default.

            .. seealso::
                :class:`optuna.samplers` module provides built-in independent samplers
                such as :class:`~optuna.samplers.RandomSampler` and
                :class:`~optuna.samplers.TPESampler`.

        warn_independent_sampling:
            If this is :obj:`True`, a warning message is emitted when
            the value of a parameter is sampled by using an independent sampler.

            Note that the parameters of the first trial in a study are always sampled
            via an independent sampler, so no warning messages are emitted in this case.

        restart_strategy:
            Strategy for restarting CMA-ES optimization when converges to a local minimum.
            If :obj:`None` is given, CMA-ES will not restart (default).
            If 'ipop' is given, CMA-ES will restart with increasing population size.
            if 'bipop' is given, CMA-ES will restart with the population size
            increased or decreased.
            Please see also ``inc_popsize`` parameter.

            .. warning::
                Deprecated in v4.4.0. ``restart_strategy`` argument will be removed in the future.
                The removal of this feature is currently scheduled for v6.0.0,
                but this schedule is subject to change.
                From v4.4.0 onward, ``restart_strategy`` automatically falls back to ``None``, and
                ``restart_strategy`` will be supported in OptunaHub.
                See https://github.com/optuna/optuna/releases/tag/v4.4.0.

        popsize:
            A population size of CMA-ES.

        inc_popsize:
            Multiplier for increasing population size before each restart.
            This argument will be used when ``restart_strategy = 'ipop'``
            or ``restart_strategy = 'bipop'`` is specified.

            .. warning::
                Deprecated in v4.4.0. ``inc_popsize`` argument will be removed in the future.
                The removal of this feature is currently scheduled for v6.0.0,
                but this schedule is subject to change.
                From v4.4.0 onward, ``inc_popsize`` is no longer utilized within Optuna, and
                ``inc_popsize`` will be supported in OptunaHub.
                See https://github.com/optuna/optuna/releases/tag/v4.4.0.

        consider_pruned_trials:
            If this is :obj:`True`, the PRUNED trials are considered for sampling.

            .. note::
                Added in v2.0.0 as an experimental feature. The interface may change in newer
                versions without prior notice. See
                https://github.com/optuna/optuna/releases/tag/v2.0.0.

            .. note::
                It is suggested to set this flag :obj:`False` when the
                :class:`~optuna.pruners.MedianPruner` is used. On the other hand, it is suggested
                to set this flag :obj:`True` when the :class:`~optuna.pruners.HyperbandPruner` is
                used. Please see `the benchmark result
                <https://github.com/optuna/optuna/pull/1229>`__ for the details.

        use_separable_cma:
            If this is :obj:`True`, the covariance matrix is constrained to be diagonal.
            Due to reduce the model complexity, the learning rate for the covariance matrix
            is increased. Consequently, this algorithm outperforms CMA-ES on separable functions.

            .. note::
                Added in v2.6.0 as an experimental feature. The interface may change in newer
                versions without prior notice. See
                https://github.com/optuna/optuna/releases/tag/v2.6.0.

        with_margin:
            If this is :obj:`True`, CMA-ES with margin is used. This algorithm prevents samples in
            each discrete distribution (:class:`~optuna.distributions.FloatDistribution` with
            ``step`` and :class:`~optuna.distributions.IntDistribution`) from being fixed to a single
            point.
            Currently, this option cannot be used with ``use_separable_cma=True``.

            .. note::
                Added in v3.1.0 as an experimental feature. The interface may change in newer
                versions without prior notice. See
                https://github.com/optuna/optuna/releases/tag/v3.1.0.

        lr_adapt:
            If this is :obj:`True`, CMA-ES with learning rate adaptation is used.
            This algorithm focuses on working well on multimodal and/or noisy problems
            with default settings.
            Currently, this option cannot be used with ``use_separable_cma=True`` or
            ``with_margin=True``.

            .. note::
                Added in v3.3.0 or later, as an experimental feature.
                The interface may change in newer versions without prior notice. See
                https://github.com/optuna/optuna/releases/tag/v3.3.0.

        source_trials:
            This option is for Warm Starting CMA-ES, a method to transfer prior knowledge on
            similar HPO tasks through the initialization of CMA-ES. This method estimates a
            promising distribution from ``source_trials`` and generates the parameter of
            multivariate gaussian distribution. Please note that it is prohibited to use
            ``use_separable_cma`` argument together.

            .. note::
                Added in v2.6.0 as an experimental feature. The interface may change in newer
                versions without prior notice. See
                https://github.com/optuna/optuna/releases/tag/v2.6.0.

    )selfx0sigma0n_startup_trialsindependent_samplerwarn_independent_samplingseed4.9.06.0.0)previous_positional_arg_namesdeprecated_versionremoved_versionN   TF)r   r    r!   r"   r#   r$   consider_pruned_trialsrestart_strategypopsizeinc_popsizeuse_separable_cmawith_marginlr_adaptsource_trialsc               V   ||
dk7  r5t         j                  j                  ddd      }t        | dt               |2t         j                  j                  ddd      }t        |t               |2t         j                  j                  d	dd      }t        |t               || _        || _        |xs  t        j                  j                  |
      | _
        || _        || _        t        |      | _        t               | _        || _        |	| _        || _        || _        || _        || _        | j&                  rd| _        n| j(                  rd| _        nd| _        | j"                  rt1        d       | j&                  rt1        d       | j,                  t1        d       | j(                  rt1        d       | j*                  rt1        d       |||t3        d      ||rt3        d      |r|s|rt3        d      | j&                  r| j(                  rt3        d      y y )Nr+   z`restart_strategy`z4.4.0r&   )named_verr_verz~ From v4.4.0 onward, `restart_strategy` automatically falls back to `None`. `restart_strategy` will be supported in OptunaHub.z`x0`r%   z`sigma0`)r$   zsepcma:zcmawm:zcma:r,   r0   r3   r1   r2   zQIt is prohibited to pass `source_trials` argument when x0 or sigma0 is specified.zNIt is prohibited to pass `source_trials` argument when using separable CMA-ES.z]It is prohibited to pass `use_separable_cma` or `with_margin` argument when using `lr_adapt`.zMCurrently, we do not support `use_separable_cma=True` and `with_margin=True`.)r   _DEPRECATION_WARNING_TEMPLATEformatr   FutureWarning_x0_sigma0optunasamplersRandomSampler_independent_sampler_n_startup_trials_warn_independent_samplingr   _cma_rngr   _search_space_consider_pruned_trials_popsize_use_separable_cma_with_margin	_lr_adapt_source_trials_attr_prefixr
   
ValueError)r   r   r    r!   r"   r#   r$   r,   r-   r.   r/   r0   r1   r2   r3   msgs                   d/Users/jameslopez/projects/TradingBot25/.venv/lib/python3.12/site-packages/optuna/samplers/_cmaes.py__init__zCmaEsSampler.__init__  sC   > ';"+<;;BB) C C % M M
 >;;BB7' C C ]+;;BBwg C C ]+$7$c6??;X;X^b;X;c!!1*C''-46'=$"3'!+"" )D (D &D''&'?@""&':;*&7&}5>>&z2$".F<Nc 
 $):`  *k$  ""t'8'8_  (9"    c                8    | j                   j                          y N)r@   
reseed_rngr   s    rN   rS   zCmaEsSampler.reseed_rngp  s    !!,,.rP   c                    i }| j                   j                  |      j                         D ]2  \  }}|j                         rt	        |t
        t        f      s.|||<   4 |S rR   )rD   	calculateitemssingle
isinstancer   r   )r   studytrialsearch_spacer5   distributions         rN   infer_relative_search_spacez(CmaEsSampler.infer_relative_search_spacet  si     57"&"4"4">">u"E"K"K"MD,""$ l->,PQ!-L #N rP   c                   | j                  |       t        |      dk(  ri S | j                  |      }t        |      | j                  k  ri S t	        || j
                   d      }| j                  |      }|| j                  ||j                        }|j                  t        |j                        k7  rN| j                  r@| j                  j                  j                  }t        j!                  d| d       d| _        i S | j#                  ||j$                        }t        |      |j&                  k\  r@g }	|d |j&                   D ]  }
|
j(                  J d       t+        |t,        j.                        r#t1        j2                  |
j4                  d         }n|j7                  |
j8                        }|j                  t:        j<                  k(  r|
j(                  n|
j(                   }|	j?                  ||f        |jA                  |	       tC        jD                  |      jG                         }| jI                  |      }|D ],  }|jJ                  jM                  |jN                  |||          . | jP                  jR                  jU                  d	d
      |jV                  z   }|jX                  j[                  |       t+        |t,        j.                        rI|j]                         \  }}|jJ                  jM                  |jN                  d|j_                                n|j]                         }| j`                  }|jJ                  jM                  |jN                  ||j$                         |jc                  |      }|S )Nr   T)transform_steptransform_0_1z7`CmaEsSampler` does not support dynamic search space. `z$` is used instead of `CmaEsSampler`.Fz"completed trials must have a value
x_for_tellr*   i   )2_raise_error_if_multi_objectivelen_get_trialsrA   r   rH   _restore_optimizer_init_optimizer	directiondimboundsrB   r@   	__class____name___loggerwarning_get_solution_trials
generationpopulation_sizevaluerY   r   CMAwMnparraysystem_attrs	transformparamsr   MINIMIZEappendtellpickledumpshex_split_optimizer_str_storageset_trial_system_attr	_trial_idrC   rngrandintnumber_rngr$   asktolist_attr_key_generationuntransform)r   rZ   r[   r\   completed_trialstrans	optimizerind_sampler_namesolution_trials	solutionstxyoptimizer_stroptimizer_attrskeyr$   rx   rb   generation_attr_keyexternal_valuess                        rN   sample_relativezCmaEsSampler.sample_relative  s    	,,U3|!I++E2 4#9#99I &T->->)>d
 ++,<=	,,UEOODI==C--..#'#<#<#F#F#O#O ())MO 38/I 334DiFZFZ[9#<#<<8:I$%@y'@'@Aww*P,PP*i5!=>A1A$.2I2IIAGGPQPWPWx  !Q( B NN9% #LL3779M"77FO&44U__c?[^K_` ' }}  ((E2U\\AD!i-!*FJNN00z/@/@/B ]]_F"77,,OO0)2F2F	
  ++F3rP   c                     | j                   dz   S )Nrp   rK   rT   s    rN   r   z!CmaEsSampler._attr_key_generation  s      <//rP   c                     | j                   dz   S )Nr   r   rT   s    rN   _attr_key_optimizerz CmaEsSampler._attr_key_optimizer  s      ;..rP   c                `     dj                   fdt        t                    D              S )N c              3  F   K   | ]  }j                    d |      yw):N)r   ).0ir   r   s     rN   	<genexpr>z7CmaEsSampler._concat_optimizer_attrs.<locals>.<genexpr>  s-      
Hc1Ot778!=>Hcs   !)joinrangerd   )r   r   s   ``rN   _concat_optimizer_attrsz$CmaEsSampler._concat_optimizer_attrs  s,    ww 
HMcRaNbHc
 
 	
rP   c                    t        |      }i }t        t        j                  |t        z              D ]8  }|t        z  }t        |dz   t        z  |      }||| || j                   d| <   : |S )Nr*   r   )rd   r   mathceil_SYSTEM_ATTR_MAX_LENGTHminr   )r   r   optimizer_lenattrsr   startends          rN   r   z!CmaEsSampler._split_optimizer_str  s{    M*tyy1H!HIJA//Eq1u 77GC7DU37OET--.as34 K rP   c                R   t        |      D ]  }|j                  j                         D ci c]#  \  }}|j                  | j                        r||% }}}t        |      dk(  rZ| j                  |      }t        j                  t        j                  |            c S  y c c}}w )Nr   )reversedrv   rW   
startswithr   rd   r   r|   loadsbytesfromhex)r   r   r[   r   rr   r   r   s          rN   rf   zCmaEsSampler._restore_optimizer  s    
 ./E #("4"4":":"<"<JC>>$":":; U
"<  
 ?#q( 88IM<<m <== 0 s   (B#c                   |j                   d d df   }|j                   d d df   }t        |j                         }| j                  j| j                  |||z
  dz  z   }n|j	                  | j                        }| j
                  t        j                  ||z
  dz        }n| j
                  }d }nt        j                  g}	| j                  r|	j                  t        j                         |t        j                  k(  rdnd}
| j                  D cg c]Z  }|j                  |	v rJt!        ||j"                        r4|j	                  |j$                        |
t'        d|j(                        z  f\ }}t        |      dk(  rt+        d      t-        j.                  |      \  }}}t1        |t2              }| j4                  rt        |j                         dk(  rt7        dt8               nVt-        j:                  |||j                   | j<                  j>                  jA                  dd	      d
|z  | jB                        S | jD                  r/t        jF                  t        |jH                        tJ              }tM        |jH                  jO                               D ]  \  }}tQ        |tR        tT        f      sJ |jV                  |jX                  rd||<   <|jZ                  |j\                  k(  rd||<   [|jV                  |j\                  |jZ                  z
  z  ||<    t-        j^                  |||j                   ||| j<                  j>                  jA                  dd	      d
|z  | jB                        S t-        j`                  ||||j                   | j<                  j>                  jA                  dd	      d
|z  | jB                  | jb                        S c c}w )Nr   r*         r+   floatzNo compatible source_trialszSeparable CMA-ES does not operate meaningfully on single-dimensional search spaces. The setting `use_separable_cma=True` will be ignored.i
   )meansigmarj   r$   n_max_resamplingrq   )dtypeg        g      ?)r   r   rj   stepscovr$   r   rq   )r   r   r   rj   r$   r   rq   r2   )2rj   rd   rJ   r;   rw   r<   rt   r   r   COMPLETErE   rz   PRUNEDr   ry   state_is_compatible_search_spacedistributionsrx   r   rr   rL   r   get_warm_start_mgdmax_EPSrG   r   UserWarningSepCMArC   r   r   rF   rH   emptyrD   r   	enumeratevaluesrY   r   r   steploglowhighrs   CMArI   )r   r   rh   lower_boundsupper_boundsn_dimensionr   r    r   expected_statessignr   source_solutionsr   r   dists                   rN   rg   zCmaEsSampler._init_optimizer  sY   
 ||AqD)||AqD)%,,'&xx#|l'Ba&GG txx0||#!< ABC)223O++&&z'8'89 "^%<%<<1"D ,, ,A77o-/qG *D43I,IJ,    #$) !>?? !& 8 89I JD&# VT"""5<< A%[ ||  <<**221i@%'+%5$(MM  HHS!4!45UCE$U%8%8%?%?%AB4!$:K(LMMM99$"E!HXX*"E!H#yyDII,@AE!H C ;;||]]&&..q)<!#k!1 $	 	 yy<<""**1i8+- MM^^	
 		
o s   AOc                    | j                  |       | j                  r;| j                  |      }t        |      | j                  k\  r| j                  ||       | j                  j                  ||||      S rR   )rc   rB   re   rd   rA   _log_independent_samplingr@   sample_independent)r   rZ   r[   
param_nameparam_distributioncomplete_trialss         rN   r   zCmaEsSampler.sample_independentZ  sq     	,,U3**"..u5O?#t'='==..ujA((;;5*&8
 	
rP   c           	         t         j                  t        j                  ||j                  | j
                  j                  j                  | j                  j                  d             y )NzVdynamic search space and `CategoricalDistribution` are not supported by `CmaEsSampler`)r   trial_numberindependent_sampler_namesampler_namefallback_reason)rm   rn   r   r9   r   r@   rk   rl   )r   r[   r   s      rN   r   z&CmaEsSampler._log_independent_samplingl  sM    299%"\\)-)B)B)L)L)U)U!^^44(		
rP   c                   g }|j                  dd      D ]  }|j                  t        j                  k(  r|j	                  |       2|j                  t        j
                  k(  sPt        |j                        dkD  si| j                  svt        |j                  j                               \  }}|t        j                  |      }||_        |j	                  |        |S )NFT)deepcopy	use_cacher   )re   r   r   r   rz   r   rd   intermediate_valuesrE   r   rW   copyr   rr   )r   rZ   r   r   _rr   copied_ts          rN   re   zCmaEsSampler._get_trialsz  s    ""ET"BAww*---&&q):,,,--.200q44::<=5===+!&&&x0 C rP   c                    | j                   }|D cg c]$  }||j                  j                  |d      k(  s#|& c}S c c}w )Nr+   )r   rv   get)r   trialsrp   r   r   s        rN   ro   z!CmaEsSampler._get_solution_trials  sB     #77!_6aZ1>>3E3EFY[]3^%^6___s   $==c                <    | j                   j                  ||       y rR   )r@   before_trial)r   rZ   r[   s      rN   r   zCmaEsSampler.before_trial  s    !!..ue<rP   c                @    | j                   j                  ||||       y rR   )r@   after_trial)r   rZ   r[   r   r   s        rN   r   zCmaEsSampler.after_trial  s     	!!--eUE6JrP   )r   zdict[str, Any] | Noner    zfloat | Noner!   intr"   zBaseSampler | Noner#   boolr$   
int | Noner,   r   r-   z
str | Noner.   r   r/   r   r0   r   r1   r   r2   r   r3   zlist[FrozenTrial] | NonereturnNone)r   r   )rZ   'optuna.Study'r[   'optuna.trial.FrozenTrial'r   dict[str, BaseDistribution])rZ   r   r[   r   r\   r   r   zdict[str, Any])r   str)r   dict[str, str]r   r   )r   r   r   r   )r   z 'list[optuna.trial.FrozenTrial]'r   z'CmaClass' | None)r   r   rh   r   r   z
'CmaClass')
rZ   r   r[   r   r   r   r   r   r   r   )r[   r   r   r   r   r   )rZ   r   r   list[FrozenTrial])r   r   rp   r   r   r   )rZ   zoptuna.Studyr[   r   r   r   )
rZ   r   r[   r   r   r   r   zSequence[float] | Noner   r   )rl   
__module____qualname____doc__r	   rO   rS   r^   r   propertyr   r   r   r   rf   rg   r   r   re   ro   r   r    rP   rN   r   r   2   se   M^ '
 #  %)# !26*.','+""'!26!_ "_ 	_
 _ 0_ $(_ _ !%_ %_ _ _  _ _ _  0!_" 
#__B/#,F	$$KK *K 2	K
 
KZ 0 0 / /

: 
$]
$]
 "]
 
	]
~

 *
 	

 -
 

$
&`'`58`	`=KK *K 	K
 'K 
KrP   r   c                    t        t        | j                  j                               j	                  |j                                     }|t        | j                        cxk(  xr t        |      k(  S c S rR   )rd   setrD   keysintersection)r   r\   intersection_sizes      rN   r   r     s]     C 3 3 8 8 :;HHIZIZI\]^E$7$7 8MC<MMMMMrP   )r   r   r\   r   r   r   )9
__future__r   r   r   r|   typingr   r   r   numpyrt   r=   r   r   optuna._convert_positional_argsr	   optuna._experimentalr
   optuna._importsr   optuna._transformr   optuna._warningsr   optuna.distributionsr   r   optuna.samplersr   optuna.samplers._baser   "optuna.samplers._lazy_random_stater   optuna.search_spacer   optuna.study._study_directionr   optuna.trialr   collections.abcr   r   r   r   r   r   r   rs   r   __annotations__
get_loggerrl   rm   r   r   r   r   r  rP   rN   <module>r     s    "            C ; ' 3 ( 2 0 ' H > 7 8 # ( 5())ell2U[[@Hi@ E
'

X
& k	K; k	K\N N0KN	NrP   