{'fraction_non_alphanumeric': 0.03876812511071184, 'fraction_numerical': 0.013842143887440848, 'mean_word_length': 4.328748651564186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
On enhancing efficiency and accuracy of particle swarm optimization algorithms

The particle swarm optimization (PSO) algorithm has been recently introduced in the non--linear programming, becoming widely studied and used in a variety of applications. Starting from its original formulation, many variants for improvement and specialization of the PSO have been already proposed, but without any definitive result, thus research in this area is nowadays still rather active. This paper goes in this direction, by proposing some modifications to the basic PSO algorithm, aiming at enhancements in aspects that impact on the efficiency and accuracy of the optimization algorithm. In particular, variants of PSO based on fuzzy logics and Bayesian theory have been developed, which show better, or competitive, performances when compared to both the basic PSO formulation and a few other optimization algorithms taken from the literature.


Introduction
Many techniques, mainly based on metaheuristic algorithms, have been developed for solving non-linear programming. In particular, chaotic algorithms [36], evolutionary programming [44,42], genetic algorithms [46,3], tabu search algorithm [21,23], have been widely used in these studies. Recently, the particle swarm optimization (PSO) algorithm [20] has been introduced in the non-linear programming becoming widely studied and used in a variety of applications [47,12,19].
The PSO algorithm performs a metaheuristic search based on competition and cooperation among particles (which represent the search variables) belonging to an initial swarm or population that covers the search space. After the basic technique was defined, numerous proposals for improvement and specialization of the PSO have appeared (refer [33] for a partial survey). Still, further investigations are nowadays of interest and solicited in PSO, to better respond to application needs in a growing variety of sectors, with related emphasis on different aspects, such as efficiency and accuracy.
In this paper we propose some modifications to the basic PSO algorithm, aiming at enhancements in the following three aspects that determine the efficiency and accuracy of the optimization algorithm: • the setting of the initial population, based on the partitioning of the search space in disjoint intervals, one for each particle, such that the initial position for each different particle is selected from a different interval, • the setting of the acceleration constants and of the inertia weight parameter, defined by using a fuzzy logics based strategy, • the calculation of the current position of each particle, based on a Bayesian approach.
By adopting approaches very suited to support the dynamics of the PSO algorithm, such as the fuzzy logics and the Bayesian theory, this paper offers novel solutions which improve on the basic PSO formulation, thus potentially resulting more appealing to be employed, as suggested by the evaluation studies already performed. Although the literature on this family of optimazation algorithms is very abundant, as already recalled, our goal is to enrich the set of alternatives to enhance the choice of the best solution that fits specific applications needs and characteristics.
The rest of the paper is structured as follows. A brief recall of the basic PSO algorithm is presented in Section 2. In Section 3, the motivation and innovative aspects of the three proposed modifications to the basic PSO algorithm are discussed. In the next three sections, we develop our enhancements to the basic PSO algorithm. In particular, the setting proposed for the initial population is described in Section 4; the approach proposed to set the acceleration constants and the inertia weight is described in Section 5, while Section 6 contains the new method to move the control variables in the search space. By composing the proposed improvements, two variants of the PSO algorithm are assembled in Section 7, which are then evaluated and compared both with the basic PSO algorithm in terms of indicators representative of their accuracy and efficiency, and with other solutions taken from the literature when employed to support power flow optimization in a simple but realistic case study in the electrical power sector. Finally, Section 8 is devoted to the conclusions.

Overview of the basic PSO algorithm
In this section, the basic PSO algorithm is briefly described, to provide the context for the variants that will be presented in the next sections. In general terms, an optimization problem is the problem of minimizing (or maximizing) an objective function f (x 1 . . . , x d , y 1 , . . . , y s ), where x i are the search variables, representing the parameters of the problem that are to be optimized, and y i are the state variables, representing the parameters that can be derived as function of the search variables. The variables x i and y i can be bounded and related together by means of constraint equations or disequations. For the sake of simplicity, in the following, we omit variables y i from the notation of the objective function and we only consider search variables x i .
The PSO algorithm is a metaheuristic global optimization method which tries to find those values of the search variables x 1 , ...x d for which the value of the cost function f (x 1 , ...x d ) is minimum (or maximum). The search is based on a discrete-time stochastic process describing the competition and cooperation between a population or swarm of particles that move in a search-variables space. The PSO algorithm considers a fixed size swarm of D particles that randomly change position with velocity v p (k) at each discrete instant of time (step) k, according to their own experience and that of their neighbors.
The starting velocity and position of the particles at step 0 are initialized at lines 5 and 6, respectively. The personal best position l p for the particle p at step k is the best position the particle p has visited since the first step, i.e., the position that minimizes the objective function among all the positions of p for different values of k. It is updated at line 12. The global best position b at each step k is the best position discovered by any of the particles so far. It is usually calculated as the personal best position and it is obtained as the personal best position at step k that minimizes the objective function, as shown at line 14, where b is updated.
The position x p (k) of the particle p at step k is updated at line 19, based on the random value assigned to the velocity v p (k), as shown from line 16 to line 18. The velocity vector drives the optimization process and results from the sum of three different components, as shown at line 18: the momentum component, which is the previous velocity, the cognitive component, which is proportional to the distance of the particle from the best position it has ever visited, and, finally, the social component which is proportional to the particle's distance from the best position where any of the swarm's particles has ever been.
The PSO algorithm has some critical points that heavily influence its performances, like the initial position of the particles and the choice of some parameters, such as inertia weight w and the acceleration constants c 1 and c 2 , used to scale the contribution of the moment to the velocity, and of the cognitive and social components, respectively [11]. Indeed, if the initial position of the particles is a well-distributed cover of the search space, then there is a higher probability to avoid local best position and to approach the global optimum. Moreover, parameters w, c 1 , c 2 heavily influence the velocity of the particles, i.e., their movements in the search space.
In the next sections we present and evaluate three variants of the PSO algorithm, aiming at enhancements in the aspects just recalled that determine the efficiency and accuracy of the optimization algorithm.

Three new variants of the PSO algorithm: motivation and innovative aspects
In this section, we discuss the motivation and the innovative aspects of the three proposed variants for the PSO algorithm. The efficiency of PSO is influenced by the initial position of the particles, i.e. by how well particles are distributed over the search space, since if regions of the search space are not covered by the initial positions, the PSO will have difficulty in finding the optimum if it is located within an uncovered region [11]. Usually, the initial position of each particle is randomly generated, with uniform distribution, from the set of all possible positions of the particles. In this case, it is important to use a good pseudo-random generator, otherwise the performances heavily degrade. In [27], the authors propose to reinitialize the particle that has the worst performance (i.e., corresponding to the biggest objective function value). In [32], re-initialization of a certain percentage of the total population is considered if after some steps there is no significative improvement. In [47], an orthogonal design is proposed in order to sample the initial positions. In [45], the authors determine the initial position of the particles by means of the Tent chaotic map. In Section 4, we propose an original algorithm that forces a uniform distribution for the position of the initial particles, dividing the search space into small intervals where we randomly generate the initial positions.
As discussed in the previous section, the values of parameters w, c 1 , c 2 affect the performance of the PSO algorithm. Standard values for the parameters of the PSO algorithm are c 1 = c 2 = 1.496172 and w = 0.72984 [5]. However, in many works (like [4], [17], [28] and [32]) values of c 1 , c 2 , w are not constant, but they change during the execution of the algorithm. This is mainly due to the fact that at the initial steps of the algorithm large values for w are preferable so that particles have a greater possibility of movement [31]. On the contrary, small values for w are preferable towards the final steps of the algorithm. Moreover, other different components could be chosen for modifying the values of w, c 1 , c 2 , like, e.g., the distance between the current particles and the best particles. Since, there are no defined rules to determine the relationship between parameters w, c 1 , c 2 and other components (such as the current step of the algorithm), in Section 5, we use fuzzy logic in order to manage these relationships. Indeed, fuzzy logics is congenial to capture and to code expert-based knowledge in view of performing targeted simulations. Usually the fuzzy logic-based systems are tuned using heuristic criteria (see, e.g., [7,30]). Fuzzy logic has been already used in various ways for improving the PSO algorithm [1,29]. In [37], a fuzzy system is defined to dynamically adapt the inertia weight of the PSO. It is based on two input variables, which measure the current best performance and the current inertia weight, and on an output variable, which is the change of the inertia weight. Our approach differs from previous usages of fuzzy logics (as in [29,37]) in the choice of the input fuzzy variables, in the tuning of the membership functions and in the fuzzy rules that combine input/output fuzzy variables together with their membership functions.
Finally, in Section 6 we propose an innovative method to update the position of the particles at each step of the algorithm. The core idea of the basic PSO algorithm is to move the particles around the search space using information provided by personal and global best positions as shown in Algorithm 1. Here, we propose to move the particles in the search space by balancing the current position of each particle with the current personal and global best positions by means of equations based on the Kalman filter [18]. The Kalman filter uses a Bayesian approach providing a posterior estimation for a system's state from the current measurement and the prior estimation of that system's state by means of the Bayes theorem. In typical applications of the Kalman filter, it takes a sequence of measurements over time, containing noise (random variations) and other inaccuracies, and produces statistically optimal estimates of unknown variables. In our context, such a Bayesian approach has been reproduced considering the current position of the particles and the current global best position as the current measurement and the prior estimation, respectively. The posterior estimation is the new global best position of the particles that should be an improved estimation for the position of the unknown global best. D where ρ() is the random permutation function of the indexes of the particles, as shown at line 5. Using this approach, the location of each different particle is selected for each dimension (search variable) from different partitions of the range of values for that dimension, improving the distribution of the particles in the search space. This approach also protects against weaknesses of bad pseudo-random generators, which might result in a poor cover of the search space.

Variant 2: fuzzy logic-based inertia weight and acceleration constants
Usually, as shown in [5], the following relation among w, c 1 , c 2 holds: from which, using equal values for c 1 , c 2 , we obtain Some works, like [28], propose a varying value for w: where k is the current step of the algorithm, k max is the maximum number of steps, and usually w min = 0.8 and w max = 1.2. In [32] and [48] different formulas for w have been proposed and in [17] similar formulas have been used for the coefficients c 1 and c 2 . In [4], a good survey on the problem of determining the parameters w, c 1 , c 2 is provided.
Here, we propose a novel fuzzy strategy to determine the parameters w, c 1 , c 2 based on the steps number and the current particle position. Generally, a fuzzy strategy is composed by • fuzzy variables (input and output), fuzzy sets and membership functions, • fuzzy rules that relate input and output variables, • a fuzzy inference engine that combines the fuzzy rules, • a defuzzification method that provides an output value.
Our strategy is based on a 2-input/1-output inference scheme, with the fuzzy variables k, α and w. The output is the value of w. The first input is the current step k of the algorithm. The second input is the percentage distance between the objective function f (x p (k)) evaluated on the current position of the particle p at step k and the objective function f (b) evaluated on the global best position at step k. When α is small, it may be convenient to move the particle around its current position, corresponding to a low value of w. On the contrary, when α is large it may be sensible moving the particle far from its current position, corresponding to a high value of w.
During the execution of the PSO algorithm, the value of w can be evaluated at each step k in the following way. A membership degree is assigned to the current step k, as shown in Figure 1a for different fuzzy sets: VeryShort, Short, Moderate, Long, VeryLong. A fuzzy set characterizes the current step k in terms of the membership degree of k, according to the following rules (the choice of values are expert based): For example, looking at Figure 1a if the value of k is less or equal than kmax 20 , then k belongs to the fuzzy set VeryShort with membership degree 1. If 2kmax 20 ≤ k ≤ 4kmax 20 , then k belongs to the fuzzy sets VeryShort and Short with membership degrees given by the ordinates of the corresponding curves.
Similarly, a membership degree is assigned to α, as shown in Figure 1b, according to the following rules: where Small, Medium and Large are the labels of the fuzzy sets that characterize the distance variable α. Let us observe that if α < 0, then we set α = 0 as input. Indeed, in this case the current particle has improved the global best and consequently we would like to perform the search around this position giving to α the maximum membership degree 1 at the fuzzy set Small.
Finally, the membership degree of w is obtained, as shown in Figure 1c, according to the following rules (the choice of values are expert based): where Low, Intermediate and High are the labels of the fuzzy sets related to w.
The derived membership functions (depicted by triangular or trapezoidal shapes) reflect expert-based choices. The inference system, used by the inference engine to derive the value of w, is based on the eleven rules shown in Table 1.
The inference engine is the basic Mamdani model [26] with if-then rules, minimax set-operations, sum for composition of activated rules, and defuzzification based on the centroid method that provides the abscissa of the barycentre of the fuzzy set composed according to the activated rules.
Finally, the values of c 1 and c 2 can be derived as a function of w from (1).
6 Variant 3: Bayesian approach to change the position of particles In this section, we propose a new strategy to change the position of the particles with respect to the PSO algorithm shown in Algorithm 1. Specifically, in Subsection 6.1 we derive the new algorithm based on the Kalman filter, and in Subsection 6.2 we describe the new parameters of the algorithm and we analyze how they impact on the velocity of the particles.

Bayesian PSO algorithm
In [8], the authors highlighted that the Kalman filter can be taken back to the Bayes theorem, considering random variables with normal distributions. Let L|X, X and X|L be random variables denoting, in terms of the Kalman filter, respectively, the current measurement (conditional on unknown parameter X), the prior estimation and the posterior estimation of the system's state. The Bayes theorem states where f X|L is the posterior density, f X the prior density, f L|X the likelihood and the denominator is a normalization factor. Assume that L|X and X have the normal distributions N (µ L|X , σ 2 L|X ) and N (µ X , σ 2 X ), respectively. Then, it is well-known that the posterior estimation X|L has the normal distribution N (µ X|L , σ 2 X|L ), where Now, we define the new position of the particles at step k, for k ≥ 1, of the PSO algorithm, in terms of the Kalman filter.
For each particle p = 1, . . . , D and for each dimension i = 1, . . . , d, we consider that: • the global best position b i (k −1) (for the sake of brevity denoted as b i ) is the current measurement B|Y , • the position x pi (k − 1) is the prior estimation Y = X|L, and • the new position x pi (k) is the posterior estimation Y |B.
The prior estimation Y is obtained by the posterior estimation X|L of the new position x pi (k), considering that: • the personal best position l pi (k − 1) (for the sake of brevity denoted as l pi ) is the current measurement L|X, • the position x pi (k − 1) is the prior estimation X, and • the new position x pi (k) is the posterior estimation X|L.
Thus, observing that L|X ∼ N (l pi , σ 2 L|X ) and X ∼ N (x pi (k − 1), σ 2 pi (k − 1)), the posterior density of the random variable Y = X|L is the normal distribution N (µ X|L (k), σ 2 X|L (k)) derived by the Bayes theorem as where Using this Bayesian approach to change the position of the particles, the value for x pi (k), at each step k, for each particle p and each dimension i, is derived from the random variable Y |B with normal distribution N (µ Y |B (k), σ 2 Y |B (k)) as The mean µ Y |B (k) is derived from equation (2) replacing recursively . In this way, considering h(k) the number of steps with a new global best until the step k, for k ≥ 1, i.e., with h(0) = 0, then the closed formulas of σ 2 Y |B (k), δ L|X (k) and δ B|Y (k) for k ≥ 1 are given by The function h(k) is monotone non-decreasing and h(k) ≤ k.
The dimension i of the velocity of the particle p at step k, denoted by v pi (k), is derived as the difference of two normal random variables In (10) the velocity v pi (k) results from the sum of the cognitive and social components of the PSO. Thus, as soon as the current position of a particle converges to the current personal and to the current global best position, the mean of the velocity µ V (k) becomes 0 and the expected new position of the particle tends to be equal to the current one. In this case, although the mean of the new velocity is 0, a new position, that can be also significantly different from the current position, can occur with a probability that depends on the value of the variance σ 2 Y |B (k − 1). A different formula for µ V (k) can be derived from (10) (as described in Appendix A), showing that the velocity v pi (k) can result from the sum of three different components (the momentum, the difference between the local best positions of the last two steps and the difference between the global best positions of the last two steps), obtaining Equation (12) shows that, when the mean µ V (k) of the velocity of a particle is greater than 0, the particle changes direction with respect to the current velocity (moment or inertia component) only when new current personal or global best positions occur. Otherwise, when personal or global best positions do not change then the magnitude of new velocity is obtained as a fraction of the current velocity. When the i-th dimension of the research space is bounded by x min i and x max i , the value (2) and (3), using the formula  (14) and (15) such that the probability that Y |B lies out of this interval is small. This probability is less than the probability that Y |B is out of the interval , that is equal to 0.003 [41].

Parameters and analysis of the Bayesian PSO algorithm
As shown in (2), the new position of a particle is determined by means of a weighted mean among the previous position of the particle, the current personal best position and the current global best position. The weights of each component are determined by δ L|X (k−1) and δ B|Y (k − 1), which are defined as a function of the variances σ 2 B|Y , σ 2 L|X and σ 2 pi (0). These variances represent the uncertainties associated to the current measurement at each step of b i (conditioned to the prior estimation of l i ), the current measurement at each step of l i (conditioned to the prior estimation of the position x pi ) and the posterior estimation at step 1 of the new position x pi (1), respectively. Parameters σ 2 B|Y and σ 2 L|X correspond to the acceleration coefficients of the basic PSO algorithm, since they control the impact of the cognitive and social components on the velocity of the particle. Parameter σ 2 pi (0) adjusts the position of a particle with respect to the new value of the mean µ Y |B (k). From (4) and (10) it follows that, the ratio of the weights of the cognitive and social components is 12 Algorithm 3: Bayesian approach to update the position of each particle at step k, with k ≥ 1 of the i-th dimension of the particle's position 4 Result: x pi (k), µ Y |B (k) and σ 2 Y |B (k) for p and i 5 begin 6 for p = 1, . . . , D do // for each particle µ Y |B (k) ← the right expression of equation (2) 12 if new global best then 13 σ 2 Y |B (k) ← the right expression of equation (3) 14 Thus, when σ 2 L|X < σ 2 B|X , the impact of the cognitive component on the velocity of the particle is greater than of the impact of the social component, like in the basic PSO algorithm when c 1 > c 2 . In this case, the particle is more attracted to its own personal best position, resulting in excessive wandering [11]. On the other hand, if σ 2 L|X > σ 2 B|X then, like in the basic PSO algorithm when c 1 < c 2 , the particle is strongly attracted to the global best position, causing particles to converge prematurely towards global best position [11]. Considering different values of σ 2 L|X and σ 2 B|Y while maintaining the same ratio, different values for µ V (k) can be obtained without changing the relative impacts of the cognitive and social components.
From (10) it follows that, for k ≥ 1: • the mean of the new position µ Y |B (k) remains equal to the mean of the current position µ Y |B (k − 1), i.e., the mean of the velocity µ V (k) tends to 0, as δ L|X (k − 1) and δ B|Y (k − 1) approach to 0, and • µ Y |B (k) tends to l pi (k − 1) or b i (k − 1) when, respectively, δ L|X (k − 1) or δ B|Y (k − 1) tend to infinity.
In fact, δ L|X (k) or δ B|Y (k) can assume very high values only when k = 0. Definitions (4) for k = 0 imply that δ L|X (0) or δ B|Y (0) vary from 0 to infinity as σ 2 L|X or σ 2 B|Y , respectively, vary from infinity to 0, or as σ 2 Y |B (0) varies from 0 to infinity. From the closed formulas (8) and (9) we derive that, depending on the initial value assigned to σ 2 pi (0), for h(k) ≥ 1 where δ L|X (k) and δ B|Y (k) become 0 when σ 2 pi (0) tends to 0, and they tend to their respective (less than 1) upper bounds when σ 2 pi (0) approaches infinity. Thus, the maximum value that δ 2 L|X (k) and δ 2 B|Y (k) can reach for h(k) ≥ 1 depends on the ratio between the values of σ 2 L|X and σ 2 B|Y and on the value of h(k), independently from the value of σ 2 pi (0). Replacing the bounds of equation (17) in equation (10) we get where, for h(k) ≥ 1, the mean µ V (k) of the velocity becomes 0, when σ 2 pi (0) approaches 0, and it tends to the upper bound of (18), when σ 2 pi (0) approaches infinity. From (8) and (9) it follows also that, for h(k) ≥ 1, δ 2 L|X (k) and δ 2 B|Y (k) have opposite trends, with δ 2 L|X (k) decreasing and δ 2 B|Y (k) increasing for increasing values of σ 2 L|X , and with δ 2 L|X (k) increasing and δ 2 B|Y (k) decreasing for increasing values of σ 2 B|Y . This implies that, when the two (cognitive and social) components of the velocity in (10) are positive and for a fixed value of σ 2 pi (0) and h(k), the mean µ V (k) of the velocity is greater than a positive lower bound; it is not dependent on the values of σ 2 L|X and σ 2 B|Y , but only on the value of σ 2 pi (0) and h(k). Thus, when the cognitive and social components of the velocity in (10) are positive, µ V (k) for h(k) ≥ 1 is limited by a positive lower bound, that depends only on h(k) and σ 2 pi (0), and by the upper bound of (18), that depends only on h(k) and on the ratio between σ 2 L|X and σ 2 B|Y . Depending on the initial value assigned to σ 2 pi (0), from (7) we have for h(k) ≥ 1 where σ 2 Y |B (k) becomes 0, when σ 2 pi (0) approaches 0, and it tends to the upper bound of (19), when σ 2 pi (0) approaches infinity. Thus, the maximum value that the variance σ 2 Y |B (k) and σ 2 V (k) can reach is limited by the values of the parameters σ 2 L|X and σ 2 B|Y , independently from the value of σ 2 pi (0). From (7) we derive that, for values of σ 2 L|X >> σ 2 pi (0) or σ 2 B|Y >> σ 2 pi (0) and for a limited value of h(k), the variance σ 2 Y |B (k) can be approximated by the constant σ 2 pi (0).
As an example of parameter setting, considering σ 2 L|X = σ 2 B|Y and σ 2 pi (0) >> σ 2 L|X , we get for h(k) ≥ 1 where the right side expressions of the two equations are derived from the upper bounds of (17) and (19), respectively. When the number of new global best positions h(k) of the algorithm increases, the uncertainties relative to the current personal best position and the current global best position decrease, since improved positions for the personal and global best should be reached. From the previous discussion about the trends of µ Y |B (k) and from equations (7), (8) and (9) it follows that, for increasing values of h(k), the mean µ Y |B (k) tends to be constant and the variance σ 2 Y |B (k) decreases to 0. In order to avoid that the mean µ V (k) and the variance σ 2 V (k) of the velocity decrease below a certain minimum value before the optimal position is reached, the following condition must be verified: where > 0 and k max is the maximum number of steps for which the optimal position is reached. Given the values for σ 2 L|X , σ 2 B|Y , k max and , then the minimum value for σ 2 pi (0) for which the variance σ 2 Y |B (k max ) ≥ is derived from (7) as .
For large values of σ 2 L|X or σ 2 B|Y , formula (21) is approximated by . On the contrary, low values of σ 2 L|X and σ 2 B|Y imply smaller values for or h(k max ) and values for σ 2 pi (0) higher than .

Evaluation of the proposed solutions
In this section, we carry on an evaluation study to assess performance and quality indicators of our solutions via simulation. To this purpose, we set up two variants of the basic PSO algorithm by assembling the previously described features. Specifically, the two PSO variants we concentrate on are generated respectively by i) employing the novel Algorithm 2 for the sample of the initial population and the fuzzy approach described in Section 5 (referred in the following as PSOF variant), and ii) the novel Algorithm 2 and the Algorithm 3 to change the position of particles (referred in the following as PSOB variant). Two kinds of evaluation are performed. First, the PSOF and PSOB solutions are compared with the basic PSO algorithm (indicated as PSOC) in terms of performance and quality indicators. Then, the new algorithms are employed in a simple but realistic use case in the electrical power sector taken from the literature and compared with a few other optimization solutions already adopted in the referred study. These analyses are detailed in the next two subsections.

