# Design and Implementation of Group Animation Based on Multimedia Intelligent Algorithm

Authors: Qing Li
Journal: Advances in Multimedia
 (2022)

---

## Abstract

In order to improve the autonomy and intelligence of group animation behavior, this paper proposes a particle swarm optimization algorithm for automatic control of group animation behavior. After the user inputs the group animation behavior construction target, the individual path is planned according to the fixed behavior rules, and the particle swarm optimization algorithm and the improved artificial fish swarm optimization algorithm are used to select the optimal action for the individual in the group animation according to the top-down control process. The experimental results show that after the PSO converges to the global optimal solution, the evolution times of the PSO converge to the global optimal solution again when the surrounding environment changes 10 times. The population diversity of particle swarm optimization algorithm is obviously better than those of the other two algorithms in the process of automatically controlling the movement of individuals to the circle and to the stand in the crowd animation. Compared with the original algorithm AFSA, the improved artificial fish swarm algorithm proposed in this paper is easier to obtain the global optimal value, and the optimization speed is also improved. In conclusion, the example analysis verifies that the algorithm can effectively realize the automatic control of group animation behavior and has high convergence speed and high autonomy.


---

## Body

## 1. Introduction

The appearance of computer animation seems to be continuous pictures one after another, but in essence, it is an image picture produced by combining digital image technology and then programming on animation creation software [1]. In real life, the pictures people see are often static. Animation is to make a picture that is originally static move. Animation can also be abstractly described as a process of an event, presenting a vivid picture, shooting a series of single pictures on consecutive multiple films, and then projecting these films at a certain rate to achieve a new visual experience. As we all know, computer animation, as a research branch of graphics, has gradually become an inevitable factor and research hotspot in the field of animation creation. Group animation is also a very important part of the animation development industry. The number of groups is relatively large, the simulation effect of groups is more real, and the creation difficulty and cost of animation are relatively high. In our daily life, we can see that group animation has played a significant role in many fields such as advertising, film and television, commerce, digital platform, and military war simulation. The traditional animation production adopts the key frame technology to make it difficult to meet the requirements of the audience in authenticity and intelligence [2]. It can be said that the group behavior animation is to use computers to simulate the group behavior of natural organisms and then show it through the animation. The animation industry is also an innovative industry at present. It is also regarded as a creative industry. The animation industry is a series of industries based on the development and production of information technology, including films, books, and advertisements, with “creativity” as the core. It can be said that the application prospect of animation industry is very broad, and it can be called a new industry in the creative economy. However, in real life, a large number of virtual or real scenes need animators to create; not only the number is too large but also the scale is quite large. If animators use the traditional key frame technology, they need to plan and set the path action for each individual in each frame. Meanwhile, in the design process, the autonomy and reliability of animation characters have also become the main content of computer animation technology exploration. In so many studies, one of the main directions is to find a method to organically combine user interaction and autonomous behavior in the group, which requires us to find a motion calculation method that makes it more simplified without losing authenticity [3]. With the development of artificial intelligence theory and the complexity of swarm animation, more and more swarm intelligence optimization algorithms are applied to the production of animation. There are many kinds of animals in nature. If we want to truly reproduce their behaviors and actions, it is not a simple simulation of their appearance, at least to achieve the lifelike shape. What should be considered is how similar the simulation model we make is to the real animal. It is obvious that our production model must have sufficient fidelity to produce convincing state effects. In general, the more accurate the model is, the higher the fidelity of the effect will be, and the overall operation will be more smooth [4, 5]. When we observe some familiar and interested animals, we can find that the structural characteristics and movement modes of the animals themselves are very complex, so the animal models are also very complex. So how to create a very smooth animation system so that it can run quickly on the computer, and at the same time, the animation creators can make changes quickly. In order to meet this requirement, the fidelity of the model and the efficiency of the operation should be integrated, and the two should be adjusted in a compromise. In view of the expected results, the accuracy of the model often plays a key role. Therefore, the in-depth study of group animation is very meaningful, and it is also a development direction of national independent innovation industry.


## 2. Literature Review

The basic clustering algorithm proposed by Muratov and Osipov uses “Boids” to simulate the movement of birds. Each individual has the most basic flight ability and applies the three rules of separation, alignment, and cohesion to each individual in the group, thereby generating group movement [6]. Zhang et al. applied the theory of artificial life to the creation of computer group animation and proposed a computer animation creation method based on the artificial life model—the artificial life method of computer animation [7]. This method regards each group animation character as an individual. Each individual not only has a realistic and vivid appearance image but also has internal habits and preferences and has the ability to perceive the external environment and life characteristics such as generating intention, responding, controlling behavior, and realizing purposeful behavior. Li et al. extended Xiaoyuan’s fish and independently modeled each virtual character by using cognitive model to make it have perception, behavior, and cognitive ability. For example, when thirsty, they would queue up to throw drinks, when tired, they would sit on a bench for a rest, and before entering the station, they would queue up to buy tickets and would be attracted by street performances to stop and watch, which fairly realistically simulated the crowds of people coming and going to the station [8]. Yw et al. proposed a group animation creation framework based on multiple autonomous agents: as autonomous agents, the characters in the group can perceive environmental information, generate intentions, plan behaviors, and finally complete behaviors and realize intentions through the motion data generated by the motion system [9]. Zhu et al. proposed a calculation model: the famous Boids system, which is a group behavior calculation model. They believe that each character’s movement in group animation should balance the following four goals [10]: (1) prevent collisions—avoid collisions between adjacent characters; (2) speed matching—match with the speed of adjacent characters; (3) center convergence—there is proximity to adjacent autonomous characters; and (4) try to fly to a target. On this basis, they proposed a role control method and established a three-layer model of group animation. In this model, each role is an independent actor in the environment. It determines what kind of behavior to take in the next step by perceiving the environment. The behavior of the role is divided into three steps: selection behavior, planning behavior, and realization behavior. The planning behavior is emphatically studied. Chen et al. introduced the artificial life method into the creation of computer animation, proposed the artificial life method of computer animation, and developed “Xiaoyuan’s fish” with this method. “Xiaoyuan’s fish” simulates the basic behaviors of fish, such as training, roaming, and avoiding obstacles. This artificial fish system selects the basic behaviors of artificial fish through rules with priority and fixed sets, such as avoiding obstacles, eating, avoiding being caught, mating, swimming, escaping, and training; these basic behaviors determine the final behavior of the character. Their representative works “the undersea world of Jack cousto” and “gofish” show a vivid and realistic virtual undersea world [11]. Liu et al. extended “Xiaoyuan’s fish” and independently modeled each character by using cognitive model, vividly and realistically simulating the crowd of people coming and going from the station. The characters in the system have cognitive and behavioral abilities, such as queuing to buy tickets before entering the station, sitting on a chair when tired, queuing to buy drinks when thirsty, and watching street performances [12]. Zhu studied the part design of the role model and its specific implementation technology, combined with the idea of animation design, applied the behavior theory of steering to the group animation design, and designed the group animation design method based on intelligent roles. Due to the intelligence and interest of group animation, more and more scholars have paid extensive attention to it [13].In view of the above defects, this paper optimizes the particle swarm optimization algorithm, improves the motion mode of particles in the particle swarm optimization algorithm, and obtains the optimal automatic control effect. Particle swarm optimization (PSO) has swarm intelligence. When PSO is applied to the automatic control of swarm animation behavior, it needs to detect the changes of the environment around the particles in real time and find the optimal solution in the shortest time. The research of particle swarm optimization algorithm for automatic control of group animation behavior can make the animation characters in the group have autonomy, simplify the behavior control and make the character motion natural and realistic, and have good global optimization performance and can quickly realize the automatic control of group animation.


