Machine learning phases in swarming systems

Recent years have witnessed a growing interest in using machine learning to predict and identify phase transitions (PTs) in various systems. Here we adopt convolutional neural networks (CNNs) to study the PTs of Vicsek model, solving the problem that traditional order parameters are insufficiently able to do. Within the large-scale simulations, there are four phases, and we confirm that all the PTs between two neighboring phases are first-order. We have successfully classified the phase by using CNNs with a high accuracy and identified the PT points, while traditional approaches using various order parameters fail to obtain. These results indicate the great potential of machine learning approach in understanding the complexities in collective behaviors, and in related complex systems in general.

Introduction -Active matter emerged as a novel class of non-equilibrium systems, in which individual components absorb energy from their surroundings and, in some way, transform it into mechanical work [1][2][3].Examples are ubiquitous in nature, ranging from bacteria colonies, cells [4][5][6], bird flocks, to fish schools [7,8], and human crowds [9,10].These systems have been the subject of numerous experimental and theoretical investigations in recent years.Due to the grand challenge in understanding the non-equilibrium nature of active matter, several minimal models have been proposed in recent years to capture the physical principles therein [11].Among them, the Vicsek model is the most well-known [12], and has considerably advanced our understanding in the physics behind.It models the swarming population as a group of self-propelled particles, the qualitative change in the collective behaviors is described by the phase transitions (PTs).The nature of orderdisorder PT, however, was once controversial.The early studies claimed that this PT is similar to an equilibrium continuous transition, but later this conclusion was challenged by large-scale simulations and is confirmed that it is discontinuous, like a liquid-gas transition with phase separation [13,14].In fact, there are three rather than simply two phases (ordered and disordered), i.e. the disordered gas-like state, the ordered liquid-like state, and the coexistence of ordered bands and disordered gas due to the density-velocity feedback [15,16].More recently, with Eigen microstates approach, Ref. [17] revealed that the phase transition in the Vicsek model is essentially a hybrid of continuous and discontinuous PTs, with the discontinuous component dominating as the system size goes infinity.This new perspective well reconciles and terminates the debates of the order-disorder PT.
Interestingly, the latest study [18] identified a fourth phase, i.e. the cross sea phase, in the ordered region, which is self-organized, as there is no external driving force.This new phase is not simply a superposition of two band waves, but an independent complex pattern with an inherently selected crossing angle.Therefore, there are four different phases identified so far in the Vicsek model: the ordered phase, the cross sea phase, the band phase, and the disordered phase.Precisely identifying these phase transition points, however, now becomes extremely challenging.
Identifying phase transitions is to pin down boundaries between different phases of systems, a fundamental task in understanding the physics of complex systems.Traditionally, the polar order parameter is computed to classify the different phases, which is often useful, e.g. in studying the ordered-disordered phases transition [12].However, no jump in the average polar order parameter is seen at the transition towards the band-disordered phases, and it's also found insensitive around the cross sea phase [18].Therefore, other quantities such as the Binder cumulant [15] and the structural order parameter are proposed [18], helping to better distinguish different phases.But it is not a prior clear how to properly choose the right order parameters for many non-equilibrium systems without a trial-and-error process.Comparatively, the identification of different phases according to typical snapshots is more accurate, but this classification approach by human eyes has its limitations when the number of snapshots is huge, but is usually required to precisely determine the regions of different phases [18,19].
In recent years, machine learning flourishes for its great momentum into almost every branch of science [20][21][22].Not surprisingly, machine learning methods have been proposed to study the matter phases [23][24][25].The general idea behind several works [26][27][28][29][30] is to use supervised learning; sampling the physical states for several phases, put these labeled configuration information as the training data set to train the neural networks; once the training is completed, the neural networks can be used to estimate the probabilities of testing data that belong to different phases; finally, the phase transitions can be inferred based on these probabilities.Machine learning is not only very effective in studying phase transitions in classic models, but also has remarkable ability to reveal various phases of matter in quantum many-body systems [31][32][33][34].The current studies indicate its great potential in identifying phase transitions in complex systems, for its extraordinary advantages over traditional methods.
In this work, we employ the convolutional neural network (CNN) [22,26,35] to classify different phases in Vicsek model according to the sampled snapshots.By large-scale simulations of Vicsek model, we first numerically confirm that all phase transitions in each of the two neighboring phases are first-order.By adopting various order parameters to analyze the phase transitions, we find that the boundaries for different phases are fuzzy due to the insensitivity of these order parameters, and even the types of phase transitions cannot be determined.But the supervised learning based on CNNs conquers these difficulties, which successfully classifies all four phases.The precision of phase classification is robust to the choice of order parameters.
The model -In the standard Vicsek model [12], N self-propelled particles with a constant velocity v 0 that move in a two-dimensional domain of size L × L with the periodic boundary condition.They move synchronously at discrete time steps by a fixed distance v 0 ∆t.Each particle i is endowed with an angle θ i that determines the movement direction.Its update is determined by the average orientations of its neighbors (defined as particles within a circle of radius R = 1 centered around particle i, including itself) plus some noise.Specifically, where Θ[v] represents the angle that describes the di- rection of the two dimensional vector v and d ij is the distance between particle i and j.The noise ξ i is chosen from the uniform distribution within the interval [−1/2, 1/2], and η is the noise amplitude.In our study, the density ρ = 0.5 and v 0 = 1.0 are fixed throughout the study.
Results and analysis -We first report typical snapshots in Fig. 1 to provide the overall picture for the Vicsek model when the noise is varied.For small noise, the Here, the bistablity and the phase coexistence in Fig. 1(V I) are confirmed in previous studies [15], which is a first-order phase transition; but the nature of other two transitions [from I to III, III to V ], to our best knowledge, have not yet been proved.Because of the insensitivity of the polar order parameter to the phase transition, especially around the cross sea and band phases, here we adopt the structure order parameter C 2 [18,19] as our new order parameter.It is a local integral over the two particle correlation function formally given by where θ is the Heaviside function, g(r) is the usual pair correlation function.The value is zero for the independent particle ensemble, but becomes large when particles are clustered.Therefore, C 2 works generally better than the traditional polar order parameter and the Binder cumulant for its ability in capturing the structural change.A simple way of computing C 2 is given in Sec.I of SM [36].Fig. 2(a) shows the dependence of the average structure order parameter C 2 on the noise amplitude, where two cases can be seen.While a sin-gle value of C 2 corresponds to a pure state [e.g.Fig. 1(I, III, V, V II)], the two-value cases are for the bistable states [Fig.1(II, IV, V I)].We can see that the bistablity is observed for all three transitions among four pure states, indicating first-order phase transitions.And this observation is strengthened by the bimodal PDF as well as the time series, see Fig. 2(b) We also compare the structure order parameter C 2 with the traditional polar order parameter, and find that C 2 indeed has advantage in distinguishing the cross sea phase (for details see Sec.II of SM [36]).Still, the change in C 2 is very small in some certain bistable states, or the system is prone to stabilize into a state within the bistable region with a little chance to evolve into the other due to the deep potential well.All these factors lead to great difficulties in the phase segmentation.In addition, both order parameters are greatly influenced by the system size (see Sec. III of SM [36]).

