
    &`i)                         d dl mZ d dlmZmZ d dlmZ d dlmZ d dl	m
Z
  e            \  ZZe G d de                      ZdS )	    )Optional)OldAPIStackoverride)try_import_torch)Schedule)
TensorTypec            	       z     e Zd ZdZ	 	 	 ddedee         dedef fd	Z e	e
          d
edefd            Z xZS )ExponentialSchedulezExponential decay schedule from `initial_p` to `final_p`.

    Reduces output over `schedule_timesteps`. After this many time steps
    always returns `final_p`.
    N      ?皙?schedule_timesteps	framework	initial_p
decay_ratec                     t                                          |           |dk    sJ || _        || _        || _        dS )aG  Initializes a ExponentialSchedule instance.

        Args:
            schedule_timesteps: Number of time steps for which to
                linearly anneal initial_p to final_p.
            framework: The framework descriptor string, e.g. "tf",
                "torch", or None.
            initial_p: Initial output value.
            decay_rate: The percentage of the original value after
                100% of the time has been reached (see formula above).
                >0.0: The smaller the decay-rate, the stronger the decay.
                1.0: No decay at all.
        )r   r   N)super__init__r   r   r   )selfr   r   r   r   	__class__s        /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/rllib/utils/schedules/exponential_schedule.pyr   zExponentialSchedule.__init__   sK    ( 	9---!A%%%%"4"$    treturnc                     | j         dk    r5t          r.t          |t          j                  r|                                }| j        | j        || j        z  z  z  S )z=Returns the result of: initial_p * decay_rate ** (`t`/t_max).torch)r   r   
isinstanceTensorfloatr   r   r   )r   r   s     r   _valuezExponentialSchedule._value-   sP     >W$$$:a3N3N$		A~A8O4O PPPr   )Nr   r   )__name__
__module____qualname____doc__intr   strr   r   r   r   r   r   __classcell__)r   s   @r   r
   r
      s          $(% %% C=% 	%
 % % % % % %4 XhQ
 Qz Q Q Q Q Q Q Q Qr   r
   N)typingr   ray.rllib.utils.annotationsr   r   ray.rllib.utils.frameworkr   "ray.rllib.utils.schedules.scheduler   ray.rllib.utils.typingr   r   _r
    r   r   <module>r.      s          = = = = = = = = 6 6 6 6 6 6 7 7 7 7 7 7 - - - - - -q &Q &Q &Q &Q &Q( &Q &Q &Q &Q &Qr   