Analysis and comparison with the basic PSO
In this study, we consider the Rosenbrock function [34] and the Griewank function [14], which are functions widely used to test the quality of optimization algorithms. In particular, we will use their multi-dimensional generalizations, i.e., and respectively. Moreover, we consider -10 and 10 as the lower and upper bounds for each variable of the Rosenbrock function and -20, 20 as the lower and upper bounds for each variable of the Grienwank function.
The two indicators we analyzed are accuracy A, which represents the ability of the algorithm to better approximate (or possibly reach) the optimal solution b * within a given number of steps, and efficiency K, which represents the promptness (in number of steps) of the algorithm in reaching the optimal solution b * or a certain approximated value a of the objective function. A and K are random variables defined as ) ≤ a and k is not limited}.
When the minimum of the objective function is 0, i.e., f (b * ) = 0, then A is equal to the minimum value of the objective function obtained by the PSO algorithm, i.e., f (b(k max )).
To enrich the analyses and the comparison between the three variants, for both indicators we evaluated the minimum and maximum values obtained out of the set of simulations performed, as well as the mean value, i.e., For the PSOF algorithm, the coefficients w, c 1 , c 2 are determined at each step k by using the fuzzy inference scheme described in Section 5. Finally, in the PSOB algorithm, the parameters σ 2 pi (0), σ 2 L|X , σ 2 B|Y are set by expertbased choice as follows: for each component i of the p-th particle.

