KAOS: A Kinetic Theory Tool for Modeling Complex Social Systems

. The kinetic theory approach is successfully used to model complex phenomena related to social systems, allowing to predict the dynamics and emergent behavior of large populations of agents. In particular, kinetic theory for active particles (KTAP) models are usually analyzed by numerically solving the underlying Boltzmann-type differential equations through ad-hoc implementations. In this paper, we present KAOS: a kinetic theory of active particles modeling and analysis software tool. To the best of our knowledge, KAOS represents the first attempt to design and implement a comprehensive tool that assists the user in all the steps of the modeling process in the framework of the kinetic theories, from the model definition to the representation of transient solutions. To show the KAOS features, we present a new model capturing the competition/cooperation dynamics of a socio-economic system with welfare dynamics, in different socio-political conditions


Introduction
Long since mathematical methods traditionally applied in physics have been applied in interdisciplinary fields such as biology, economy or social sciences. For a review of methods borrowed from statistical physics and applied to interdisciplinary fields, see [1], while an historical perspective can be found in [2]. The micro-scale approach to complex systems is that of agent-based models, where rule-based agents dynamically interact. The approach of Complex Adaptative Systems combines agent-based and complex network based models [3]. Widespread models using this approach are Cellular Automata models (for a review of applications see [4]). The approach at the macro-scale, basically borrows ideas from the principles of fluid dynamics (for examples in vehicular traffic, see [5,6] and references therein). Frameworks as Sociodynamics [7] and Sociophysics [8] arise from a dynamical systems approach to the modeling of phenomena in social sciences. The kinetic theory mathematical framework has been applied to many different interdisciplinary contexts; for a review of the literature and many interesting examples, see [9]. The Kinetic Theory of Active Particles (KTAP) adopts the general approach of the classical kinetic theory, although introducing interactions modeled using methodologies borrowed from the evolutive theory of stochastic games. In many applications, the analytic solutions may be no longer feasible; in these cases, a software tool could help in testing in a simple and quick way the predictive ability of kinetic models with respect to the reference application. Examples can be the consensus vs. polarization in opinion formation [10] or the radicalization of the economic gap in a society [11]. In this paper, we present a new model of wealth redistribution testing the emergence of patterns in the wealth micro-state of individuals and we introduce the KAOS software tool, a kinetic theory of active particles modeling and analysis framework. We also show how KAOS can help in analyzing such complex models. In fact, it has been designed with the purpose of assisting domain experts in studying emergent behaviors in a simple way without knowing the mathematical details of the underlying kinetic theory. We show a set of numerical results obtained by changing the model parameters in order to represent different societies coupled to political actions.