## 3. Research Methods

### 3.1. Construction of Particle Swarm Optimization Algorithm

#### 3.1.1. Group Animation

Group animation is a way to build three-dimensional group animation based on human and animal group behaviors. Group animation has been widely used in film and television works, public safety, and various large-scale games [14]. The movement behavior control of groups and individuals in group animation is an important direction of group animation research. The structure diagram of group animation construction system is shown in Figure 1.Figure 1
Group animation construction architecture.The group animation needs to follow the fixed principle, and the group animation simulation process gives the most basic action ability to the individuals in the group. All individuals in the group animation can determine the motion path according to the motion of other individuals. It can be seen from Figure1 that after the user inputs the group animation construction target, the individual path is planned according to the fixed behavior rules. After the individual action path in the group animation is determined, the particle swarm optimization algorithm is used to select the optimal action for the individual in the group animation according to the top-down control process. After the individual action is completed, the final result is output through the rendering function of 3DS MAX software. 3DS MAX software is used to establish the group animation model. The establishment process needs to be based on the following principles:
(1)
All individuals in the group animation need to have their own individual space. In order to avoid the occupation of individual space, individuals need to stay away from other individuals when they enter the safe space(2)
All individuals in the group animation need to keep the same movement direction with other individuals, and the movement direction of all individuals in the group animation is roughly the same(3)
The small groups in the group animation can be integrated with the surrounding groups when there are no obstacles around. In the process of group animation design, collision should be avoided as much as possibleThe automatic control strategy of group animation behavior is mainly divided into two parts: bottom-up control and top-down control [15]. The process in which individuals decide their behavior according to their own judgment in group animation is called bottom-up control process. The bottom-up automatic control method can enable individuals to achieve autonomous interaction with the surrounding environment and surrounding individuals according to the perception of the surrounding environment and display the group characteristics through autonomous interaction. The control process in which user consciousness determines individual behavior in group animation is called top-down control process. By controlling individuals in group animation, users make all individuals realize independent control according to user consciousness. The particle swarm optimization algorithm is selected to realize the automatic control of the group animation behavior through the top-down control process. After the user inputs the control parameters of the group animation behavior, the initial state of the individual in the group animation is specified by the control parameters, and the individual in the group animation realizes independent control according to the user control parameters.


#### 3.1.2. Particle Swarm Optimization Algorithm

The particle swarm optimization algorithm regards all the individuals to be optimized as particles without mass and volume and stores them in theB-dimensional search space. Assuming that the flight speed of all particles is fixed, the flight speed of each particle is dynamically adjusted according to the flight experience of all particles and individual particles. Through the adaptability of the individual to the environment, all the individuals in the group move to the set area. Let the particle swarm exist in the b-dimensional search space, where the number of particles is m and the position of the i-th particle in the search space is represented by Yi=yi1,yi2,⋯,yiB and i=1,2,⋯,m, which is the potential solution of the optimization problem. The particle fitness value can be obtained by using this position, and the quality of the spatial position can be evaluated according to the obtained fitness value [16]. The moving speed of the individual particles in the particle swarm is expressed by Ui=ui1,ui2,⋯,uiB. The movement of the particles i in the B-dimensional 1≤b≤B space needs to move according to the following formula during each iteration, as follows:
(1)uib=wuib+e1r1qib−yib+e2r2qgb−yib,(2)yib=yib+uib,where w and e1 and e2, respectively, represent inertia weight and acceleration coefficient and r1 and r2 represent random numbers that vary within the range of [0, 1]. Equation (2) is the movement position adjustment caused by the interaction of particles in the particle solution space [17].The steps of particle swarm algorithm are as follows:(1)
Initialize the scale, inertia weight, maximum allowable iteration times, fitness error limit, acceleration coefficient, particle initial speed, initial position, position limit, and flight speed limit of the particle swarm algorithm(2)
Evaluate the initial adaptation value of the particles, and set the individual historical optimum value and the global historical optimum value within the particle swarm(3)
Work by limiting the update rate and position of individuals in the particle swarm and the updates and activities of the product(4)
Evaluate particle fitness(5)
Compare the individual historical optimum adaptation value and the current adaptation value of each particle, save the optimum adaptation value as the historical optimum adaptation value, and update the position as the individual historical optimum position(6)
Compare the global optimal fitness value of all individuals in the particle swarm with the fitness value at this time, and retain the optimal fitness value as the overall historical optimal fitness value, and the position at this time is the global historical optimal position;(7)
When the adaptive value error meets the set adaptive value error limit, the stop condition is met, the algorithm ends, and the global optimal search result is output; otherwise, return to Step 3


#### 3.1.3. Particle Swarm Optimization Algorithm

In order to make the particle swarm optimization algorithm less susceptible to the influence of the external environment, the algorithm still has strong adaptability when the environment changes, can accurately sense the change of the environment, and can accurately track the optimal solution when the environment changes. Based on the particle swarm optimization algorithm, the global extremum representation method is improved. The optimized particle swarm optimization algorithm replaces the global extremum with the local optimal average value obtained and calculates the current local optimal fitness value of each particle when the particle swarm evolves for one generation. Obtain the local worst fitness value and the local optimal fitness value of the individual in the particle swarm, calculate the sum and difference of the local worst fitness value and the local optimal fitness value, and obtain the ratio of the sum and the difference, and use the ratio to obtain the average value of all the individual optimal fitness values in the particle swarm. The global optimal fitness value of the particle swarm selects the product obtained by the difference between the average value and the ratio. The calculation formula is as follows:(3)Qm=max+minmax−min·,where max=maxq1b,q2b,⋯,qnb and min=minq1b,q2b,⋯,qnb, respectively, represent the current maximum fitness particle position and the minimum fitness particle position and n and qib, respectively, represent the number of particles and the optimal position of the i-th particle in the b-dimensional space.The particle velocity is updated by replacingQg of the particle swarm optimization algorithm with Qm obtained by equation (3).Particle swarm optimization must be able to quickly understand changes in the external environment, so that the dynamic process can be quickly controlled. The particle swarm optimization algorithm requires a timely response after sensing changes in the environment. Eberhart’s method uses a particle-by-particle optimization algorithm that senses changes in the external environment. It has been shown that when the global mass value of the particle swarm changes, the change in the environment of the particle swarm causes a change in the global mass value of the particle swarm. In the case of changes in the particle swarm environment, the global cloud value and the local mass value of all particles in the particle swarm algorithm must be given in time, and the local cloud value is compared with the global cloud value to be separated. By reinitializing particles according to the distance from the existing consensus value, 6% of particles with a distance less than the global absolute value, expanding the research diverse and continuous search, particle swarm will be diverse and continuous and evolved to find the world’s perceived value after the environment changes.


### 3.2. Overview of Artificial Fish Swarm Algorithm

The artificial fish swarm algorithm is based on the animal autonomous body model, starting from the local optimization behavior of the artificial fish and adopting the bottom-up design idea, so that the global optimal value gradually emerges. The state of each artificial fish in AFSA is expressed asX=x1,x2,⋯,xn, where xii=1,2,⋯,n represents the variable to be optimized; Y=fX represents the amount of food at the position of the artificial fish, where Y is the value of the objective function. The distance between two artificial fish is expressed by di,j=Xi−Xj; Visual represents the perceived distance of the artificial fish; Step represents the moving step of the artificial fish; δ represents the congestion factor; trynumber represents the maximum number of attempts of each movement of the artificial fish.