Accuracy evaluation results
Results of 100 simulation runs to evaluate the accuracy parameter are summarized in Table  2 for the PSOC, PSOF, PSOB algorithms used to minimize the Rosenbrock function with d = 3. The Rosenbrock function with d = 3 takes the minimum value, that is zero, at the point (0, 0, 0).  We can observe that for the default values of the parameters (first row of the table), PSOF has a better accuracy than PSOB and PSOC with respect to the minimum value. Instead, PSOB shows a better accuracy than PSOF and PSOC for both A mean P SOB and A max P SOB . Similar results are obtained for different values of the parameters D and k max . Although there is no definitive rank among the three variants of the PSO under analysis, the accuracy of the basic PSO version is never better than both the other two. Especially when focusing on A mean P SOC , it is constantly (and significantly) higher than A mean P SOF and A mean P SOB , meaning lower accuracy. Similarly, results of 100 simulation runs are summarized in Table 3 for the PSOC, PSOF, PSOB algorithms used to minimize the Griewank function with d = 5, again to evaluate the accuracy indicator. The Griewank function with d = 5 takes the minimum value, that is zero, in several different points.  Comments similar to those already made with reference to the previous table are applicable also to Table 3. PSOC accuracy is always outperformed by either PSOB or PSOF (actually, by both, unless for the minimum value in the first row when the default parameters are used, for which PSOC is better than PSOB). Therefore, also in this use case the proposed variants PSOF and PSOB should be preferred.

