# Multi-Agent System for maximizing the overall reward of all agents?

**URL:** <https://discuss.ray.io/t/multi-agent-system-for-maximizing-the-overall-reward-of-all-agents/1571>\
**Category:** RLlib\
**Created:** [April 6, 2021, 9:33am UTC](https://discuss.ray.io/t/multi-agent-system-for-maximizing-the-overall-reward-of-all-agents/1571 "2021-04-06T09:33:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aronium](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/aronium/32/1068_2.png) [@aronium](https://discuss.ray.io/u/aronium)\
**Post date:** [April 6, 2021, 9:33am UTC](https://discuss.ray.io/t/multi-agent-system-for-maximizing-the-overall-reward-of-all-agents/1571/1 "2021-04-06T09:33:37Z")

</div>

Hello,

maybe you can help me with the following problem.

**System Model:**

We assume two Agents A and B, and their corresponding actions a\_a and a\_b .  
The actions space is defined as {1,2,3}. The numbers correspond to the row and column of the reward matrix.  
The reward matrices are defined as follows:

Reward Matrix for Agent A:  
[11 0 0,  
0 0 0,  
0 0 -10]

Reward Matrix for Agent B:  
[11 0 0,  
0 0 0,  
0 0 100]

Now, Agent A chooses the column and agent B the row. Both observe the reward from their corresponding matrix.

**Optimization Objective**

We want to maximize the overall reward, i.e. the sum of the reward of Agent A and B.

**Whats the question now?**

We solve the above objective by using a centralized critic multi-agent system, following this tutorial ([ray/centralized\_critic.py at master · ray-project/ray · GitHub](https://github.com/ray-project/ray/blob/master/rllib/examples/centralized_critic.py)).

Unfortunately, this system only optimizes the agents individual reward, as seen here:

![Unbenannt](https://us1.discourse-cdn.com/flex020/uploads/ray/original/1X/44d8a8af4f94620c05f4dc5b957bcecffa7cfad5.png)

**Is there any example of a multi-agent system which is suited to our optimization objective, i.e. maximizing the overall reward?**

In our model, this would lead to a overall reward of 90 instead of 22.

Thank you very much.

Best,  
Aaron

---

<div class="post-metadata">

**Author:** ![mannyv](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mannyv/32/606_2.png) [@mannyv](https://discuss.ray.io/u/mannyv)\
**Post date:** [April 10, 2021, 2:43pm UTC](https://discuss.ray.io/t/multi-agent-system-for-maximizing-the-overall-reward-of-all-agents/1571/2 "2021-04-10T14:43:16Z")

</div>

@aronium the reward comes from the environment. What I gleaned from your description is that you have two agents, each is training a seperate policy which means each will store their own samples independently. If you want them to share a global reward then you need to provide that. The natural place to do that is in the environment. I don’t k ow your ultimate goals but one way I would think you do that is to include a “global\_mixing” parameter when constructing the environment and define the reward as some variation of `(own_reward + self.global_mixing * other_reward)` Then you have a continuum where if global\_mixing is 0 each would be maximizing their own individual reward and 1 would be a fully shared global reward.

With your current setup I would expect that you should see a switch from 0 0 to 2 2 in the actions somewhere around .21.