#### 3.2.1. Basic Behavior Description of Artificial Fish

AFSA mainly uses several basic behaviors of fish groups, such as foraging, crowding, and tail chasing, to achieve global optimization. Several types of behaviors used in the iteration process are briefly described as follows:(1)
Random behavior: the artificial fish randomly chooses a state in the field of view and moves in that direction; that is, see the following formula:(4)Xinext=Xi+RandomStep(2)
Foraging behavior: it refers to the behavior of artificial fish moving toward the position with high food concentration. The artificial fishXi randomly selects a state Xj within its sensing range Visual, if the food concentration Xi<Xj in the maximum problem; that is, see the following formula:(5)AFprey·:Xinext=Xi+RandomStepXj−XiXj−Xi,Yi<Yj,Xinext=Xi+RandomStep,else(3)
Swarm behavior: the artificial fishXi explores the number of partners nf and the center position Yc in the current neighborhood. If Yc/nf>δYi, it indicates that there is more food in the center of the partner and it is not too crowded; then, the artificial fish moves further toward the center position of the partner; otherwise, perform foraging behavior; that is, see the following formula:(6)Xinext=Xi+RandomStepXc−XiXc−Xi,Ycnf>δYi,AFprey·,else(4)
Tail chasing behavior: it refers to the behavior of the fish school chasing the best artificial fish in its vicinity during swimming. The artificial fishXi searches for the partner Xj with the largest Xj among the partners in the current neighborhood; that is, see the following formula:(7)Xinext=Xi+RandomStepXmax−XiXmax−Xi,Ymaxnf>δYi,AFprey·,elseThe schematic diagram of AFSA algorithm is shown in Figure2.Figure 2
Schematic diagram of AFSA algorithm.


#### 3.2.2. Algorithm Structure Flow

The basic implementation process of artificial fish swarm algorithm is shown in Figure3.Figure 3
AFSA algorithm flow.


### 3.3. Improved Artificial Fish Swarm Algorithm

The research shows that AFSA has many excellent characteristics and can solve the nonlinear function optimization problem well. However, with the continuous development and deepening of the problem, some problems gradually appear. For example, the step size in the algorithm determines the convergence speed and optimization accuracy. When the step size is large, the artificial fish moves in a large range, and the convergence speed is relatively fast, but the accuracy is poor. On the contrary, the convergence speed is slow and the accuracy is good. Because the step in the algorithm selects a fixed value, the phenomenon that artificial fish oscillates around the optimal value is easy to occur, and the convergence accuracy and the optimization speed are in conflict. The convergence speed of the algorithm is relatively fast in the initial stage of optimization, but it is often slow in the later stage, and it is easy to fall into local optimization. In addition, AFSA generally finds a satisfactory solution domain, and it is difficult to obtain accurate values. In view of some defects of AFSA, researchers have improved AFSA from the aspects of initialization of fish swarm, adjustment of algorithm parameters, improvement of basic behavior, and combination with other intelligent algorithms to improve the optimization efficiency of AFSA.


#### 3.3.1. Social Learning Mechanism

Social learning mechanism is a theoretical system formed by human beings in the process of long-term evolution. The so-called learning can be understood as a form of expression used to explore the relationship between cognition, behavior and environment. While following the natural law of gradual evolution, human beings can effectively guide the evolution of human society according to the accumulated experience and knowledge. Learning generally includes direct experience learning and indirect experience learning, and convergence and divergence are two basic behaviors in social learning. On the one hand, the individuals in the population tend to learn from the excellent individuals and use the experience and knowledge accumulated by the excellent individuals to improve and improve themselves. On the other hand, they will break through the limitations of converging to the excellent individuals and look for new development opportunities, that is, the divergent behaviors of the individuals. The convergence and divergence behaviors in the social learning mechanism can quickly learn and search for a relatively accurate optimal state. These two behaviors are described mathematically. In the early stage of optimization, the local solution domain is quickly found, and then, the convergence and divergence principles are used to search in the local solution domain. The convergence behavior ensures the progress to the global optimal solution, and the divergence behavior explores other possible optimal values in the opposite direction of the optimal solution, which improves the optimization accuracy while preventing the group from falling into the local optimal solution.


#### 3.3.2. Learning Process Based on Social Learning Mechanism

The state of each individual in the population is marked asXi, the historical optimal state of the individual is marked as Xpbesti, and the optimal state of the population is marked as Xgbest. Learning is carried out by the formula Xi,iter+1=Xpbesti+r×N0,σ×Xgbest−Xi,iter, where iter is the number of iterations, r is a positive real number between 0 and 1, and N0,σ is a normal distribution random number and also a learning factor. The value of σ determines whether to conduct a fine centralized search or a broad search. The value of N0,σ determines whether to conduct convergence or divergence; that is, when N0,σ>0, individuals converge in the direction of vector difference Xpbest−Xi,iter; When N0,σ<0, individuals diverge in the opposite direction of vector difference gbest−Xi,iter. The learning process is shown in Figure 4.Figure 4
Individual learning process.Each individual takes its own historical optimal stateXpbesti as the benchmark and takes the current state Xi,iter of the individual and the vector difference Xgbest−Xi,iter of the group optimal state as the reference and updates the individual state through the organic combination of convergence and divergence [18]. The schematic diagram of two-dimensional update is shown in Figure 5.Figure 5
Schematic diagram of individual 2D update.On the basis of the above analysis, combined with the social learning mechanism, an improved artificial fish swarm algorithm (IAFSA) is obtained, which applies the convergence and divergence phenomena in the social learning mechanism to AFSA. After quickly finding the local optimal domain, on the one hand, we use the convergence behavior to evolve to the global optimal direction, and on the other hand, we use the divergence behavior to advance to the opposite direction of the optimal, so as to find other possible global optimal values and prevent falling into the local optimal.


## 3.1. Construction of Particle Swarm Optimization Algorithm

### 3.1.1. Group Animation

Group animation is a way to build three-dimensional group animation based on human and animal group behaviors. Group animation has been widely used in film and television works, public safety, and various large-scale games [14]. The movement behavior control of groups and individuals in group animation is an important direction of group animation research. The structure diagram of group animation construction system is shown in Figure 1.Figure 1
Group animation construction architecture.The group animation needs to follow the fixed principle, and the group animation simulation process gives the most basic action ability to the individuals in the group. All individuals in the group animation can determine the motion path according to the motion of other individuals. It can be seen from Figure1 that after the user inputs the group animation construction target, the individual path is planned according to the fixed behavior rules. After the individual action path in the group animation is determined, the particle swarm optimization algorithm is used to select the optimal action for the individual in the group animation according to the top-down control process. After the individual action is completed, the final result is output through the rendering function of 3DS MAX software. 3DS MAX software is used to establish the group animation model. The establishment process needs to be based on the following principles:
(1)
All individuals in the group animation need to have their own individual space. In order to avoid the occupation of individual space, individuals need to stay away from other individuals when they enter the safe space(2)
All individuals in the group animation need to keep the same movement direction with other individuals, and the movement direction of all individuals in the group animation is roughly the same(3)
The small groups in the group animation can be integrated with the surrounding groups when there are no obstacles around. In the process of group animation design, collision should be avoided as much as possibleThe automatic control strategy of group animation behavior is mainly divided into two parts: bottom-up control and top-down control [15]. The process in which individuals decide their behavior according to their own judgment in group animation is called bottom-up control process. The bottom-up automatic control method can enable individuals to achieve autonomous interaction with the surrounding environment and surrounding individuals according to the perception of the surrounding environment and display the group characteristics through autonomous interaction. The control process in which user consciousness determines individual behavior in group animation is called top-down control process. By controlling individuals in group animation, users make all individuals realize independent control according to user consciousness. The particle swarm optimization algorithm is selected to realize the automatic control of the group animation behavior through the top-down control process. After the user inputs the control parameters of the group animation behavior, the initial state of the individual in the group animation is specified by the control parameters, and the individual in the group animation realizes independent control according to the user control parameters.


