
    h                         S SK JrJrJrJr  S SKrS SKJr  S SK	J
r
  S SKJrJrJr  S SKJr  S SKJr  \" SS	S
9r " S S	\5      rg)    )AnyOptionalTypeVarUnionN)ReplayBuffer)ActionNoise)GymEnvMaybeCallbackSchedule)	TD3Policy)TD3SelfDDPGDDPG)boundc            +         ^  \ rS rSrSr                   S#S\\\\   4   S\\	\4   S\\
\4   S\S\S\S	\
S
\
S\\\\\4   4   S\S\\   S\\\      S\\\\4      S\S\S\\   S\\\\4      S\S\\   S\\R*                  \4   S\4*U 4S jjjr     S$S\S\S\S\S\S\S\S \4U 4S! jjjrS"rU =r$ )%r      a&
  
Deep Deterministic Policy Gradient (DDPG).

Deterministic Policy Gradient: http://proceedings.mlr.press/v32/silver14.pdf
DDPG Paper: https://arxiv.org/abs/1509.02971
Introduction to DDPG: https://spinningup.openai.com/en/latest/algorithms/ddpg.html

Note: we treat DDPG as a special case of its successor TD3.

:param policy: The policy model to use (MlpPolicy, CnnPolicy, ...)
:param env: The environment to learn from (if registered in Gym, can be str)
:param learning_rate: learning rate for adam optimizer,
    the same learning rate will be used for all networks (Q-Values, Actor and Value function)
    it can be a function of the current progress remaining (from 1 to 0)
:param buffer_size: size of the replay buffer
:param learning_starts: how many steps of the model to collect transitions for before learning starts
:param batch_size: Minibatch size for each gradient update
:param tau: the soft update coefficient ("Polyak update", between 0 and 1)
:param gamma: the discount factor
:param train_freq: Update the model every ``train_freq`` steps. Alternatively pass a tuple of frequency and unit
    like ``(5, "step")`` or ``(2, "episode")``.
:param gradient_steps: How many gradient steps to do after each rollout (see ``train_freq``)
    Set to ``-1`` means to do as many gradient steps as steps done in the environment
    during the rollout.
:param action_noise: the action noise type (None by default), this can help
    for hard exploration problem. Cf common.noise for the different action noise type.
:param replay_buffer_class: Replay buffer class to use (for instance ``HerReplayBuffer``).
    If ``None``, it will be automatically selected.
:param replay_buffer_kwargs: Keyword arguments to pass to the replay buffer on creation.
:param optimize_memory_usage: Enable a memory efficient variant of the replay buffer
    at a cost of more complexity.
    See https://github.com/DLR-RM/stable-baselines3/issues/37#issuecomment-637501195
:param n_steps: When n_step > 1, uses n-step return (with the NStepReplayBuffer) when updating the Q-value network.
:param policy_kwargs: additional arguments to be passed to the policy on creation. See :ref:`ddpg_policies`
:param verbose: Verbosity level: 0 for no output, 1 for info messages (such as device or wrappers used), 2 for
    debug messages
:param seed: Seed for the pseudo random generators
:param device: Device (cpu, cuda, ...) on which the code should be run.
    Setting it to auto, the code will be run on the GPU if possible.
:param _init_setup_model: Whether or not to build the network at the creation of the instance
policyenvlearning_ratebuffer_sizelearning_starts
batch_sizetaugamma
train_freqgradient_stepsaction_noisereplay_buffer_classreplay_buffer_kwargsoptimize_memory_usagen_stepstensorboard_logpolicy_kwargsverboseseeddevice_init_setup_modelc                    > [         TU ]  UUUUUUUUU	U
UUUUUUUUUUSSSSS9  SU R                  ;  a  SU R                  S'   U(       a  U R                  5         g g )N   g        g?F)r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r#   r"   r$   r&   r%   policy_delaytarget_noise_cliptarget_policy_noiser'   	n_critics)super__init__r#   _setup_model)selfr   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   	__class__s                         U/home/james-whalen/.local/lib/python3.13/site-packages/stable_baselines3/ddpg/ddpg.pyr/   DDPG.__init__9   s    0 	'#+!!)% 3!5"7'+ ! ##5 	 	
< d000./D{+     r1   total_timestepscallbacklog_intervaltb_log_namereset_num_timestepsprogress_barreturnc           	      (   > [         TU ]  UUUUUUS9$ )N)r6   r7   r8   r9   r:   r;   )r.   learn)r1   r6   r7   r8   r9   r:   r;   r2   s          r3   r>   
DDPG.learnu   s-     w}+%# 3%  
 	
r5    )gMbP?i@B d      g{Gzt?gGz?r)   r)   NNNFr)   NNr   NautoT)N   r   TF)__name__
__module____qualname____firstlineno____doc__r   strtyper   r	   floatr   inttupler   r   r   dictr   boolthr&   r/   r   r
   r>   __static_attributes____classcell__)r2   s   @r3   r   r      s   (\ 15$"23.2<@9=&+)-26"(."&-: c4	?*+:  63;:  UH_-	: 
 :  :  :  :  :  #uS#X./:  :  {+:  &d<&89:  'tCH~6:   $:   !: " "##: $  S#X/%: & ': ( sm): * biin%+: ,  -:  : ~ #'!$("


  
 	

 
 "
 
 

 
r5   )typingr   r   r   r   torchrQ    stable_baselines3.common.buffersr   stable_baselines3.common.noiser   %stable_baselines3.common.type_aliasesr	   r
   r   stable_baselines3.td3.policiesr   stable_baselines3.td3.td3r   r   r   r@   r5   r3   <module>r[      s:    0 0  9 6 Q Q 4 ):V,w
3 w
r5   