
    Di                         d dl m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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Z G d de      Zy)    )annotations)SequenceN)Any)overload)distributions)convert_positional_args)deprecated_func)optuna_warn)BaseDistribution)CategoricalChoiceType)CategoricalDistribution)FloatDistribution)IntDistribution)_SUGGEST_INT_POSITIONAL_ARGS)	BaseTrialz Use suggest_float{args} instead.c                     e Zd ZdZd)d*dZddd	 	 	 	 	 	 	 	 	 	 	 d+dZ eddej                  d	
            d,d       Z	 eddej                  d
            d,d       Z
 eddej                  d
            d-d       Z eedd      ddd	 	 	 	 	 	 	 	 	 	 	 d.d       Zed/d       Zed0d       Zed1d       Zed2d       Zed3d       Ze	 	 	 	 	 	 d4d       Z	 	 	 	 	 	 d4dZd5dZd6dZd7dZ ed d      d7d!       Zd8d"Zed9d#       Zed:d$       Zed9d%       Zed9d&       Zed;d'       Zed<d(       Zy)=
FixedTriala}  A trial class which suggests a fixed value for each parameter.

    This object has the same methods as :class:`~optuna.trial.Trial`, and it suggests pre-defined
    parameter values. The parameter values can be determined at the construction of the
    :class:`~optuna.trial.FixedTrial` object. In contrast to :class:`~optuna.trial.Trial`,
    :class:`~optuna.trial.FixedTrial` does not depend on :class:`~optuna.study.Study`, and it is
    useful for deploying optimization results.

    Example:

        Evaluate an objective function with parameter values given by a user.

        .. testcode::

            import optuna


            def objective(trial):
                x = trial.suggest_float("x", -100, 100)
                y = trial.suggest_categorical("y", [-1, 0, 1])
                return x**2 + y


            assert objective(optuna.trial.FixedTrial({"x": 1, "y": 0})) == 1


    .. note::
        Please refer to :class:`~optuna.trial.Trial` for details of methods and properties.

    Args:
        params:
            A dictionary containing all parameters.
        number:
            A trial number. Defaults to ``0``.

    c                    || _         i | _        i | _        i | _        i | _        t
        j
                  j                         | _        || _        y N)	_params_suggested_params_distributions_user_attrs_system_attrsdatetimenow_datetime_start_number)selfparamsnumbers      Y/home/ubuntu/crypto_trading_bot/.venv/lib/python3.12/site-packages/optuna/trial/_fixed.py__init__zFixedTrial.__init__>   sG    13;=+--/'00446    NF)steplogc          	     @    | j                  |t        ||||            S N)r&   r%   )_suggestr   r   namelowhighr%   r&   s         r"   suggest_floatzFixedTrial.suggest_floatG   s!     }}T#4S$Cd#STTr$   z3.0.0z6.0.0 )args)textc                (    | j                  |||      S r   r.   r   r+   r,   r-   s       r"   suggest_uniformzFixedTrial.suggest_uniformR   s    !!$T22r$   z(..., log=True)c                ,    | j                  |||d      S )NT)r&   r3   r4   s       r"   suggest_loguniformzFixedTrial.suggest_loguniformV   s    !!$Tt!<<r$   z(..., step=...)c                ,    | j                  ||||      S )N)r%   r3   )r   r+   r,   r-   qs        r"   suggest_discrete_uniformz#FixedTrial.suggest_discrete_uniformZ   s    !!$T!::r$   z3.5.0z5.0.0)previous_positional_arg_namesdeprecated_versionremoved_version   c               R    t        | j                  |t        ||||                  S r(   )intr)   r   r*   s         r"   suggest_intzFixedTrial.suggest_int^   s&     4==sDcPT'UVWWr$   c                     y r    r   r+   choicess      r"   suggest_categoricalzFixedTrial.suggest_categoricalh       ORr$   c                     y r   rC   rD   s      r"   rF   zFixedTrial.suggest_categoricalk   rG   r$   c                     y r   rC   rD   s      r"   rF   zFixedTrial.suggest_categoricaln       MPr$   c                     y r   rC   rD   s      r"   rF   zFixedTrial.suggest_categoricalq   s    QTr$   c                     y r   rC   rD   s      r"   rF   zFixedTrial.suggest_categoricalt   rJ   r$   c                     y r   rC   rD   s      r"   rF   zFixedTrial.suggest_categoricalw   s     !$r$   c                :    | j                  |t        |            S )N)rE   )r)   r   rD   s      r"   rF   zFixedTrial.suggest_categorical|   s     }}T#:7#KLLr$   c                     y r   rC   )r   valuer%   s      r"   reportzFixedTrial.report   s    r$   c                     y)NFrC   r   s    r"   should_prunezFixedTrial.should_prune   s    r$   c                "    || j                   |<   y r   r   r   keyrP   s      r"   set_user_attrzFixedTrial.set_user_attr   s     %r$   z3.1.0c                "    || j                   |<   y r   r   rW   s      r"   set_system_attrzFixedTrial.set_system_attr   s    "'3r$   c           	     j   || j                   vrt        d| d      | j                   |   }|j                  |      }|j                  |      st	        d| d| d| d       || j
                  v r#t        j                  | j
                  |   |       || j                  |<   || j
                  |<   |S )NzThe value of the parameter 'zK' is not found. Please set it at the construction of the FixedTrial object.z