### 3.1.2. Particle Swarm Optimization Algorithm

The particle swarm optimization algorithm regards all the individuals to be optimized as particles without mass and volume and stores them in theB-dimensional search space. Assuming that the flight speed of all particles is fixed, the flight speed of each particle is dynamically adjusted according to the flight experience of all particles and individual particles. Through the adaptability of the individual to the environment, all the individuals in the group move to the set area. Let the particle swarm exist in the b-dimensional search space, where the number of particles is m and the position of the i-th particle in the search space is represented by Yi=yi1,yi2,⋯,yiB and i=1,2,⋯,m, which is the potential solution of the optimization problem. The particle fitness value can be obtained by using this position, and the quality of the spatial position can be evaluated according to the obtained fitness value [16]. The moving speed of the individual particles in the particle swarm is expressed by Ui=ui1,ui2,⋯,uiB. The movement of the particles i in the B-dimensional 1≤b≤B space needs to move according to the following formula during each iteration, as follows:
(1)uib=wuib+e1r1qib−yib+e2r2qgb−yib,(2)yib=yib+uib,where w and e1 and e2, respectively, represent inertia weight and acceleration coefficient and r1 and r2 represent random numbers that vary within the range of [0, 1]. Equation (2) is the movement position adjustment caused by the interaction of particles in the particle solution space [17].The steps of particle swarm algorithm are as follows:(1)
Initialize the scale, inertia weight, maximum allowable iteration times, fitness error limit, acceleration coefficient, particle initial speed, initial position, position limit, and flight speed limit of the particle swarm algorithm(2)
Evaluate the initial adaptation value of the particles, and set the individual historical optimum value and the global historical optimum value within the particle swarm(3)
Work by limiting the update rate and position of individuals in the particle swarm and the updates and activities of the product(4)
Evaluate particle fitness(5)
Compare the individual historical optimum adaptation value and the current adaptation value of each particle, save the optimum adaptation value as the historical optimum adaptation value, and update the position as the individual historical optimum position(6)
Compare the global optimal fitness value of all individuals in the particle swarm with the fitness value at this time, and retain the optimal fitness value as the overall historical optimal fitness value, and the position at this time is the global historical optimal position;(7)
When the adaptive value error meets the set adaptive value error limit, the stop condition is met, the algorithm ends, and the global optimal search result is output; otherwise, return to Step 3


### 3.1.3. Particle Swarm Optimization Algorithm

In order to make the particle swarm optimization algorithm less susceptible to the influence of the external environment, the algorithm still has strong adaptability when the environment changes, can accurately sense the change of the environment, and can accurately track the optimal solution when the environment changes. Based on the particle swarm optimization algorithm, the global extremum representation method is improved. The optimized particle swarm optimization algorithm replaces the global extremum with the local optimal average value obtained and calculates the current local optimal fitness value of each particle when the particle swarm evolves for one generation. Obtain the local worst fitness value and the local optimal fitness value of the individual in the particle swarm, calculate the sum and difference of the local worst fitness value and the local optimal fitness value, and obtain the ratio of the sum and the difference, and use the ratio to obtain the average value of all the individual optimal fitness values in the particle swarm. The global optimal fitness value of the particle swarm selects the product obtained by the difference between the average value and the ratio. The calculation formula is as follows:(3)Qm=max+minmax−min·,where max=maxq1b,q2b,⋯,qnb and min=minq1b,q2b,⋯,qnb, respectively, represent the current maximum fitness particle position and the minimum fitness particle position and n and qib, respectively, represent the number of particles and the optimal position of the i-th particle in the b-dimensional space.The particle velocity is updated by replacingQg of the particle swarm optimization algorithm with Qm obtained by equation (3).Particle swarm optimization must be able to quickly understand changes in the external environment, so that the dynamic process can be quickly controlled. The particle swarm optimization algorithm requires a timely response after sensing changes in the environment. Eberhart’s method uses a particle-by-particle optimization algorithm that senses changes in the external environment. It has been shown that when the global mass value of the particle swarm changes, the change in the environment of the particle swarm causes a change in the global mass value of the particle swarm. In the case of changes in the particle swarm environment, the global cloud value and the local mass value of all particles in the particle swarm algorithm must be given in time, and the local cloud value is compared with the global cloud value to be separated. By reinitializing particles according to the distance from the existing consensus value, 6% of particles with a distance less than the global absolute value, expanding the research diverse and continuous search, particle swarm will be diverse and continuous and evolved to find the world’s perceived value after the environment changes.


## 3.1.1. Group Animation

Group animation is a way to build three-dimensional group animation based on human and animal group behaviors. Group animation has been widely used in film and television works, public safety, and various large-scale games [14]. The movement behavior control of groups and individuals in group animation is an important direction of group animation research. The structure diagram of group animation construction system is shown in Figure 1.Figure 1
Group animation construction architecture.The group animation needs to follow the fixed principle, and the group animation simulation process gives the most basic action ability to the individuals in the group. All individuals in the group animation can determine the motion path according to the motion of other individuals. It can be seen from Figure1 that after the user inputs the group animation construction target, the individual path is planned according to the fixed behavior rules. After the individual action path in the group animation is determined, the particle swarm optimization algorithm is used to select the optimal action for the individual in the group animation according to the top-down control process. After the individual action is completed, the final result is output through the rendering function of 3DS MAX software. 3DS MAX software is used to establish the group animation model. The establishment process needs to be based on the following principles:
(1)
All individuals in the group animation need to have their own individual space. In order to avoid the occupation of individual space, individuals need to stay away from other individuals when they enter the safe space(2)
All individuals in the group animation need to keep the same movement direction with other individuals, and the movement direction of all individuals in the group animation is roughly the same(3)
The small groups in the group animation can be integrated with the surrounding groups when there are no obstacles around. In the process of group animation design, collision should be avoided as much as possibleThe automatic control strategy of group animation behavior is mainly divided into two parts: bottom-up control and top-down control [15]. The process in which individuals decide their behavior according to their own judgment in group animation is called bottom-up control process. The bottom-up automatic control method can enable individuals to achieve autonomous interaction with the surrounding environment and surrounding individuals according to the perception of the surrounding environment and display the group characteristics through autonomous interaction. The control process in which user consciousness determines individual behavior in group animation is called top-down control process. By controlling individuals in group animation, users make all individuals realize independent control according to user consciousness. The particle swarm optimization algorithm is selected to realize the automatic control of the group animation behavior through the top-down control process. After the user inputs the control parameters of the group animation behavior, the initial state of the individual in the group animation is specified by the control parameters, and the individual in the group animation realizes independent control according to the user control parameters.


## 3.1.2. Particle Swarm Optimization Algorithm