Kinetic Theory for Active Particles
The founding idea of kinetic models for living systems is that a system composed of a sufficiently large number of living beings can be described using the laws of statistical mechanics, as it happens in a physical system composed of many interacting particles [9]. However, it is necessary to consider that the main actors are not particles but living beings and that their interactions can be described as stochastic evolutive games [12,13] rather than as binary elastic collisions as in the classical Boltzmann equations. Hallmarks of KTAP, when applied to the modeling of social systems, are: 1. The overall system is a large population of entities, called active particles, whose micro-state is characterized is characterized by a variable called activity representing a social attribute. 2. The state of the system is defined by a suitable time dependent probability distribution over the micro-state space. 3. Interactions between active particles are modeled as stochastic evolutive games, where the state of the interacting particles and the output of the interactions are known only in probability. 4. The evolution of the probability distribution is obtained by a balance of particles within the elementary volume of the micro-state space, where the dynamics of inflow and outflow of particles is related to the interactions at the micro-scale. The general micro-state of the active particles can be represented as ‫ݑ‬ ∈ ‫ܦ‬ ௨ ⊂ ℝ , where ‫ݑ‬ is the activity (which refers to a social state) and it is assumed that a measure of the distance between two element in ‫ܦ‬ ௨ is defined. A distribution function on the micro-state space , describing the overall state of the system, where ܶ is a reference time. Three types of active particles are introduced: the candidate particle which interacts with a field particle and acquires, with a given probability, the state of a test particle; only binary interactions are considered. The rate of variation of the number of active particles is given by a balance of inlet and outlet fluxes in the micro-state space. In KTAP, interactions are considered as stochastic games whose payoff is the micro-state acquired by the interacting active particles which is given in probability and whose rules may depend on the distribution itself, thus evolving in time; in this sense one may speak of evolutive stochastic games. The specific 'game' played depends on the specific phenomenon under observation and it is phenomenologically determined. In the following we will briefly introduce two particular kind of interactions often used in the applications; for both of them a threshold triggers the dynamics.
Competition/Cooperation. The competition dynamics takes place when the activity distance related to the interacting particles, i.e. the difference between the activity variable values of the interacting particles, is less than a given threshold μ; it mimics the fact that when the particles share a common niche, they tend to behave competitively and the result of the interaction is that they may increase their activity distance. The cooperation dynamics takes place in the opposite situation, i.e. when the activity distance between the interacting particles is above the given threshold; in this case the active particles are induced to behave cooperatively, thus reducing their activity distance.
Consensus/Dissent. The consensus dynamics takes place when the activity distance between the interacting active particles is less than a given threshold and the dissent dynamics in the opposite situation. In the consensus dynamics the post-interaction activity distance is shorter than the pre-interaction one; basically, the active particles 'approach' each other due to the interaction. In the dissent dynamics, the post-interaction active distance is greater than the pre-interaction one; basically the active particles move away from one another, with respect to the activity variable. This dynamics generalizes the well-known Bounded Confidence Model of statistical physics [14].

Discrete activity models
If the variable ‫ݑ‬ ∈ ‫ܦ‬ ௨ is discretized, activities are written as ‫ݑ{‬ }, ݅ = 1, … , ܰ, and the probability distribution on the micro-state space Since we do assume that the number of particles does not change over time in the considered time period, the probability density Interactions are stochastic games involving the candidate particle with activity ‫ݑ‬ which, due to the interaction with the field particle with activity ‫ݑ‬ attains the micro-state ‫ݑ‬ of the field particle. The general Boltzmann-type equation takes the form of a system of ordinary differential equations Supplemented by the initial condition ݂(0). In order to derive explicit expressions for Eq. (2.1), we need to specify the following quantities: ߟ = ‫ݑ(ߟ‬ , ‫ݑ‬ ) -rate of interactions between the candidate particle with micro-state ‫ݑ‬ and the field particle with micro-state ‫ݑ‬ . ी = ी(‫ݑ‬ → ‫ݑ‬ , ‫ݑ‬ , ‫ݑ‬ , ) -transition probabilities (also called table of games) defining the probability for a candidate active particle characterized by ‫ݑ‬ to shift to the micro-state ‫ݑ‬ due to an interaction with a field active particle characterized by ‫ݑ‬ , . It may depend on the distribution through macroscopic quantities such as statistical moments, thus introducing nonlinearities in the model [11,15]. We introduce here an explicit form regarding the transition probability matrix in the case of competition/cooperation dynamics of interactions, which is the case we consider as example is Sec.4. The interaction of the type cooperation applies when ‫ݑ|‬ − ‫ݑ‬ | ≥ ߤ, with 0 < ߤ < ܰ and, in the case of wealth dynamics it represents wealth redistribution (i.e. through taxation). Under the cooperation interaction, the candidate active particle has a given probability to shift to an activity value which is nearer to the activity value of the field active particle, then the output of the interaction is in the interval between the candidate active particle activity and the field particle one. To define the explicit form of ी, let us define the following quantities: ݀ = min(‫ݑ‬ , ‫ݑ‬ ) and ‫ܦ‬ = max(‫ݑ‬ , ‫ݑ‬ ). The elements of the table of games related to the cooperation interaction are thus: in KAOS could set as ‫‬ = ߚ + ߚ ॸ , where ॸ is a macroscopic quantity, weighted by the nonlinearity factor ߚ, and such that 0 ≤ ॸ ≤ 1. As an example, ॸ can be the first order moment normalized with respect to the number of clusters ܰ, in opinion dynamics, modeling the stream induced by the mean opinion in the society (majority rule). The linearity coefficient ߚ instead models the intensity of the effect of the interaction. As a second possibility, the ߙ() distribution could be set as a discrete uniform distribution on [݀, ‫.]ܦ‬ The competition interaction applied when the activity distance between the candidate and the field particle is less than the given threshold μ; in the case of wealth dynamics, it represents the economic competition that may start when two active particles shares the same economic niche. In this case, ‫ݑ‬ and ‫ݑ‬ are such that ‫ݑ|‬ − ‫ݑ‬ | < ߤ. In the competition dynamics, the candidate active particle has a probability to shift to an activity value which is farther with respect to the activity value of the field active particle due to the interaction, thus approaching one of the two extremes of the activity state space. In this case, the table of games reads: Similarly to the cooperation interaction, ‫ݑ(ߙ‬ ‫ݑ|‬ , ‫ݑ‬ , ) can be set according to the first-neighbor or uniform distribution.

