L iddlmZddlmZddlmZddlmZddlZddlm Z ddl m Z ddl m Z dd lmZdd lmZerdd lmZe d Gd de Zy)) annotations)Sequence)Any) TYPE_CHECKINGN)experimental_class)BaseDistribution) BaseSampler) FrozenTrial) TrialState)Studyz2.4.0ceZdZdZd dZd dZ d dZ d dZ ddZddZ ddZ y )PartialFixedSampleraSampler 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 ||_||_yN) _fixed_params _base_sampler)self fixed_params base_samplers d/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/optuna/samplers/_partial_fixed.py__init__zPartialFixedSampler.__init__:s))c8|jjyr)r reseed_rng)rs rrzPartialFixedSampler.reseed_rng>s %%'rc|jj||}|jjD] }||vs||= |Sr)rinfer_relative_search_spacerkeys)rstudytrial search_space param_names rrz/PartialFixedSampler.infer_relative_search_spaceAsT))EEeUS ,,113 -J\) , -rc<|jj|||Sr)rsample_relative)rrrr s rr#z#PartialFixedSampler.sample_relativeMs!!11% MMrc ||jvr|jj||||S|j|}|j|}|j |}|st j d|d|d|d|S)NzFixed parameter 'z ' with value z" is out of range for distribution .)rrsample_independentto_internal_repr _containswarningswarn)rrrr!param_distribution param_valueparam_value_in_internal_repr containeds rr&z&PartialFixedSampler.sample_independentVs T// /%%88uj*<  ,,Z8K+=+N+N{+[ (*445QRI ' |= N((:';1> rc<|jj||yr)r before_trial)rrrs rr0z PartialFixedSampler.before_trialqs ''u5rc@|jj||||yr)r after_trial)rrrstatevaluess rr2zPartialFixedSampler.after_trialts &&ueUFCrN)rdict[str, Any]rr returnNone)r6r7)rr rr r6dict[str, BaseDistribution])rr rr r r8r6r5) rr rr r!strr+rr6r)rr rr r6r7) rr rr r3r r4zSequence[float] | Noner6r7) __name__ __module__ __qualname____doc__rrrr#r&r0r2rrrrs#J*(  #.  $ NNN2 N  N  -  66DDD D ' D  Drr) __future__rcollections.abcrtypingrrr)optuna._experimentalroptuna.distributionsroptuna.samplersr optuna.trialr r optuna.studyr rr>rrrGsQ"$ 31'$#"GgD+gDgDr