The particle swarm optimization algorithm regards all the individuals to be optimized as particles without mass and volume and stores them in theB-dimensional search space. Assuming that the flight speed of all particles is fixed, the flight speed of each particle is dynamically adjusted according to the flight experience of all particles and individual particles. Through the adaptability of the individual to the environment, all the individuals in the group move to the set area. Let the particle swarm exist in the b-dimensional search space, where the number of particles is m and the position of the i-th particle in the search space is represented by Yi=yi1,yi2,⋯,yiB and i=1,2,⋯,m, which is the potential solution of the optimization problem. The particle fitness value can be obtained by using this position, and the quality of the spatial position can be evaluated according to the obtained fitness value [16]. The moving speed of the individual particles in the particle swarm is expressed by Ui=ui1,ui2,⋯,uiB. The movement of the particles i in the B-dimensional 1≤b≤B space needs to move according to the following formula during each iteration, as follows:
(1)uib=wuib+e1r1qib−yib+e2r2qgb−yib,(2)yib=yib+uib,where w and e1 and e2, respectively, represent inertia weight and acceleration coefficient and r1 and r2 represent random numbers that vary within the range of [0, 1]. Equation (2) is the movement position adjustment caused by the interaction of particles in the particle solution space [17].The steps of particle swarm algorithm are as follows:(1)
Initialize the scale, inertia weight, maximum allowable iteration times, fitness error limit, acceleration coefficient, particle initial speed, initial position, position limit, and flight speed limit of the particle swarm algorithm(2)
Evaluate the initial adaptation value of the particles, and set the individual historical optimum value and the global historical optimum value within the particle swarm(3)
Work by limiting the update rate and position of individuals in the particle swarm and the updates and activities of the product(4)
Evaluate particle fitness(5)
Compare the individual historical optimum adaptation value and the current adaptation value of each particle, save the optimum adaptation value as the historical optimum adaptation value, and update the position as the individual historical optimum position(6)
Compare the global optimal fitness value of all individuals in the particle swarm with the fitness value at this time, and retain the optimal fitness value as the overall historical optimal fitness value, and the position at this time is the global historical optimal position;(7)
When the adaptive value error meets the set adaptive value error limit, the stop condition is met, the algorithm ends, and the global optimal search result is output; otherwise, return to Step 3


## 3.1.3. Particle Swarm Optimization Algorithm

In order to make the particle swarm optimization algorithm less susceptible to the influence of the external environment, the algorithm still has strong adaptability when the environment changes, can accurately sense the change of the environment, and can accurately track the optimal solution when the environment changes. Based on the particle swarm optimization algorithm, the global extremum representation method is improved. The optimized particle swarm optimization algorithm replaces the global extremum with the local optimal average value obtained and calculates the current local optimal fitness value of each particle when the particle swarm evolves for one generation. Obtain the local worst fitness value and the local optimal fitness value of the individual in the particle swarm, calculate the sum and difference of the local worst fitness value and the local optimal fitness value, and obtain the ratio of the sum and the difference, and use the ratio to obtain the average value of all the individual optimal fitness values in the particle swarm. The global optimal fitness value of the particle swarm selects the product obtained by the difference between the average value and the ratio. The calculation formula is as follows:(3)Qm=max+minmax−min·,where max=maxq1b,q2b,⋯,qnb and min=minq1b,q2b,⋯,qnb, respectively, represent the current maximum fitness particle position and the minimum fitness particle position and n and qib, respectively, represent the number of particles and the optimal position of the i-th particle in the b-dimensional space.The particle velocity is updated by replacingQg of the particle swarm optimization algorithm with Qm obtained by equation (3).Particle swarm optimization must be able to quickly understand changes in the external environment, so that the dynamic process can be quickly controlled. The particle swarm optimization algorithm requires a timely response after sensing changes in the environment. Eberhart’s method uses a particle-by-particle optimization algorithm that senses changes in the external environment. It has been shown that when the global mass value of the particle swarm changes, the change in the environment of the particle swarm causes a change in the global mass value of the particle swarm. In the case of changes in the particle swarm environment, the global cloud value and the local mass value of all particles in the particle swarm algorithm must be given in time, and the local cloud value is compared with the global cloud value to be separated. By reinitializing particles according to the distance from the existing consensus value, 6% of particles with a distance less than the global absolute value, expanding the research diverse and continuous search, particle swarm will be diverse and continuous and evolved to find the world’s perceived value after the environment changes.


## 3.2. Overview of Artificial Fish Swarm Algorithm

The artificial fish swarm algorithm is based on the animal autonomous body model, starting from the local optimization behavior of the artificial fish and adopting the bottom-up design idea, so that the global optimal value gradually emerges. The state of each artificial fish in AFSA is expressed asX=x1,x2,⋯,xn, where xii=1,2,⋯,n represents the variable to be optimized; Y=fX represents the amount of food at the position of the artificial fish, where Y is the value of the objective function. The distance between two artificial fish is expressed by di,j=Xi−Xj; Visual represents the perceived distance of the artificial fish; Step represents the moving step of the artificial fish; δ represents the congestion factor; trynumber represents the maximum number of attempts of each movement of the artificial fish.


### 3.2.1. Basic Behavior Description of Artificial Fish

AFSA mainly uses several basic behaviors of fish groups, such as foraging, crowding, and tail chasing, to achieve global optimization. Several types of behaviors used in the iteration process are briefly described as follows:(1)
Random behavior: the artificial fish randomly chooses a state in the field of view and moves in that direction; that is, see the following formula:(4)Xinext=Xi+RandomStep(2)
Foraging behavior: it refers to the behavior of artificial fish moving toward the position with high food concentration. The artificial fishXi randomly selects a state Xj within its sensing range Visual, if the food concentration Xi<Xj in the maximum problem; that is, see the following formula:(5)AFprey·:Xinext=Xi+RandomStepXj−XiXj−Xi,Yi<Yj,Xinext=Xi+RandomStep,else(3)
Swarm behavior: the artificial fishXi explores the number of partners nf and the center position Yc in the current neighborhood. If Yc/nf>δYi, it indicates that there is more food in the center of the partner and it is not too crowded; then, the artificial fish moves further toward the center position of the partner; otherwise, perform foraging behavior; that is, see the following formula:(6)Xinext=Xi+RandomStepXc−XiXc−Xi,Ycnf>δYi,AFprey·,else(4)
Tail chasing behavior: it refers to the behavior of the fish school chasing the best artificial fish in its vicinity during swimming. The artificial fishXi searches for the partner Xj with the largest Xj among the partners in the current neighborhood; that is, see the following formula:(7)Xinext=Xi+RandomStepXmax−XiXmax−Xi,Ymaxnf>δYi,AFprey·,elseThe schematic diagram of AFSA algorithm is shown in Figure2.Figure 2
Schematic diagram of AFSA algorithm.


### 3.2.2. Algorithm Structure Flow

The basic implementation process of artificial fish swarm algorithm is shown in Figure3.Figure 3
AFSA algorithm flow.


## 3.2.1. Basic Behavior Description of Artificial Fish

