o
    }oi                      @  s   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 deZdS )    )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                   @  s  e Zd ZdZd[d\d	d
Zdddd]ddZeddejdddd^ddZ	eddejd ddd^d!d"Z
eddejd#ddd_d%d&Zeed'd(d)d*ddd`d+d,Zedad/d0Zedbd2d0Zedcd4d0Zeddd6d0Zeded8d0Zedfd;d0Zdfd<d0Zdgd>d?Zdhd@dAZdidDdEZedFd(didGdHZdjdKdLZedkdMdNZedldPdQZedkdRdSZedkdTdUZedmdWdXZedndYdZZdS )o
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``.

    r   paramsdict[str, Any]numberintreturnNonec                 C  s4   || _ i | _i | _i | _i | _tj | _|| _d S N)	_params_suggested_params_distributions_user_attrs_system_attrsdatetimenow_datetime_start_number)selfr   r    r#   G/home/ubuntu/.local/lib/python3.10/site-packages/optuna/trial/_fixed.py__init__>   s   
zFixedTrial.__init__NF)steplognamestrlowfloathighr&   float | Noner'   boolc             	   C  s   |  |t||||dS N)r'   r&   )_suggestr   r"   r(   r*   r,   r&   r'   r#   r#   r$   suggest_floatG   s   	zFixedTrial.suggest_floatz3.0.0z6.0.0 )args)textc                 C  s   |  |||S r   r2   r"   r(   r*   r,   r#   r#   r$   suggest_uniformR      zFixedTrial.suggest_uniformz(..., log=True)c                 C  s   | j |||ddS )NT)r'   r6   r7   r#   r#   r$   suggest_loguniformV      zFixedTrial.suggest_loguniformz(..., step=...)qc                 C  s   | j ||||dS )N)r&   r6   )r"   r(   r*   r,   r<   r#   r#   r$   suggest_discrete_uniformZ   r;   z#FixedTrial.suggest_discrete_uniformz3.5.0z5.0.0)previous_positional_arg_namesdeprecated_versionremoved_version   c             
   C  s   t | |t||||dS r/   )r   r0   r   r1   r#   r#   r$   suggest_int^   s   zFixedTrial.suggest_intchoicesSequence[None]c                 C     d S r   r#   r"   r(   rC   r#   r#   r$   suggest_categoricalh      zFixedTrial.suggest_categoricalSequence[bool]c                 C  rE   r   r#   rF   r#   r#   r$   rG   k   rH   Sequence[int]c                 C  rE   r   r#   rF   r#   r#   r$   rG   n   rH   Sequence[float]c                 C  rE   r   r#   rF   r#   r#   r$   rG   q   rH   Sequence[str]c                 C  rE   r   r#   rF   r#   r#   r$   rG   t   rH   Sequence[CategoricalChoiceType]r   c                 C  rE   r   r#   rF   r#   r#   r$   rG   w   s   c                 C  s   |  |t|dS )N)rC   )r0   r   rF   r#   r#   r$   rG   |   s   valuec                 C  rE   r   r#   )r"   rN   r&   r#   r#   r$   report   rH   zFixedTrial.reportc                 C  s   dS )NFr#   r"   r#   r#   r$   should_prune   rH   zFixedTrial.should_prunekeyr   c                 C     || j |< d S r   r   r"   rR   rN   r#   r#   r$   set_user_attr   s   zFixedTrial.set_user_attrz3.1.0c                 C  rS   r   r   rU   r#   r#   r$   set_system_attr   r9   zFixedTrial.set_system_attrdistributionr
   c                 C  s   || j vrtd| d| j | }||}||s*td| d| d| d || jv r8t| 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(   rY   rN   param_value_in_internal_reprr#   r#   r$   r0      s"   







zFixedTrial._suggestc                 C     | j S r   )r   rP   r#   r#   r$   r         zFixedTrial.paramsdict[str, BaseDistribution]c                 C  r`   r   )r   rP   r#   r#   r$   r      ra   zFixedTrial.distributionsc                 C  r`   r   rT   rP   r#   r#   r$   
user_attrs   ra   zFixedTrial.user_attrsc                 C  r`   r   rW   rP   r#   r#   r$   system_attrs   ra   zFixedTrial.system_attrsdatetime.datetime | Nonec                 C  r`   r   )r    rP   r#   r#   r$   datetime_start   ra   zFixedTrial.datetime_startc                 C  r`   r   )r!   rP   r#   r#   r$   r      ra   zFixedTrial.number)r   )r   r   r   r   r   r   )r(   r)   r*   r+   r,   r+   r&   r-   r'   r.   r   r+   )r(   r)   r*   r+   r,   r+   r   r+   )
r(   r)   r*   r+   r,   r+   r<   r+   r   r+   )r(   r)   r*   r   r,   r   r&   r   r'   r.   r   r   )r(   r)   rC   rD   r   r   )r(   r)   rC   rI   r   r.   )r(   r)   rC   rJ   r   r   )r(   r)   rC   rK   r   r+   )r(   r)   rC   rL   r   r)   )r(   r)   rC   rM   r   r   )rN   r+   r&   r   r   r   )r   r.   )rR   r)   rN   r   r   r   )r(   r)   rY   r
   r   r   )r   r   )r   rb   )r   re   )r   r   )__name__
__module____qualname____doc__r%   r2   r   _suggest_deprecated_msgformatr8   r:   r=   r   r   rB   r   rG   rO   rQ   rV   rX   r0   propertyr   r   rc   rd   rf   r   r#   r#   r#   r$   r      sd    %




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   rk   r   r#   r#   r#   r$   <module>   s$    