Efficiency evaluation results
To assess the efficiency indicator, we considered the Griewank function only and calculated the (minimum, mean and maximum) number of steps required by each of the three PSO variants to reach a predefined value a for this function. Again, 100 simulations have been performed; each run is completed either when the specified value is obtained by the execution of the PSO algorithm, or a maximum of 150 steps is exceeded. Table 4 summarizes the simulation results. The values chosen for a are the minimum, mean and maximum values obtained in Table 3 by PSOC, in correspondence of the row "Default", that is, A min P SOC = 0.0004, A mean P SOC = 0.0757 and A max P SOC = 0.2234, respectively. The values 0 in the table indicate that the initial position randomly selected by the corresponding algorithms already provide an outcome better than a. Instead, when "not found" appears, it means that a is not reached within 150 steps (maximum number of steps set in the simulations). Looking at the results in Table 4, we can immediately appreciate the significantly better efficiency shown in general by the variants PSOF and PSOB. In fact, for both a = A mean P SOC and a = A max P SOC , the number of steps requested by PSOF and PSOB is much lower than that required by PSOC, being indeed 0 for a = A max P SOC . The only exception is PSOB for a = A min P SOC , which is not surprising, since looking at Table 3, PSOB shows lower accuracy than the minimum value obtained by PSOC, when default parameters are used (which is 0.0004).