AFSA mainly uses several basic behaviors of fish groups, such as foraging, crowding, and tail chasing, to achieve global optimization. Several types of behaviors used in the iteration process are briefly described as follows:(1)
Random behavior: the artificial fish randomly chooses a state in the field of view and moves in that direction; that is, see the following formula:(4)Xinext=Xi+RandomStep(2)
Foraging behavior: it refers to the behavior of artificial fish moving toward the position with high food concentration. The artificial fishXi randomly selects a state Xj within its sensing range Visual, if the food concentration Xi<Xj in the maximum problem; that is, see the following formula:(5)AFprey·:Xinext=Xi+RandomStepXj−XiXj−Xi,Yi<Yj,Xinext=Xi+RandomStep,else(3)
Swarm behavior: the artificial fishXi explores the number of partners nf and the center position Yc in the current neighborhood. If Yc/nf>δYi, it indicates that there is more food in the center of the partner and it is not too crowded; then, the artificial fish moves further toward the center position of the partner; otherwise, perform foraging behavior; that is, see the following formula:(6)Xinext=Xi+RandomStepXc−XiXc−Xi,Ycnf>δYi,AFprey·,else(4)
Tail chasing behavior: it refers to the behavior of the fish school chasing the best artificial fish in its vicinity during swimming. The artificial fishXi searches for the partner Xj with the largest Xj among the partners in the current neighborhood; that is, see the following formula:(7)Xinext=Xi+RandomStepXmax−XiXmax−Xi,Ymaxnf>δYi,AFprey·,elseThe schematic diagram of AFSA algorithm is shown in Figure2.Figure 2
Schematic diagram of AFSA algorithm.


## 3.2.2. Algorithm Structure Flow

The basic implementation process of artificial fish swarm algorithm is shown in Figure3.Figure 3
AFSA algorithm flow.


## 3.3. Improved Artificial Fish Swarm Algorithm

The research shows that AFSA has many excellent characteristics and can solve the nonlinear function optimization problem well. However, with the continuous development and deepening of the problem, some problems gradually appear. For example, the step size in the algorithm determines the convergence speed and optimization accuracy. When the step size is large, the artificial fish moves in a large range, and the convergence speed is relatively fast, but the accuracy is poor. On the contrary, the convergence speed is slow and the accuracy is good. Because the step in the algorithm selects a fixed value, the phenomenon that artificial fish oscillates around the optimal value is easy to occur, and the convergence accuracy and the optimization speed are in conflict. The convergence speed of the algorithm is relatively fast in the initial stage of optimization, but it is often slow in the later stage, and it is easy to fall into local optimization. In addition, AFSA generally finds a satisfactory solution domain, and it is difficult to obtain accurate values. In view of some defects of AFSA, researchers have improved AFSA from the aspects of initialization of fish swarm, adjustment of algorithm parameters, improvement of basic behavior, and combination with other intelligent algorithms to improve the optimization efficiency of AFSA.


### 3.3.1. Social Learning Mechanism

Social learning mechanism is a theoretical system formed by human beings in the process of long-term evolution. The so-called learning can be understood as a form of expression used to explore the relationship between cognition, behavior and environment. While following the natural law of gradual evolution, human beings can effectively guide the evolution of human society according to the accumulated experience and knowledge. Learning generally includes direct experience learning and indirect experience learning, and convergence and divergence are two basic behaviors in social learning. On the one hand, the individuals in the population tend to learn from the excellent individuals and use the experience and knowledge accumulated by the excellent individuals to improve and improve themselves. On the other hand, they will break through the limitations of converging to the excellent individuals and look for new development opportunities, that is, the divergent behaviors of the individuals. The convergence and divergence behaviors in the social learning mechanism can quickly learn and search for a relatively accurate optimal state. These two behaviors are described mathematically. In the early stage of optimization, the local solution domain is quickly found, and then, the convergence and divergence principles are used to search in the local solution domain. The convergence behavior ensures the progress to the global optimal solution, and the divergence behavior explores other possible optimal values in the opposite direction of the optimal solution, which improves the optimization accuracy while preventing the group from falling into the local optimal solution.


### 3.3.2. Learning Process Based on Social Learning Mechanism

The state of each individual in the population is marked asXi, the historical optimal state of the individual is marked as Xpbesti, and the optimal state of the population is marked as Xgbest. Learning is carried out by the formula Xi,iter+1=Xpbesti+r×N0,σ×Xgbest−Xi,iter, where iter is the number of iterations, r is a positive real number between 0 and 1, and N0,σ is a normal distribution random number and also a learning factor. The value of σ determines whether to conduct a fine centralized search or a broad search. The value of N0,σ determines whether to conduct convergence or divergence; that is, when N0,σ>0, individuals converge in the direction of vector difference Xpbest−Xi,iter; When N0,σ<0, individuals diverge in the opposite direction of vector difference gbest−Xi,iter. The learning process is shown in Figure 4.Figure 4
Individual learning process.Each individual takes its own historical optimal stateXpbesti as the benchmark and takes the current state Xi,iter of the individual and the vector difference Xgbest−Xi,iter of the group optimal state as the reference and updates the individual state through the organic combination of convergence and divergence [18]. The schematic diagram of two-dimensional update is shown in Figure 5.Figure 5
Schematic diagram of individual 2D update.On the basis of the above analysis, combined with the social learning mechanism, an improved artificial fish swarm algorithm (IAFSA) is obtained, which applies the convergence and divergence phenomena in the social learning mechanism to AFSA. After quickly finding the local optimal domain, on the one hand, we use the convergence behavior to evolve to the global optimal direction, and on the other hand, we use the divergence behavior to advance to the opposite direction of the optimal, so as to find other possible global optimal values and prevent falling into the local optimal.


## 3.3.1. Social Learning Mechanism

Social learning mechanism is a theoretical system formed by human beings in the process of long-term evolution. The so-called learning can be understood as a form of expression used to explore the relationship between cognition, behavior and environment. While following the natural law of gradual evolution, human beings can effectively guide the evolution of human society according to the accumulated experience and knowledge. Learning generally includes direct experience learning and indirect experience learning, and convergence and divergence are two basic behaviors in social learning. On the one hand, the individuals in the population tend to learn from the excellent individuals and use the experience and knowledge accumulated by the excellent individuals to improve and improve themselves. On the other hand, they will break through the limitations of converging to the excellent individuals and look for new development opportunities, that is, the divergent behaviors of the individuals. The convergence and divergence behaviors in the social learning mechanism can quickly learn and search for a relatively accurate optimal state. These two behaviors are described mathematically. In the early stage of optimization, the local solution domain is quickly found, and then, the convergence and divergence principles are used to search in the local solution domain. The convergence behavior ensures the progress to the global optimal solution, and the divergence behavior explores other possible optimal values in the opposite direction of the optimal solution, which improves the optimization accuracy while preventing the group from falling into the local optimal solution.


## 3.3.2. Learning Process Based on Social Learning Mechanism

The state of each individual in the population is marked asXi, the historical optimal state of the individual is marked as Xpbesti, and the optimal state of the population is marked as Xgbest. Learning is carried out by the formula Xi,iter+1=Xpbesti+r×N0,σ×Xgbest−Xi,iter, where iter is the number of iterations, r is a positive real number between 0 and 1, and N0,σ is a normal distribution random number and also a learning factor. The value of σ determines whether to conduct a fine centralized search or a broad search. The value of N0,σ determines whether to conduct convergence or divergence; that is, when N0,σ>0, individuals converge in the direction of vector difference Xpbest−Xi,iter; When N0,σ<0, individuals diverge in the opposite direction of vector difference gbest−Xi,iter. The learning process is shown in Figure 4.Figure 4
Individual learning process.Each individual takes its own historical optimal stateXpbesti as the benchmark and takes the current state Xi,iter of the individual and the vector difference Xgbest−Xi,iter of the group optimal state as the reference and updates the individual state through the organic combination of convergence and divergence [18]. The schematic diagram of two-dimensional update is shown in Figure 5.Figure 5
Schematic diagram of individual 2D update.On the basis of the above analysis, combined with the social learning mechanism, an improved artificial fish swarm algorithm (IAFSA) is obtained, which applies the convergence and divergence phenomena in the social learning mechanism to AFSA. After quickly finding the local optimal domain, on the one hand, we use the convergence behavior to evolve to the global optimal direction, and on the other hand, we use the divergence behavior to advance to the opposite direction of the optimal, so as to find other possible global optimal values and prevent falling into the local optimal.


