o
    /wi                     @  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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)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"   P/home/ubuntu/sommelier/.venv/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   r1   r!   r'   r)   r+   r"   r"   r#   suggest_uniformR      zFixedTrial.suggest_uniformz(..., log=True)c                 C  s   | j |||ddS )NT)r&   r5   r6   r"   r"   r#   suggest_loguniformV      zFixedTrial.suggest_loguniformz(..., step=...)qc                 C  s   | j ||||dS )N)r%   r5   )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   r/   r   r0   r"   r"   r#   suggest_int^   s   zFixedTrial.suggest_intchoicesSequence[None]c                 C     d S r   r"   r!   r'   rB   r"   r"   r#   suggest_categoricalh      zFixedTrial.suggest_categoricalSequence[bool]c                 C  rD   r   r"   rE   r"   r"   r#   rF   k   rG   Sequence[int]c                 C  rD   r   r"   rE   r"   r"   r#   rF   n   rG   Sequence[float]c                 C  rD   r   r"   rE   r"   r"   r#   rF   q   rG   Sequence[str]c                 C  rD   r   r"   rE   r"   r"   r#   rF   t   rG   Sequence[CategoricalChoiceType]r
   c                 C  rD   r   r"   rE   r"   r"   r#   rF   w   s   c                 C  s   |  |t|dS )N)rB   )r/   r   rE   r"   r"   r#   rF   |   s   valuec                 C  rD   r   r"   )r!   rM   r%   r"   r"   r#   report   rG   zFixedTrial.reportc                 C  s   dS )NFr"   r!   r"   r"   r#   should_prune   rG   zFixedTrial.should_prunekeyr   c                 C     || j |< d S r   r   r!   rQ   rM   r"   r"   r#   set_user_attr   s   zFixedTrial.set_user_attrz3.1.0c                 C  rR   r   r   rT   r"   r"   r#   set_system_attr   r8   zFixedTrial.set_system_attrdistributionr	   c                 C  s~   || j vrtd|| j | }||}||s%td||| || jv r3t	| j| | || j
|< || j|< |S )NziThe value of the parameter '{}' is not found. Please set it at the construction of the FixedTrial object.zNThe value {} of the parameter '{}' is out of the range of the distribution {}.)r   
ValueErrorformatto_internal_repr	_containswarningswarnr   r    check_distribution_compatibilityr   )r!   r'   rX   rM   param_value_in_internal_reprr"   r"   r#   r/      s"   







zFixedTrial._suggestc                 C     | j S r   )r   rO   r"   r"   r#   r         zFixedTrial.paramsdict[str, BaseDistribution]c                 C  ra   r   )r   rO   r"   r"   r#   r      rb   zFixedTrial.distributionsc                 C  ra   r   rS   rO   r"   r"   r#   
user_attrs   rb   zFixedTrial.user_attrsc                 C  ra   r   rV   rO   r"   r"   r#   system_attrs   rb   zFixedTrial.system_attrsdatetime.datetime | Nonec                 C  ra   r   )r   rO   r"   r"   r#   datetime_start   rb   zFixedTrial.datetime_startc                 C  ra   r   )r    rO   r"   r"   r#   r      rb   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(   rB   rC   r   r   )r'   r(   rB   rH   r   r-   )r'   r(   rB   rI   r   r   )r'   r(   rB   rJ   r   r*   )r'   r(   rB   rK   r   r(   )r'   r(   rB   rL   r   r
   )rM   r*   r%   r   r   r   )r   r-   )rQ   r(   rM   r   r   r   )r'   r(   rX   r	   r   r   )r   r   )r   rc   )r   rf   )r   r   )__name__
__module____qualname____doc__r$   r1   r   _suggest_deprecated_msgrZ   r7   r9   r<   r   r   rA   r   rF   rN   rP   rU   rW   r/   propertyr   r   rd   re   rg   r   r"   r"   r"   r#   r      sd    %




r   )
__future__r   collections.abcr   r   typingr   r   r]   optunar   optuna._convert_positional_argsr   optuna._deprecatedr   optuna.distributionsr	   r
   r   r   r   optuna.trial._baser   r   rl   r   r"   r"   r"   r#   <module>   s$    