docstr: MADDPG algorithm
  
  Args:
      model (parl.Model): forward network of actor and critic.
                          The function get_actor_params() of model should be implemented.
      agent_index: index of agent, in multiagent env
      act_space: action_space, gym space
      gamma (float): discounted factor for reward computation.
      tau (float): decay coefficient when updating the weights of self.target_model with self.model
      lr (float): learning rate, lr will be assigned to both critic_lr and actor_lr
      critic_lr (float): learning rate of the critic model
      actor_lr (float): learning rate of the actor model
docstr_tok: ["MADDPG","algorithm","Args",":","model","(","parl.Model",")",":","forward","network","of","actor","and","critic",".","The","function","get_actor_params","(",")","of","model","should","be","implemented",".","agent_index",":","index","of","agent",",","in","multiagent","env","act_space",":","action_space",",","gym","space","gamma","(","float",")",":","discounted","factor","for","reward","computation",".","tau","(","float",")",":","decay","coefficient","when","updating","the","weights","of","self.target_model","with","self.model","lr","(","float",")",":","learning","rate",",","lr","will","be","assigned","to","both","critic_lr","and","actor_lr","critic_lr","(","float",")",":","learning","rate","of","the","critic","model","actor_lr","(","float",")",":","learning","rate","of","the","actor","model"]
code: def __init__(
      self,
      model,
      agent_index=None,
      act_space=None,
      gamma=None,
      tau=None,
      lr=None,
      actor_lr=None,
      critic_lr=None,
  ):
      """MADDPG algorithm
  
      Args:
          model (parl.Model): forward network of actor and critic.
                              The function get_actor_params() of model should be implemented.
          agent_index: index of agent, in multiagent env
          act_space: action_space, gym space
          gamma (float): discounted factor for reward computation.
          tau (float): decay coefficient when updating the weights of self.target_model with self.model
          lr (float): learning rate, lr will be assigned to both critic_lr and actor_lr
          critic_lr (float): learning rate of the critic model
          actor_lr (float): learning rate of the actor model
      """
  
      assert isinstance(agent_index, int)
      assert isinstance(act_space, list)
      assert isinstance(gamma, float)
      assert isinstance(tau, float)
      # compatible upgrade of lr
      if lr is None:
          assert isinstance(actor_lr, float)
          assert isinstance(critic_lr, float)
      else:
          assert isinstance(lr, float)
          assert (
              actor_lr is None
          ), "no need to set `actor_lr` if `lr` is not None"
          assert (
              critic_lr is None
          ), "no need to set `critic_lr` if `lr` is not None"
          critic_lr = lr
          actor_lr = lr
          warnings.warn(
              "the `lr` argument of `__init__` function in `parl.Algorithms.MADDPG` is deprecated \
                      since version 1.4 and will be removed in version 2.0. \
                      Recommend to use `actor_lr` and `critic_lr`. ",
              DeprecationWarning,
              stacklevel=2,
          )
      self.agent_index = agent_index
      self.act_space = act_space
      self.gamma = gamma
      self.tau = tau
      self.lr = lr
      self.actor_lr = actor_lr
      self.critic_lr = critic_lr
  
      self.model = model
      self.target_model = deepcopy(model)
  
file_path: PARL/parl/algorithms/fluid/maddpg.py
imports: import warnings
  from parl.core.fluid import layers
  from copy import deepcopy
  from paddle import fluid
  from parl.core.fluid.algorithm import Algorithm
  from parl.core.fluid.policy_distribution import SoftCategoricalDistribution
  from parl.core.fluid.policy_distribution import SoftMultiCategoricalDistribution
label_desc: Use image node_id 1 to create a new MADDPG object from inherited base classes: Algorithm with example: obj = MADDPG(model, agent_index, act_space, gamma, tau, lr, actor_lr, critic_lr)