## 4. Result Analysis

### 4.1. Result Analysis of Particle Swarm Optimization Algorithm

On the basis of the above research, the particle swarm optimization algorithm for the automatic control of group animation behavior studied in this paper is simulated, and the group animation algorithm is developed by MicrosoftVisualStudio. NET platform for autodesk maya 2016 software is used to program this algorithm. The algorithm in this paper can realize the automatic control of individual behavior in the group animation, and the group animation has a strong sense of reality, which verifies the effectiveness of the autonomous control of the algorithm in this paper and shows that the algorithm in this paper is feasible. The animation group controlled by the algorithm in this paper has artificial intelligence and can effectively reproduce the group foraging behavior. The evolution process of the movement of individuals in the group animation to the inner circle is automatically controlled by the algorithm in this paper, as shown in Figure6. In order to intuitively show the control performance of the algorithm in this paper, the algorithm in this paper is compared with the Q-learning algorithm and the target tracking algorithm.Figure 6
Evolution process of moving into the circle.The evolution process of the behavior of individuals moving to the stand in the group animation controlled by the algorithm in this paper is shown in Figure7. The Q-learning algorithm and the target tracking algorithm are used as comparison algorithms.Figure 7
Evolution process of moving to stand.It can be seen from Figures6 and 7 that when the optimal solution changes dynamically, the optimal values obtained by the three algorithms fluctuate obviously. The main reason is that the original optimal solution changes into a suboptimal solution after dynamic changes. The algorithm in this article can find the best solution in the fastest time. As the evolution time increases, the physical value will decrease, indicating that the algorithm presented in this paper has used better results in the past and made it faster to get the good problem solving. The algorithm in this paper can control the group animation with less transition time, which confirms the effectiveness of the group animation control algorithm. The algorithm in this paper can effectively track the dynamic environment changes in the group animation during the control process, and the convergence speed is obviously better than the other two algorithms. It shows that the algorithm in this paper has good adaptive ability, and the fitness value obtained is close to the global minimum value.After the algorithm in this paper converges to the global optimal solution, the evolution times of the algorithm in this paper converge to the global optimal solution again when the surrounding environment changes 10 times, and the algorithm in this paper is compared with theQ-learning algorithm and the target tracking algorithm. The results are shown in Tables 1–3.Table 1
Comparison of algorithm evolution algebra in this paper/generation.
Number of environmental changesMove into the circleMove to stand156522545335152452475504964945748458454394140104038Table 2
Comparison of evolution algebra ofQ-learning algorithm/generation.
Number of environmental changesMove into the circleMove to stand177742747637277479725777467775776788728097476107870Table 3
Comparison of evolution algebra of target tracking algorithm/generation.
Number of environmental changesMove into the circleMove to stand180832838938187478855858568382780788777397277107471From the experimental results in Tables1–3, it can be seen that the evolution times of the algorithm in this paper in the automatic control of the movement of individuals to the circle and the movement to the stand in the group animation are significantly less than those of the Q-learning algorithm and the target tracking algorithm, which indicates that the algorithm in this paper can converge to the global extremum quickly and effectively verifies that the algorithm in this paper has excellent optimization performance.The diversity of the population in the particle swarm optimization algorithm can make the environment change, and the particles in the algorithm can still cover a large area of the search space, which provides support for the particle swarm optimization algorithm to find a new global optimal value, and can improve the excessive convergence of the particles and make the algorithm fall into the local optimal value. The diversity of the group in the process of finding the global optimal solution when the individuals in the group animation move to the circle automatically controlled by the algorithm in this paper is shown in Figure8. The algorithm in this paper is compared with the Q-learning algorithm and the target tracking algorithm.Figure 8
Comparison of diversity within the circle.The group diversity in the process of searching for the global optimal solution when the individual moves to the stand in the automatic control group animation is shown in Figure9. The algorithm in this paper is compared with the Q-learning algorithm and the target tracking algorithm.Figure 9
Diversity comparison of moving to stand.From the experimental results in Figures8 and 9, it can be seen that the population diversity of the algorithm in this paper is significantly better than that of the other two algorithms in the process of automatically controlling the behavior of individuals moving to the circle and to the stand in the group animation, which shows that the algorithm in this paper has high global search performance and the algorithm in this paper has high control performance when applied to the automatic control of group animation.


### 4.2. Result Analysis of Artificial Fish Swarm Algorithm

In order to verify the effectiveness of the improved algorithm, three functions are selected for testing. The experimental functions are as follows:(1)
f1:∑i=1nxi2−10cos2πxi+10. The search scope is −10,10; the minimum value 0 is obtained at 0,⋯,0(2)
f2:1/4000∑i=1nxi2−∏i=1ncosxi/i+1. The search range is [-600, 600], and the minimum value 0 is obtained at 0,⋯,0(3)
f3:∑i=1n−1100xi+12−xi2+1−xi2. The search range is [-100, 100], and the minimum value 0 is obtained at 1,⋯,1The parameter initialization results in the experiment are as follows.The population sizeNp is 20, the crowding factor δ is 11, the maximum number of attempts trynumber is 5, and Visual=2.5,Step=0.3 for the function f1; for function f2, take Visual=150,Step=18; for function f3, take Visual=25,Step=3.The three functions are simulated by AFSA and IAFSA, respectively. The experimental results of 50 independent execution of each function are summarized in Tables4–6 [19].Table 4
Execution results of two optimization algorithms (functionf1).
AlgorithmOptimal valueAverage valueWorst valueAverage operation time (s)AFSA86.72701137.3256183.59512.3682IAFSA2.64e-112.3614918.273190.8928Table 5
Execution results of two optimization algorithms (functionf2).
AlgorithmOptimal valueAverage valueWorst valueAverage operation time (s)AFSA0.4524130.7207806.5630522.0419IAFSA0.0001530.0276350.1204220.7352Table 6
Execution results of two optimization algorithms (functionf3).
AlgorithmOptimal valueAverage valueWorst valueAverage operation time (s)AFSA54.3642031291.731049063.83.1034IAFSA0.0043804.0545889.4271390.9511In addition, Figures10–12 are comparison diagrams of evolution curves of experiments on three functions with AFSA and IAFSA, wherein the abscissa is the evolution algebra and the ordinate is the common logarithm of the average value of 50 experimental functions. The evolution comparison diagram is shown in Figures 10–12.Figure 10
Evolution curve of average optimal value of functionf1.Figure 11
Evolution curve of average optimal value of functionf2.Figure 12
Evolution curve of average optimal value of functionf3.It can be seen from the experimental results in Tables4–6 that compared with the original algorithm AFSA, the improved algorithm proposed in this paper is easier to obtain the global optimal value, and the optimization speed is also greatly improved [20]. In addition, it can be seen from the evolution curves of the three functions that the convergence speed of the improved algorithm is obviously accelerated and the accuracy is also improved when the evolution algebra is fixed.


## 4.1. Result Analysis of Particle Swarm Optimization Algorithm

