
    !#h                        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rd d
lmZ  G d de      Zy)    )annotations)Any)TYPE_CHECKING)distributions)_SearchSpaceTransform)BaseDistribution)BaseSampler)LazyRandomState)FrozenTrial)Studyc                  j    e Zd ZdZdd	dZd
dZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 ddZy)RandomSampleraS  Sampler using random sampling.

    This sampler is based on *independent sampling*.
    See also :class:`~optuna.samplers.BaseSampler` for more details of 'independent sampling'.

    Example:

        .. testcode::

            import optuna
            from optuna.samplers import RandomSampler


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


            study = optuna.create_study(sampler=RandomSampler())
            study.optimize(objective, n_trials=10)

    Args:
        seed: Seed for random number generator.
    Nc                $    t        |      | _        y N)r
   _rng)selfseeds     T/var/www/html/sandstorm/venv/lib/python3.12/site-packages/optuna/samplers/_random.py__init__zRandomSampler.__init__,   s    #D)	    c                L    | j                   j                  j                          y r   )r   rngr   )r   s    r   
reseed_rngzRandomSampler.reseed_rng/   s    		r   c                    i S r    )r   studytrials      r   infer_relative_search_spacez)RandomSampler.infer_relative_search_space2   	     	r   c                    i S r   r   )r   r   r   search_spaces       r   sample_relativezRandomSampler.sample_relative7   r   r   c                    ||i}t        |      }| j                  j                  j                  |j                  d d df   |j                  d d df         }|j                  |      |   S )Nr      )r   r   r   uniformboundsuntransform)r   r   r   
param_nameparam_distributionr!   transtrans_paramss           r   sample_independentz RandomSampler.sample_independent<   sd     #$67%l3yy}},,U\\!Q$-?aQRdAST  .z::r   r   )r   z
int | NonereturnNone)r-   r.   )r   r   r   r   r-   dict[str, BaseDistribution])r   r   r   r   r!   r/   r-   zdict[str, Any])
r   r   r   r   r(   strr)   zdistributions.BaseDistributionr-   r   )	__name__
__module____qualname____doc__r   r   r   r"   r,   r   r   r   r   r      s    2*#.	$
#.>Y	
;; ; 	;
 ;; 
;r   r   N)
__future__r   typingr   r   optunar   optuna._transformr   optuna.distributionsr   optuna.samplersr	   "optuna.samplers._lazy_random_stater
   optuna.trialr   optuna.studyr   r   r   r   r   <module>r>      s4    "      3 1 ' > $ "5;K 5;r   