The KAOS software tool
We designed and implemented KAOS, a tool for the definition and the transient solution of KTAP models. KAOS is implemented as an open source tool and it is publicly available on the Web (https://github.com/MDSLab/KAOS). The modeler can graphically represent the KTAP model by enumerating the number of clusters (depicted as circles in the central panel) Model parameters can be set by filling the text fields in the Model Parameters box on the right. In particular, the number of clusters ܰ, the encounter rate η, the interaction mode, and the transition probabilities (table of games) can be set. In the Initial Condition box, the modeler can set the initial condition in terms of the probability distribution on the clusters at ‫ݐ‬ = 0. Finally, in the Solution Parameters box, the final time and the time step of the transient analysis can be set. At the time being, the tool supports competition/cooperation, consensus/dissent and user-defined interaction modes. If one of the two modes competition/cooperation or consensus/dissent is set, the modeler has to choose the value of the threshold μ. The tool allows to set a first neighbor approach or a uniform distribution. If the first neighbor approach is chosen, the modeler can choose between a linear solution (i.e. the transition probability is constant along the whole solution) or a non-linear one (i.e. the transition probability changes as a function of the probability distribution itself at the considered time instant through a non-linearity factor). In this case the table of games is automatically generated and updated by the tool at each step of the solution. All these choices are performed through user-friendly wizards. In the userdefined interaction mode, the modeler is free to set the table of games as he/she wants. KAOS helps the modeler in modeling the interactions by representing the candidate particle in gray and moving it to the central position. The field particle is represented in yellow and moved externally while the other particles are kept white and maintained in their original positions. Arrows represent transitions from the candidate particle to the test particles and the modeler is allowed to insert user-defined transition probabilities for each cluster transition. Once the model has been fully specified, the solution can be started. KAOS implements a transient analysis and it graphically provides the time trend of the expected value of the probability distribution on the clusters from ‫ݐ‬ = 0 to ‫ݐ‬ = ܶ ௫ with steps equal to ‫ܶܽݐ݈݁ܦ‬ , as set by the modeler. Moreover, it provides the probability distribution on the micro-state space at ‫ݐ‬ = ܶ ௫ .   We introduce a mathematical model for the redistribution of wealth in a society, numerically analyzing the resulting emergent behaviors. Active particles represent here individuals whose micro-state is characterized by individual's wealth. A wealth probability distribution characterizes the mesoscopic system and the related moments are the macroscopic variables representing the mean wealth within the society (first moment) or, in general, other macroscopic quantities (higher moments). We modela process based on a competition/cooperation dynamics. It mimics the fact that when the interacting active particles shae the same economic niche a competition between them may take place, whilst when they have wealth variables that are sufficiently distant a cooperation may start, as an effect of a welfare policy. The involved parameters are: the number of wealth classes ܰ (Number of clusters in KAOS); the frequency of interactions between active particles η (encounter rate in KAOS); the degree of liberalism in the society μ (Distance in KAOS); the level of economic activity in competitive dynamics and the level of fiscal pressure in cooperative dynamics, both indicated as ߚ (Neighbor Probability in KAOS); the stream factor weighting the influence of macroscopic quantities on the dynamics ߚ (Non-linearity Factor in KAOS). We used KAOS to numerically explore solutions of the model in the following two case studies.

A KTAP welfare model with KAOS
Case study I. We model the effect of two different welfare policies on a society with an initial wealth distribution with prevalent presence of 'middle' wealth classes. The whole society is represented by ܰ = 11 wealth classes. A low threshold represents a more enhanced welfare policy (ߤ = 3) whilst an high threshold ( ߤ = 9 ) represents a policy enhancing economic competition. The initial distribution is chosen such that ݂ = 1/21 for classes with ݅ = 0,1,2,3,4,9,10 and ݂ = 1/6 for classes with ݅ = 5,6,7,8, while ߚ =0.6 is the transition parameter. We compare the results obtained in the linear case, i.e. .for ߚ ଵ =0, with those obtained in the nonlinear case, with ߚ ଵ =0.4 (in both cases we used the first-neighbor table of games), with those obtained in the uniform distribution case. The obtained result are depicted in Figures 1, 2, 3 and 4. The value of μ can be considered, in this example of welfare policy, as the action of the goverrnrnent; smaller values model more cooperative actions among the wealth classes, whilst greater values introduce stronger competition. For a small value of the threshold, the society tends to evolve towards a middle class prevalence (Figure 1), instead in the case of an higher threshold the extreme competition creates higher inequalities in the society (Figure 2). In the nonlinear case, we have chosen ॸ = ∑ ݂ ଵଵ ୀ − ∑ ݂ ସ ୀ quantifying a social gap [11], i.e. socio-economic inequalities in the society; in the case of low threshold the stream effect of the social gap of the society on the evolution of the wealth distribution has strong impact.     Case study II. We model the case of a welfare policy represented by a medium threshold (ߤ = 5) on societies with different initial wealth distributions. In particular, we obtained the solutions for initial wealth distributions with prevalent 'poor' classes (݂ = 1/6 for classes with ݅ = 0,1,2,3 and ݂ = 1/21 for classes with ݅ = 4,5, 6,7,8,9,10) and with prevalent 'rich' classes (݂ = 1/21 for classes with ݅ =0,1,2,3,4,5,6 and ݂ = 1/6 for classes with ݅ = 7, 8,9,10). In this case, for each solution we compare the results obtained in the case of non-linear first-neighbor table of games ( ߚ ଵ =0.4) with those obtained in the case of uniform distribution table of games. As in the previous case study, we used as nonlinearity function the social gap. The results obtained are depicted in Figures 5,6,7 and 8. The stream effect of the social gap of the society is evident for both nonlinear solutions.

Conclusions
KTAP theory is a powerful framework for the modeling of complex social systems. However, no comprehensive tools are available to help the modeler in describing and analyzing specific systems without the knowledge of the underlying mathematical details. In this paper, we introduce KAOS, a tool that fills this gap. We also proposed a model able to predict wealth dynamics in a complex society as a function of the society composition and the political governance, showing several numerical results. Even if in the proposed model the microscopic state of the agents is fully characterized by a single real variable and a single population, without the effect of external field agents, our final goal is to improve KAOS with the ability of managing many interacting populations on a network structure supporting the possibility to easily test many other already existing models.