On the basis of the above research, the particle swarm optimization algorithm for the automatic control of group animation behavior studied in this paper is simulated, and the group animation algorithm is developed by MicrosoftVisualStudio. NET platform for autodesk maya 2016 software is used to program this algorithm. The algorithm in this paper can realize the automatic control of individual behavior in the group animation, and the group animation has a strong sense of reality, which verifies the effectiveness of the autonomous control of the algorithm in this paper and shows that the algorithm in this paper is feasible. The animation group controlled by the algorithm in this paper has artificial intelligence and can effectively reproduce the group foraging behavior. The evolution process of the movement of individuals in the group animation to the inner circle is automatically controlled by the algorithm in this paper, as shown in Figure6. In order to intuitively show the control performance of the algorithm in this paper, the algorithm in this paper is compared with the Q-learning algorithm and the target tracking algorithm.Figure 6
Evolution process of moving into the circle.The evolution process of the behavior of individuals moving to the stand in the group animation controlled by the algorithm in this paper is shown in Figure7. The Q-learning algorithm and the target tracking algorithm are used as comparison algorithms.Figure 7
Evolution process of moving to stand.It can be seen from Figures6 and 7 that when the optimal solution changes dynamically, the optimal values obtained by the three algorithms fluctuate obviously. The main reason is that the original optimal solution changes into a suboptimal solution after dynamic changes. The algorithm in this article can find the best solution in the fastest time. As the evolution time increases, the physical value will decrease, indicating that the algorithm presented in this paper has used better results in the past and made it faster to get the good problem solving. The algorithm in this paper can control the group animation with less transition time, which confirms the effectiveness of the group animation control algorithm. The algorithm in this paper can effectively track the dynamic environment changes in the group animation during the control process, and the convergence speed is obviously better than the other two algorithms. It shows that the algorithm in this paper has good adaptive ability, and the fitness value obtained is close to the global minimum value.After the algorithm in this paper converges to the global optimal solution, the evolution times of the algorithm in this paper converge to the global optimal solution again when the surrounding environment changes 10 times, and the algorithm in this paper is compared with theQ-learning algorithm and the target tracking algorithm. The results are shown in Tables 1–3.Table 1
Comparison of algorithm evolution algebra in this paper/generation.
Number of environmental changesMove into the circleMove to stand156522545335152452475504964945748458454394140104038Table 2
Comparison of evolution algebra ofQ-learning algorithm/generation.
Number of environmental changesMove into the circleMove to stand177742747637277479725777467775776788728097476107870Table 3
Comparison of evolution algebra of target tracking algorithm/generation.
Number of environmental changesMove into the circleMove to stand180832838938187478855858568382780788777397277107471From the experimental results in Tables1–3, it can be seen that the evolution times of the algorithm in this paper in the automatic control of the movement of individuals to the circle and the movement to the stand in the group animation are significantly less than those of the Q-learning algorithm and the target tracking algorithm, which indicates that the algorithm in this paper can converge to the global extremum quickly and effectively verifies that the algorithm in this paper has excellent optimization performance.The diversity of the population in the particle swarm optimization algorithm can make the environment change, and the particles in the algorithm can still cover a large area of the search space, which provides support for the particle swarm optimization algorithm to find a new global optimal value, and can improve the excessive convergence of the particles and make the algorithm fall into the local optimal value. The diversity of the group in the process of finding the global optimal solution when the individuals in the group animation move to the circle automatically controlled by the algorithm in this paper is shown in Figure8. The algorithm in this paper is compared with the Q-learning algorithm and the target tracking algorithm.Figure 8
Comparison of diversity within the circle.The group diversity in the process of searching for the global optimal solution when the individual moves to the stand in the automatic control group animation is shown in Figure9. The algorithm in this paper is compared with the Q-learning algorithm and the target tracking algorithm.Figure 9
Diversity comparison of moving to stand.From the experimental results in Figures8 and 9, it can be seen that the population diversity of the algorithm in this paper is significantly better than that of the other two algorithms in the process of automatically controlling the behavior of individuals moving to the circle and to the stand in the group animation, which shows that the algorithm in this paper has high global search performance and the algorithm in this paper has high control performance when applied to the automatic control of group animation.


## 4.2. Result Analysis of Artificial Fish Swarm Algorithm

In order to verify the effectiveness of the improved algorithm, three functions are selected for testing. The experimental functions are as follows:(1)
f1:∑i=1nxi2−10cos2πxi+10. The search scope is −10,10; the minimum value 0 is obtained at 0,⋯,0(2)
f2:1/4000∑i=1nxi2−∏i=1ncosxi/i+1. The search range is [-600, 600], and the minimum value 0 is obtained at 0,⋯,0(3)
f3:∑i=1n−1100xi+12−xi2+1−xi2. The search range is [-100, 100], and the minimum value 0 is obtained at 1,⋯,1The parameter initialization results in the experiment are as follows.The population sizeNp is 20, the crowding factor δ is 11, the maximum number of attempts trynumber is 5, and Visual=2.5,Step=0.3 for the function f1; for function f2, take Visual=150,Step=18; for function f3, take Visual=25,Step=3.The three functions are simulated by AFSA and IAFSA, respectively. The experimental results of 50 independent execution of each function are summarized in Tables4–6 [19].Table 4
Execution results of two optimization algorithms (functionf1).
AlgorithmOptimal valueAverage valueWorst valueAverage operation time (s)AFSA86.72701137.3256183.59512.3682IAFSA2.64e-112.3614918.273190.8928Table 5
Execution results of two optimization algorithms (functionf2).
AlgorithmOptimal valueAverage valueWorst valueAverage operation time (s)AFSA0.4524130.7207806.5630522.0419IAFSA0.0001530.0276350.1204220.7352Table 6
Execution results of two optimization algorithms (functionf3).
AlgorithmOptimal valueAverage valueWorst valueAverage operation time (s)AFSA54.3642031291.731049063.83.1034IAFSA0.0043804.0545889.4271390.9511In addition, Figures10–12 are comparison diagrams of evolution curves of experiments on three functions with AFSA and IAFSA, wherein the abscissa is the evolution algebra and the ordinate is the common logarithm of the average value of 50 experimental functions. The evolution comparison diagram is shown in Figures 10–12.Figure 10
Evolution curve of average optimal value of functionf1.Figure 11
Evolution curve of average optimal value of functionf2.Figure 12
Evolution curve of average optimal value of functionf3.It can be seen from the experimental results in Tables4–6 that compared with the original algorithm AFSA, the improved algorithm proposed in this paper is easier to obtain the global optimal value, and the optimization speed is also greatly improved [20]. In addition, it can be seen from the evolution curves of the three functions that the convergence speed of the improved algorithm is obviously accelerated and the accuracy is also improved when the evolution algebra is fixed.


## 5. Conclusion

The algorithm in this paper applies the particle swarm optimization algorithm to the automatic control of group animation behavior and determines whether there are changes around the individual according to the global extreme value. When there are environmental changes, some particles need to be reinitialized to expand the search range of the population and improve the diversity of the particle population. Through the memory function of the particles, the particle swarm is prevented from falling into the local optimal situation, and the automatic control effect of group animation behavior is higher. Through experiments, the effectiveness of the algorithm in automatically controlling the group animation behavior is verified. The algorithm can automatically control the movement of individuals in the group animation according to the movement trajectory according to the user’s wishes and realize the following effect of moving objects. The group animation behavior automatically controlled by the algorithm has the advantages of strong realism and good control performance. In addition, this paper introduces the idea of artificial fish swarm algorithm (AFSA), the basic behavior description of artificial fish, and the structure and flow of the algorithm. Then, it analyzes some problems of AFSA and the related improvement research of some scholars. On this basis, an improved artificial fish swarm algorithm (IAFSA) is proposed, and the effect of the improved algorithm is analyzed experimentally, and the corresponding conclusions are drawn.



---

*Source: 9881957-2022-09-29.xml*