D YNAMIC N OISES OF M ULTI -A GENT E NVIRONMENTS C AN I MPROVE G ENERALIZATION : A GENT - BASED M ODELS MEETS R EINFORCEMENT L EARNING
A BSTRACT
We study the benefits of reinforcement learning (RL) environments based on agent-based models (ABM).
While ABMs are known to offer microfoundational simulations at the cost of computational complexity, we empirically show in this work that their non-deterministic dynamics can improve the generalization of RL agents.
To this end, we examine the control of an epidemic SIR environments based on either differential equations or ABMs.
Numerical simulations demonstrate that the intrinsic noise in the ABM-based dynamics of the SIR model not only improve the average reward but also allow the RL agent to generalize on a wider ranges of epidemic parameters.
I NTRODUCTION 1. B ACKGROUND AND RELATED WORK
Most dominant learning algorithms rely on single-agent and optimization-based paradigms.
However, many intelligent systems in various domains such as economy, biology, gaming, ecology and sociology are multi-agent and/or decentralized in nature (Ponomarev & Voronkov (2017)).
This calls for the need to i ) design systems accounting for the intrinsic interactions between its multiple components and ii ) investigate the impact of this consideration in the overall performance and the generalization of the existing algorithms.
Generalization has become one of the major challenges of real-world Reinforcement Learning (RL).
Despite the tremendous success of RL in a myriad of applications, the learned policies have difficulty generalizing to new test environments, even when these environments are slightly different from the training ones (Farebrother et al.
; Zhang et al.
; Cobbe et al.
; Song et al.
Indeed, RL agents are commonly trained and evaluated on the same environment, thereby leading to overfitting and biased evaluation (Whiteson et al.
This practice is fundamentally different from supervised learning settings where the optimization and the evaluation are conducted on two separate sets (i.e., train and test sets).
Empirical risk minimization guarantees a good generalization for supervised learning in absence of data distributional shift.
This motivated the construction of similar settings in RL to improve generalization: The agent learns using a training set of contexts or tasks and is evaluated on new unseen test contexts (Cobbe et al.
The existing RL suites for generalization such as OpenAI Procgen (Cobbe et al.
and 2D
CoinRun (Cobbe et al.
(2019)) are solely devoted to quantify generalization in vision-based RL tasks.
To do so, a set of game levels are procedurally generated by varying visual styles and level layouts without changing the environment dynamics.
However, little attention has been given for non-vision RL tasks where the agent is supposed to generalize across different dynamics (Packer et al.
; Peng et al.
This is because artificially perturbing the dynamics of complex non-linear dynamical systems (e.g., fluid dynamics, electromagnetism, etc.)
requires a careful design of the dynamics randomization procedure to avoid unrealistic scenarios (e.g. deterministic chaos, strange attractors).
Such problems are challenging for traditional and deep control methods to handle (Bucci et al.
[Figure]
1. M OTIVATION
As depicted in Fig.
1, we advocate in this work the use of agent-based models (ABM) to design a class of environments for dynamics generalization without the injection of artificial noise.
The motivation behind this work stems from the fact that several real-world applications in social and network sciences rely on complex interactions between the components of the overall simulated system.
The dynamics of the latter are out of reach for mathematical methods (Epstein & Axtell (1996); Colman (1998)), i.e., they cannot be explicitly governed by ordinary differential equations (ODE) or partial differential equations (PDE).
This is in contrast to many real-word applications such as robotics (Kober et al.
, ventilating (Farahmand et al.
and fluid dynamics Pirmorad et al.
(2021) whose complex dynamical systems can be captured using ODEs and PDEs.
Moreover, it has been shown that RL agents are prone to exploiting idiosyncrasies of specific implementations of
RL environments from which they learn infeasible behaviors in the real world (Heess et al.
This fact justifies the need for more realistic simulators for RL environments based on ABMs despite their computational complexity.
ABMs come into play as a computational modelling approach for several dynamical systems based on the microfoundational simulation of heterogeneous interactions across predefined agents with heterogeneous preferences (Bianchi & Squazzoni (2015)).
ABMs capture emergent self-organizing phenomena induced by the interactions of the individuals, leading to a system behavior whose properties are decoupled of the agents’ properties.
This aspect commonly summarized by “the whole is more than the sum of its parts” is a modelling bottleneck because its explicit mathematical description is unknown and/or not easy to obtain.
Furthermore, several ODE/PDE-based RL environments tend to smooth out fluctuations by modelling the average behavior across all the agents.
However, under certain conditions, fluctuations can be amplified when the system is linearly stable but unstable to larger perturbations.
Therefore, simulating a population of agents using dynamic parameters computed from averaging over the behavior of all agents is an oversimplification (Bonabeau (2002)).
Indeed, the behavior of each individual is nonlinear and highly dependent on the dynamics of its neighbors.
For example, some behavioral scenarios can follow a hard-thresholding decision making strategies.
The latter induce a discontinuity in the behavior that cannot be captured by differential equations.
Last but not least, the dynamics of ABMs are non-deterministic due to the randomness in the behavior of each agent.
Hence, they induce intrinsic noises that are not artificially injected to examine the effect of the dynamic randomization on the generalization of the RL agent.
1. C ONTRIBUTIONS
The use of ABMs for the microfoundational simulations of the dynamics of RL environments is not new a idea (Rand (2006); Sert et al.
However, to our best knowledge, the effect of the intrinsic noise in the ABM dynamics on the generalization of RL agents has never been investigated.
In this paper, we benchmark the generalization of an RL agent interacting with a standard epidemic
SIR environment implemented with either ODEs (Kermack & McKendrick (1927)) or ABMs (Perez & Dragicevic (2009))
We first compare the evolution of the SIR dynamics using ODEs and ABMs
Presented at the Gamification and Multiagent Solutions
) to seize the intrinsic noise in the dynamics of the ABM-based SIR environment.
We then randomize the epidemic parameters of the SIR model during both training and inference.
By doing so, we show that an RL agent obtains a significant improvement in the average reward and an ability to generalize across different ABM-based environments whose epidemic parameters correspond to distinct pandemic regimes.
Our work present an empirical evidence about the relationship between
ABM-based environments and RL generalization, thereby calling for the need to further investigate this relationship in future work.
T HE ABM- BASED RL ENVIRONMENT : THE SIR MODEL AS A STUDY CASE 2. T HE ODE- BASED SIR DYNAMICS
The spread of a disease can be modelled using the well-known SIR model Kermack & McKendrick (1927).
The latter divides the (fixed) population of N individuals into the following three varying group of individuals over the time t (measured in days):
• S ( t ) is the number of susceptible but not yet infected individuals, • I ( t ) is the number of infected individuals, • R ( t ) is the number of recovered individual from the disease, and hence are naturally immunized.
Using the finite state machine representation, these three groups are associated to three states as shown in Fig.
The transition between them is governed by two key parameters:
• β represents the effective contact rate of the disease.
At every time step t , an infected individual in the group I ( t ) comes into contact with a sub-population of size β N corresponding to the fraction S ( t ) /N
( t ) of individuals that are susceptible to contract the disease.
• γ is the mean recovery rate.
This corresponds to a mean period of time, γ − 1 , during which an infected individual among the group
I ( t ) can spread the virus to its contacts.
[Figure]
Recovered
The dynamics of this system can also be formulated using the following set of differential equations (Kermack & McKendrick (1927)):
[Equation]
2. T HE ABM- BASED SIR DYNAMICS
We consider a complete undirected graph between N homogeneous agents.
Each agent can be in one of the three possible SIR states in Fig 2.
At each time step, if the agent is infected, it transmits the disease with a probability p trans =
β/N to each neighboring agent in the susceptible state.
Moreover, each infected agent transits to the recovered state after γ − 1 time steps (in days).
The choice of the complete graph topology stems from the fact that it captures more accurately the idea of the aggregate population.
In other words, the more interactions between agents are allowed, the closer the average dynamics of the ABM becomes as compared to the ODE-based one.
2. T HE INTRINSIC NOISE IN THE ABM- BASED SIR DYNAMICS
To verify our implementation of the SIR model with an ABM, we compare the ABM-based dynamics vs. the ODE-based one.
Fig.
3 depicts the time evolution of the number of individuals belonging to the susceptible, infected, and recovered populations, namely, S ( t ) , I ( t ) and R ( t ) , respectively.
There, it is seen that the values produced by the ODE model (in solid lines) and the ABM (in dashed lines) converge to approximately the same values.
This validates the asymptotic behavior of the
ABM model against the ODE model.
We also observe a discrepancy between the time evolution of the ABM-based and ODE-based values.
This is due to the realistic discrete behavior of the agents as opposed to the averaged one from the ODE.
The “microscopic modelling” of ABMs lead to significant deviations from predicted aggregate behavior based on the coarse-grained models (Moein et al.
[Figure]
ABM, infected
ABM, recovered
ABM, susceptible
ODE, susceptible
ODE, recovered
ODE, infected
The observed deviations from one single simulation to another can be seen as an intrinsic noise in the ABM-based dynamics shown in Fig.3.
This non-deterministic aspect of ABM simulations are different from the artificial noise incorporation to deterministic ODE-based dynamics in order to study generalization in RL.
S IMULATION RESULTS
In this section, we empirically show how the intrinsic noise in ABM-based dynamics can be beneficial for RL generalization.
To this end, we consider two pandemic propagation regimes: a lowspreading one with β = 0 .
2 and a wide-spreading one with β = 0 .
We train an RL agent using proximal policy optimization (PPO) (Schulman et al.
(2017)) to choose an action from the set
A = { lockdown , social distancing , open } to control three SIR models:
• ODE : an ODE-based SIR model as described in subsection 2.1; •
Randomized ODE : an ODE-based SIR model with dynamics randomisation at each time-step of each episode, where the SIR state ( S ( t ) , I ( t ) , R ( t ) ) is perturbed with a noise sampled from a uniform probability mass distribution between 1 and 10 individuals.
• ABM : an ABM-based SIR model as described in subsection 2.2.
We train and evaluate the RL agent interacting with each one of the aforementioned environments with the default parameters of the PPO implementation of the stable baselines (Raffin et al.
We evaluate the RL agent on 5000 episodes.
The number of evaluation episodes was chosen such as the evaluation time of ABMs does not exceed 12 hours.
To investigate the learned policies of the RL agents [Table] we present in Tables 1 and 2 the distribution of the actions for wide- and low- spreading pandemics, respectively.
We also report the average reward during the evaluation in Table
[Table] [Table]
[Table] [Table]
We observe that the uniform randomisation of the ODE dynamics has drastically shifted the action distribution of the RL agent and led to a poor average reward in both pandemic regimes.
This confirms that the blind randomization of the dynamics cannot be beneficial without domain knowledge, unlike visual-based randomization (Lee et al.
Moreover, we observe that the RL agent trained on an ABM-based environment achieves a high average reward in the evaluation.
Its policy has shifted from being ignorant of the pandemic dynamics (i.e., almost picks the action “open”) in the low-spreading pandemic to a policy that consider social distancing with a frequency of 20% in the wide-spreading regime.
This suggests that the noise introduced by the non-deterministic dynamics of ABMs from one episode to another has improved the overall averaged reward.
Further experiments should be conducted over a higher number of Monte
Carlo simulations to validate this fact.
Finally, we evaluate the generalization of the trained RL agents on test pandemic regimes with different β values.
To this end, we randomly sample the values of the parameter β between 0 . 2 and 0 .and run the learned policies on the train regimes (i.e., low and wide spreading pandemic regimes).
Figure 4 illustrates the obtained results.
It shows that the agent trained with ABM-based environments is able to generalize to different pandemic parameters and maintain similar performance (i.e., 2 . 3% decrease) as in the train regimes.
However, using ODE-based environments, we observe that there is a decrease in the performance (approximately 8% ).
This confirms that ABMs can offer a
[Figure]
ABM 0.
A v e r a g
e R e w a r d
Train
Test better design of RL environments not only for the sake of realistic modelling but also for RL generalization because of their non-deterministic dynamics.
Moreover, our results highlight that artificially injecting noise in the agent state did not improve generalization (i e., negative average reward) on the contrary to the common practice in generalization and sim-to-real works, e.g., (Peng et al.
C ONCLUSION
In this work we empirically demonstrated that ABM-based modeling improves the performance and generalization of RL agents due to the intrinsic noise of their dynamics.
Our experiments showed that dynamics randomization through random perturbation leads to deterioration of the agent’s performance thereby calling for a more careful design of simulated environments for better generalization.
We therefore advocated ABM-based modeling as an approach to tackle dynamics randomization without artificial noise injection during training.