# Ecological Dynamics and Evolution of Cooperation in Vehicular Ad Hoc Networks
## 3 The Proposed Model Based on Evolutionary Public Goods Game
### Formulation of the Model  
In a typical public goods, all individuals have the opportunity to invest an amount \(c\) into a common pool. The total amount is then multiplied by a positive number \(r\), and is distributed equally among all individuals, regardless of whether they have contributed or not. The average payoffs for cooperators and defectors among N players in an infinite population are given by  
\[\Pi_{\text{C}}(x)=\sum_{j=0}^{N-1}\binom{N-1}{J}x^{j}(1-x)^{N-j-1}\frac{(j+1)c }{N}r-c \tag{1}\]  
\[\Pi_{D}(x)=\sum_{j=0}^{N-1}\binom{N-1}{J}x^{j}(1-x)^{N-j-1}\frac{jc}{N}r \tag{2}\]  
where \(N\) is group size and \(x\) is the relative frequency of the cooperation in the group. In this configuration, every individual has a temptation to defect since the cost of defection is equal to zero. Thus, each rational player avoids contributing and makes an effort to free-ride on contributions of other players. If all players follow this rationality, no one would contribute and, hence, the benefits of the public good would be equal to zero.  
In a well-mixed, infinite population we assume, as is standard, that groups are formed randomly at each generation, after which fitness is calculated. The group size of public goods interactions varies in public goods game with a population of varying densities. Basically, small (large) effective group sizes are induced by small (large) population densities.  
Let us call x, y, and z the frequencies of cooperators, defectors and empty spaces (\(x+y+z=1\)) in the randomly composed group of vehicles to exchange event messages. Therefore, \(x+y\) represents the normalized density of vehicles, such that 1 corresponds to maximum density of the population and 0 shows extinction. The average payoff of cooperators, \(\Pi_{\text{C}}\), and defectors, \(\Pi_{D}\), are calculated by weighting the payoffs obtained in the randomly formed groups of vehicles, weighted by the probability that such group composed.  
In standard PGG the probability of a group composed of \(X\) cooperators and \(N-X\) defectors is given by  
\[B(X,N,x)=\binom{N}{X}x^{X}(1-x)^{N-X} \tag{3}\]  
where \(x\) denotes the fraction of the cooperators. In our problem, the probability of a group composed \(m\) cooperators, \(S-m\) defectors, and \(N-S-1\) empty spaces is \(B(S-1,N-1,z)\times B(m,S-1,\frac{x}{1-z})\). Therefore, the average payoffs of the focal cooperator and defector are given by  
\[\Pi_{\text{C}}=\sum_{S=1}^{N}\left[B(S-1,N-1,z)\sum_{m=0}^{S-1}B(m,S-1,\frac{x }{1-z})\times\frac{(m+1)c}{N}r\right]-c \tag{4}\]  
\[\Pi_{D}=\sum_{S=1}^{N}\left[B(S-1,N-1,x)\sum_{m=0}^{S-1}B(m,S-1,\frac{y}{1-x} )\times\frac{(N-S)c}{N}r\right] \tag{5}\]where \(N\) is the number of vehicles within the diffusion range of the event message by a given vehicle, \(S\) is the number of individuals belonging to either type cooperator or defector, and \(m\) is the number of individuals of type cooperator. The fitness functions (4) and (5) can be reduced to:  
\[\Pi_{\text{C}}=rc\frac{x}{z}\frac{Nz-1+z^{N}}{Nz}+\frac{rc(1-z^{N})}{Nz}-(rc-1)z ^{N-1}-c \tag{6}\]  
\[\Pi_{D}=rc\frac{x}{z}\frac{Nz-1+z^{N}}{Nz} \tag{7}\]