The value z of the parameter 'z*' is out of the range of the distribution .)	r   
ValueErrorto_internal_repr	_containsr
   r   r    check_distribution_compatibilityr   )r   r+   distributionrP   param_value_in_internal_reprs        r"   r)   zFixedTrial._suggest   s    t||#.tf 5= = 
 T"'3'D'DU'K$%%&BCUG#6tf =11=aA
 4&&&::4;N;Nt;TVbc',t$$0D!r$   c                    | j                   S r   )r   rS   s    r"   r    zFixedTrial.params   s    %%%r$   c                    | j                   S r   )r   rS   s    r"   r   zFixedTrial.distributions   s    """r$   c                    | j                   S r   rV   rS   s    r"   
user_attrszFixedTrial.user_attrs   s    r$   c                    | j                   S r   r[   rS   s    r"   system_attrszFixedTrial.system_attrs   s    !!!r$   c                    | j                   S r   )r   rS   s    r"   datetime_startzFixedTrial.datetime_start   s    ###r$   c                    | j                   S r   )r   rS   s    r"   r!   zFixedTrial.number   s    ||r$   )r   )r    dict[str, Any]r!   r@   returnNone)r+   strr,   floatr-   rr   r%   zfloat | Noner&   boolro   rr   )r+   rq   r,   rr   r-   rr   ro   rr   )
r+   rq   r,   rr   r-   rr   r9   rr   ro   rr   )r+   rq   r,   r@   r-   r@   r%   r@   r&   rs   ro   r@   )r+   rq   rE   zSequence[None]ro   rp   )r+   rq   rE   zSequence[bool]ro   rs   )r+   rq   rE   zSequence[int]ro   r@   )r+   rq   rE   zSequence[float]ro   rr   )r+   rq   rE   zSequence[str]ro   rq   )r+   rq   rE   zSequence[CategoricalChoiceType]ro   r   )rP   rr   r%   r@   ro   rp   )ro   rs   )rX   rq   rP   r   ro   rp   )r+   rq   rc   r   ro   r   )ro   rn   )ro   zdict[str, BaseDistribution])ro   zdatetime.datetime | None)ro   r@   )__name__
__module____qualname____doc__r#   r.   r	   _suggest_deprecated_msgformatr5   r7   r:   r   r   rA   r   rF   rQ   rT   rY   r\   r)   propertyr    r   rh   rj   rl   r!   rC   r$   r"   r   r      s   #J "	U	U 	U 		U 	U 	U 
	U Wg,C,J,JPR,J,ST3 U3 Wg,C,J,JPa,J,bc= d= Wg,C,J,JPa,J,bc; d; &B" >?EXX!X),X7:XEIX	X
X
 R RR RP PT TP P$$"A$	$ $MM"AM	M
& Wg&( '(. & & # #     " " $ $  r$   r   )
__future__r   collections.abcr   r   typingr   r   optunar   optuna._convert_positional_argsr   optuna._deprecatedr	   optuna._warningsr
   optuna.distributionsr   r   r   r   r   optuna.trial._baser   r   rx   r   rC   r$   r"   <module>r      sK    " $      C . ( 1 6 8 2 0 ; ( = c cr$   