Convolutional neural network -We now turn to adopt
CNNs to classify the rich phases of Vicsek model with the help of TensorFlow [37].The particle configuration is sampled as an image, and the task turns to be the image classification.The method belongs to the supervised learning that try to find the correct mapping between the configuration and the phase label.Fig. 3 shows the network structure of the CNN.It is composed of an input layer with the same size as the image pixel sampled, multiple cascaded convolution-pooling layers, fully connected layers, and the output layer [38,39].Each convolutionpooling stage is a series of the convolution layer to extract a feature map and the max-pooling layer to reduce the feature map size.We use zero padding to maintain the spatial dimensions of feature maps during the convolution processes [35,39].To avoid a vanishing gradient problem during training, we use the rectified linear unit (ReLU) activation for each layer of convolutional neural network.We utilize the stochastic gradient descent optimization function in the learning rate for stable convergence [40].
In our experiment, we use three independent data sets: the training, validation, and test sets.The training and validation sets are sampled far from the three bistable regions to guarantee the correctness for the assigned label for each image, while the test set is prepared across the whole parameter domain without label (more details see Sec.III of SM [36]).For details about CNNs and the data sets, see Sec.IV of SM [36].
The whole training process consists of two stages.In the first stage, in each epoch the CNN is fed with all training data, and then we validate the CNN with the validation set to monitor its performance and stability.By validation, we find the CNNs are able to classify different phases successfully, the accuracy is almost 100% when the system size is not very large.This is beyond our expectation because when the system is small, the snapshots are difficult to distinguish artificially by eyes.When the system becomes large, the CNN still can classify the ordered, cross sea, band and disordered phases.Though the accuracy now decreases to around 86.2%.This is due to the narrow regions for the newly emerging phases, the correctness of labels in the training data sets cannot be guaranteed, thus leading to the accuracy decrease on the validation set.More details see Sec.IV of SM [36].
After the training is completed, we enter into the second stage, use the trained CNNs to classify the images in the test data set.The output probabilities for the avail-able phases on the test sets as a function of the noise η are shown in Fig. 4, for four different system sizes.Given these probabilities, their intersections can naturally interpreted as the transition point of two neighboring phases, since the probabilities there are approximately 50%.With this idea, we estimate η c1 ≈ 1.47, η c2 ≈ 2.11, η c3 ≈ 2.58 in Fig. 4 (c), all fall within the bistable regions.It's worthy to note that in the firstorder phase transitions, the boundary for two neighboring phases is a parameter interval defined by two thresholds.Our estimated transition point instead provides a single threshold that approximately divide the two phase regions.
Conclusions -Alongside the previous concerns, here we aim to clarify the nature of all phase transitions in the Vicsek model.By adopting the structural order parameter [18] and the technique of PDF segmentation [16], we confirm that all phase transitions between the two neighboring phase are first-order given the system is large enough.The existing problem is that the structural order parameter is still insensitive to the parameter change in some regions, that makes the PDF segmentation bad and thus less precise in characterizing the phase transitions.Therefore, we use the CNNs to classify different phases by feeding them labeled snapshot images.We find that this approach is able to successfully do phase classifica-tion with high accuracies.The transition points of two neighboring phases can also be inferred accordingly.
Our approach is feature extraction of raw data from different states, which not only correctly classifies the given states into different phases, but also infers phase transition points as well.This work opens up new possibilities for exploring phase transitions in systems where a priori knowledge is unavailable, thus the proper order parameter is unknown.Given the success [33,41,42] in complex networks, materials science, quantum systems etc, we look forward to applying machine learning to detect, predict and identify phase transitions in active matters and in many other non-equilibrium fields in the future.
We acknowledge Weiran Cai (Soochow University) and Jiqiang Zhang (Ningxia University) for helpful comments.Xiaosong Chen and Xu Li are supported by the National Natural Science Foundation of China under Grant no.12135003.Zhangang Han and Tingting Xue are supported by the National Natural Science Foundation of China under Grant no.62176022.Li Chen is supported by the National Natural Science Foundation of China under Grant no.12075144.

FIG. 2 .
FIG. 2. (Color online) Phase transitions of the Vicsek model.(a)The structural order parameter C2 t versus the noise amplitude η.C2 t is computed as follows: if the probability distribution function (PDF) of C2 is single-peaked, then we average all data; but if the profile is bimodal, as cases shown in (b), we divide the data at the valley point, and do average respectively for the bistable states, two points are then obtained for each η.The plot shows that three transitions among the four states are all bistable, thus are of first-order nature.(b) PDF of C2 for the three parameters used in Fig.1.The double peak structures show the discontinuous nature of the transition.The inset shows the time series at the noise amplitude η = 1.53.The data is averaged over 5 × 10 5 time steps after the transient 5 × 10 5 .Parameter: L = 512.

FIG. 3 .
FIG. 3. (Color online) A schematic diagram of the convolutional neural network for the phase classification.

FIG. 4 .
FIG. 4. (Color online) Machine learning different phases in the Vicsek model.The output on the test set versus the noise amplitude η for the system with size L = 32, 128, 512 and 1408, respectively for (a) to (d).Only two states are presented in the small system (a), and the emergence of the cross sea phase requires the system is large enough (c,d).The output layer is averaged 10 realizations, the error bars represent the standard deviation.