# Polarization in Political Rallies: A Markovian Agent-Based Model for Opinion Dynamics
## 3 The Markovian Agent Modelling Paradigm
Each position could be identified by a _cell_ numbered with an integer with respect to some reference system, since in this work the space is considered discrete. Each agent \(MA^{c}\) of class \(c\) is defined by the tuple:  
\[MA^{c}=\{\mathbf{Q}^{c},\mathbf{\Lambda}^{c},\mathbf{G}^{c}(m),\mathbf{ \Lambda}^{c}(m),\boldsymbol{\pi}_{0}^{c}\} \tag{2}\]  
where \(\mathbf{Q}^{c}=[q_{ij}^{c}]\) is the \(n_{c}\times n_{c}\) infinitesimal generator matrix of the CTMC that describes the local behavior of a class \(c\) agent, with its element \(q_{ij}^{c}\) representing the transition rate from state \(i\) to state \(j\) (and \(q_{il}^{c}=-\sum_{j\
eq i}q_{ij}^{c}\)). \(\mathbf{\Lambda}^{c}=[\lambda_{i}^{c}]\) is a vector of size \(n_{c}\) whose components represent the rates at which the Markov chain reenters the same state; this can be used to send messages at a specified rate without leaving a state. \(\mathbf{G}^{c}(m)=[g_{ij}^{c}(m)]\) and \(\mathbf{\Lambda}^{c}(m)=[a_{ij}^{c}(m)]\) are \(n_{c}\times n_{c}\) matrices that represent, respectively, the probability that an agent of class \(c\) generates a message of type \(m\) during a transition from state \(i\) to state \(j\), and the probability that an agent of class \(c\) accepts a message of type \(m\) in state \(i\) and immediately transits to state \(j\). \(\pi_{0}^{c}\) is a probability vector of size \(n_{c}\) that represents the agent initial state distribution. The perception function of a multi-agent model (MAM) is formally defined as \(u_{m}\): \(\mathcal{V}\times\mathcal{C}\times\mathbf{N}\times\mathcal{V}\times\mathbf{C }\times\mathbf{N}\rightarrow\mathbb{R}^{+}\). The values \(u_{m}(\mathbf{v},c,i,\mathbf{v}^{\prime},c^{\prime},i^{\prime})\) represent the probability that an agent of class \(c\), located at position \(\mathbf{v}\), and in state \(i\), perceives a message \(m\) generated by an agent of class \(c^{\prime}\) located at position \(\mathbf{v}^{\prime}\) in state \(i^{\prime}\). Perception functions enable different instances of agents deployed in space to interact by sending messages to each other. These interactions are technically implemented through the matrix \(\mathbf{\Gamma}^{c}(t,\mathbf{v},m)\), which is a diagonal  
Figure 2: Graphical representation of MAs. matrix collecting the total rate of received messages \(m\) by an agent of class \(c\) in position \(\mathbf{v}\). Element \(\gamma_{ii}\) stores the total rate of received messages when the agent is in the state \(i\). The elements of \(\mathbf{\Gamma}^{c}(t,\mathbf{v},m)\) are computed as follows. \(\beta_{j}^{c}(m)\) represents the total rate at which messages of type \(m\) are generated by an agent of class \(c\) in state \(j\). This is evaluated using the equation  
\[\beta_{j}^{c}(m)=\lambda_{j}^{c}\,g_{jj}^{c}(m)+\sum_{k\
eq j}q_{jk}^{c}\,g_{jk }^{c}(m). \tag{3}\]  
Let \(\mathbf{\pi}_{j}^{c}(t,\mathbf{v})\) denote the probability vector of class \(c\) agent in position \(\mathbf{v}\). The total rate of messages received by an agent of class \(c\), in state \(i\), in position \(\mathbf{v}\), and at time \(t\) is given by  
\[\gamma_{ii}^{c}(t,\mathbf{v},m)=\sum_{\mathbf{v}^{\prime}}\sum_{c^{\prime}=1} ^{C}\sum_{j=1}^{n_{j^{\prime}}}u_{m}(\mathbf{v},c,i,\mathbf{v}^{\prime},c^{ \prime},j)\beta_{j}^{c^{\prime}}(m)\mathbf{\pi}_{j}^{c^{\prime}}(t,\mathbf{v}). \tag{4}\]  
Rates in (4) are collected into the diagonal matrix \(\mathbf{\Gamma}^{c}(t,\mathbf{v},m)=\text{diag}(\gamma_{ii}^{c}(t,\mathbf{v}, m))\), which is used to compute the kernel (infinitesimal generator matrix) of a class \(c\) agent at position \(\mathbf{v}\) at time \(t\):  
\[\mathbf{K}^{c}(t,\mathbf{v})=\mathbf{Q}^{c}+\sum_{m}\mathbf{\Gamma}^{c}(t, \mathbf{v},m)[\mathbf{A}^{c}(m)-\mathbf{I}]. \tag{5}\]  
The overall MAM thus evolves according to a set of coupled differential equations  
\[\frac{d\mathbf{\pi}^{c}(t,\mathbf{v})}{dt}=\mathbf{\pi}^{c}(t,\mathbf{v})\mathbf{K}^{ c}(t,\mathbf{v}) \tag{6}\]  
under the initial condition \(\mathbf{\pi}_{0}^{c},\forall\mathbf{v}\in\mathcal{V}\), \(\forall c\in\mathcal{C}\).