Evaluation in a practical case study: optimization of electrical grids
In this section, we have evaluated our modified PSO algorithms when employed in electrical grid optimizations, in terms of minimizing the total power loss over the lines. The evaluation is performed in terms of the accuracy indicator, as introduced in 7.1. In particular, we focused on the IEEE-6 bus system in Figure 2, typically used as a simple case study to deal with optimization in electrical grids. A survey on the general optimal power flow problem (i.e., the problem to optimize electrical grids) can be found in [13] and [39]. In [38], the authors have reported the results of the optimization of the IEEE-6 The optimization has been implemented through minimizing the total power loss over the lines of the electrical grid, expressed as follows: where N is the total number of bus (nodes), V i is the voltage magnitude at bus i, δ i is the voltage angle at bus i, g i,j is the conductance of the line connecting busses i and j. For optimization purposes, seven control variables have been used in these papers: P 6 active power of bus 6, V 1 and V 6 voltages of busses 1 and 6, Q 3 and Q 4 reactive power of busses 3 and 4, T 24 and T 35 tap changers of transformers over lines connecting busses 2,4 and 3,5. We have instantiated our PSOF and PSOB solutions to this problem, adopting the same control variables, which correspond to the search variables of our algorithms. For the sake of comparison with the previously analysed optimization algorithms, the same range of values as in [38] have been assigned to the (both control and state) variables of our algorithms; for brevity, they are omitted here.
In Table 5, we report the results obtained in [38] for the GA, PSO, ABA and DE algorithms, with the addition of the results that we have obtained using our modified algorithms PSOB and PSOF. These results (expressed in terms of min, mean and maximum total power loss) are obtained with k max = 200, D = 30, running 30 simulation experiments. From this table, it can be observed that both PSOB and PSOF show the best minimum value for the total power loss. Moreover, PSOB is the best also in terms of the average and maximum values, so ranking as the most accurate power flow optimization algorithm among the 6 considered alternatives for this scenario. Although dependent on the specific setting adopted in the set up of this case study, the observed results are encouraging to investigate more deeply the suitability of our proposed solutions to support power flow optimizations, which we plan as future work. For completeness on the presented case study, in Table 6 we report the optimal configuration for the control variables that yields the minimum value of the total power loss obtained by the PSOB and the PSOF algorithms.

