
    -ji                        S SK Jr  S SKJr  S SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJr  S S	KJr  S S
KJr  \(       a  S SKJr  \" S5       " S S\5      5       rg)    )annotations)Sequence)Any)TYPE_CHECKING)experimental_class)optuna_warn)BaseDistribution)BaseSampler)FrozenTrial)
TrialState)Studyz2.4.0c                      \ rS rSrSrSS jrSS jr      SS jr        SS jr          SS jr	SS jr
          SS	 jrS
rg)PartialFixedSampler   aH  Sampler with partially fixed parameters.

Example:

    After several steps of optimization, you can fix the value of ``y`` and re-optimize it.

    .. testcode::

        import optuna


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


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

        best_params = study.best_params
        fixed_params = {"y": best_params["y"]}
        partial_sampler = optuna.samplers.PartialFixedSampler(fixed_params, study.sampler)

        study.sampler = partial_sampler
        study.optimize(objective, n_trials=10)

Args:

    fixed_params:
        A dictionary of parameters to be fixed.

    base_sampler:
        A sampler which samples unfixed parameters.

c                    Xl         X l        g N)_fixed_params_base_sampler)selffixed_paramsbase_samplers      X/home/james-whalen/.local/lib/python3.13/site-packages/optuna/samplers/_partial_fixed.py__init__PartialFixedSampler.__init__:   s    ))    c                8    U R                   R                  5         g r   )r   
reseed_rng)r   s    r   r   PartialFixedSampler.reseed_rng>   s    %%'r   c                    U R                   R                  X5      nU R                  R                  5        H  nXC;   d  M
  X4	 M     U$ r   )r   infer_relative_search_spacer   keys)r   studytrialsearch_space
param_names        r   r    /PartialFixedSampler.infer_relative_search_spaceA   sI     ))EEeS ,,113J) , 4 r   c                :    U R                   R                  XU5      $ r   )r   sample_relative)r   r"   r#   r$   s       r   r(   #PartialFixedSampler.sample_relativeM   s     !!11%MMr   c           	         X0R                   ;  a  U R                  R                  XX45      $ U R                   U   nUR                  U5      nUR	                  U5      nU(       d  [        SU SU SU S35        U$ )NzFixed parameter 'z' with value z" is out of range for distribution .)r   r   sample_independentto_internal_repr	_containsr   )r   r"   r#   r%   param_distributionparam_valueparam_value_in_internal_repr	containeds           r   r,   &PartialFixedSampler.sample_independentV   s     ///%%88j  ,,Z8K+=+N+N{+[(*445QRI'
|= N((:';1> r   c                :    U R                   R                  X5        g r   )r   before_trial)r   r"   r#   s      r   r5    PartialFixedSampler.before_trialq   s    ''5r   c                <    U R                   R                  XX45        g r   )r   after_trial)r   r"   r#   statevaluess        r   r8   PartialFixedSampler.after_trialt   s     	&&uUCr   )r   r   N)r   dict[str, Any]r   r
   returnNone)r=   r>   )r"   r   r#   r   r=   dict[str, BaseDistribution])r"   r   r#   r   r$   r?   r=   r<   )
r"   r   r#   r   r%   strr/   r	   r=   r   )r"   r   r#   r   r=   r>   )
r"   r   r#   r   r9   r   r:   zSequence[float] | Noner=   r>   )__name__
__module____qualname____firstlineno____doc__r   r   r    r(   r,   r5   r8   __static_attributes__ r   r   r   r      s    #J*(

#.
	$
NN N 2	N
 
N  	
 - 
66DD D 	D
 'D 
Dr   r   N)
__future__r   collections.abcr   typingr   r   optuna._experimentalr   optuna._warningsr   optuna.distributionsr	   optuna.samplersr
   optuna.trialr   r   optuna.studyr   r   rG   r   r   <module>rQ      sQ    " $    3 ( 1 ' $ # " GgD+ gD gDr   