Conclusions
In this paper, the problem of performing non-linear optimization has been treated by means of the PSO algorithm. Moving from the original formulation of the PSO algorithm, improvements have been proposed on the sampling of the initial population, the setting of the algorithm's parameters and the method for moving the control variables in the search space. Well consolidated techniques have been adopted to cover the critical points of the algorithm we worked on, namely the fuzzy logics and the Bayesian theory. A simulation study has been carried on to show the benefits of the new proposed PSO solutions with respect to the classical PSO formulation, using well-known testing functions like the Rosenbrock function and the Griewank function. Moreover, a case study in the electrical field has been worked out, to show results on the suitability of our proposed solutions to support optimization needs in this context, in comparisons with other already adopted alternatives. The obtained results are encouraging, and we expect that the new features we introduced into the PSO algorithm are actually relevant in a variety of application contexts, especially those that are sensitive to the input sampling and the coverage of the search space. Several research extensions are foreseen. Further simulations devoted to improve the understanding of the sensitivity of the three compared solutions to the algorithms parameters would be undoubtedly a valuable direction to explore. Other refinements would be also interesting, such as focus on the setting of variances and introducing correlation factors in the Bayesian approach, as well as setting of expert-based choices in the fuzzy logics strategy. Of course, addressing more deep investigations on the usage of the proposed solutions in specific application contexts, such as the electrical power system already tackled in this paper, is another planned research line. Finally, practical support to the the selection of the most suited algorithm to solve optimization aspects would be also very helpful by exploring the characterization of the PSO family with respect to typical needs raised in optimizations problems.

Acknowledgements
This work has been partially supported by the European Project SmartC2Net (n. ICT-318023) and the TENACE PRIN Project (n. 20103P34XC) funded by the Italian Ministry of Education, University and Research.

A Appendix
We use equation (2) for deriving formula (10) for µ V (k) as follow .