1 Introduction

Swarm intelligence optimization algorithm originates from the simulation of various types of biological behavior in nature and has the characteristics of simple operation, strong parallelism, good optimization performance, etc. Inspired by this idea, the genetic algorithm (GA) [1], ant colony optimization (ACO) [2, 3], particle swarm optimization (PSO) [4] are proposed and are applied widely. In recent years, some new swarm intelligence algorithms were also proposed, such as the shuffled frog leaping algorithm (SFLA) [5], artificial bee colony optimization (ABC) [6], artificial fish swarm algorithm (AFSA) [7], cuckoo search (CS) [8], monkey algorithm (MA) [9] and firefly algorithm (FA), Glowworm swarm optimization algorithm (GSO) [1013]. Swarm intelligence optimization algorithm can effectively solve some problems which traditional methods cannot solve and have shown excellent performance in many respects. So, its application scope has been greatly expanded.

The real-valued bat algorithm (BA) was proposed by Yang in 2010 [14, 15], which originated from the simulation of echolocation behavior in bats. Bats use a type of sonar called echolocation to detect prey, avoid obstacles in the dark. When searching their prey, the bats emit ultrasonic pulses. The loudness at this time is the maximum, which can help lengthen the ultrasonic propagation distance. During flight to the prey, loudness will decrease while the pulse emission will gradually increase, which can make the bat locate the prey more accurately. But the basic bat algorithm uses real number encoding method, and the application range is limited in the real number. So, the population diversity is limited, and the algorithm is easy to fall into the local optimum. In the low dimensional case, optimization performance is good [1618], engineering optimization [19, 20], multi-objective optimization [21], and hybrid bat algorithm [22], but in the high dimensional case, optimization performance cannot be satisfactory. In order to solve the high space optimization problems in the basic bat algorithm based on the idea of complex diploid encoding [2325], we present a bat algorithm based on the complex-valued encoding (CBA) in this paper. The idea of complex-valued encoding uses two parameters (i.e., the real part and the imaginary part) to represent a variable, and the real and imaginary parts can be updated in parallel. The independent variables of the objective function are determined by the modules and angles of their corresponding complex numbers. So, the diversity of population is greatly enriched, the proposed CBA algorithm expands the dimensions for denoting and the performance of the algorithm is improved and CBA can expand the scope of application and basic theory of bat algorithm to certain extent and also provides a new way for bat algorithm to solve the practical problems. This paper is organized as follows. In the Sect. 2, the basic bat algorithm is described. Section 3 gives the CBA algorithm. The simulation and comparison of this proposed algorithm are presented in Sect. 4. Finally, some remarks and conclusions are provided in Sect. 5.

2 Bat algorithm

2.1 The velocity updating and position updating of the bat

Firstly, initialize the bat population randomly. Supposed the dimension of search space is n, the position of the bat i at time t is \(x_{i}^{t}\) and the velocity is \(v_{i}^{t}\). Therefore, the position \(x_{i}^{t + 1}\) and velocity \(v_{i}^{t + 1}\) at time t + 1 are updated by the following formulas:

$$Q_{i}^{t} = Q_{\hbox{min} } + (Q_{\hbox{max} } - Q_{\hbox{min} } )\beta$$
(1)
$$v_{i}^{t + 1} = v_{i}^{t} + (x_{i}^{t} - {\text{best}})Q_{i}^{t}$$
(2)
$$x_{i}^{t + 1} = x_{i}^{t} { + }v_{i}^{t + 1}$$
(3)

where Q i represents the pulse frequency emitted by bat i at the current moment. Q max and Q min represent the maximum and minimum values of pulse frequency, respectively, β is a random number in \([0,1]\) and best represents the current global optimal solution.

Select a bat from the bat population randomly and update the corresponding position of the bat according to Eq. (4). This random walk can be understood as a process of local search, which produces a new solution by the chosen solution.

$$x_{\text{new}} (i) = x_{\text{old}} + \varepsilon A^{t}$$
(4)

where x old represents a random solution selected from the current optimal solution, A t is the loudness, ε is a random vector and its arrays are random values in \([ - 1,\;1]\).

2.2 Loudness and pulse emission

Usually, at the beginning of the search, loudness is strong and pulse emission is small. When a bat has found its prey, the loudness decreases while pulse emission gradually increases. Loudness A(i) and pulse emission r(i) are updated according to Eqs. (5) and (6):

$$r^{t + 1} (i) = r^{0} (i) \times [1 - \exp ( - \gamma t)]$$
(5)
$$A^{t + 1} (i) = \alpha A^{t} (i)$$
(6)

where α and γ are constants. For any 0 < α < 1, γ > 0, A(i) = 0 means that a bat has just found its prey and temporarily stop emitting any sound. It is not hard to find that as \(t \to \infty\), we can get \(A^{t} (i) \to 0,\,r^{t} (i) = r^{0} (i)\).

2.3 The implementation steps of bat algorithm

Generally speaking, the implementation steps of bat algorithm as follows:

  1. 1.

    Initialize the basic parameters: population size N, attenuation coefficient of loudness α, increasing coefficient of pulse emission γ, the maximum loudness A 0 and maximum pulse emission r 0 and the maximum number of iterations \(iterMax\);

  2. 2.

    Define pulse frequency \(Q_{i} \in [Q_{\hbox{min} } ,\;Q_{\hbox{max} } ]\);

  3. 3.

    Initialize the bat population x i and v;

  4. 4.

    Enter the main loop. If rand < r i , update the velocity and the current position of the bat according to Eqs. (2) and (3). Otherwise, make a random disturbance for position of the bat and go to step 5;

  5. 5.

    If (\({\text{rand}} < A_{i} ,f(x_{i} ) < f(x)\)), accept the new solutions and fly to the new position;

  6. 6.

    If \(f(x_{i} ) < f_{\hbox{min} }\), replace the best bat and adjust the loudness and pulse emission according to Eqs. (5) and (6);

  7. 7.

    Evaluate the bat population and find out the best bat and its position;

  8. 8.

    If termination condition is met (i.e., reach maximum number of iterations or satisfy the search accuracy), go to step 9; otherwise, go to step 4 and execute the next search.

  9. 9.

    Output the best fitness values and global optimal solution.

3 Complex-valued bat algorithm (CBA)

3.1 The complex-valued encoding method

Compared with the traditional real number encoding method, complex-valued encoding has many advantages. It maps one-dimensional expression space with two-dimensional coding space. For each individual bat, the real and imaginary part of complex are updated separately which leads to an inherent parallelism and increases the diversity of individuals in the intangible. So, to some extent, the CBA has higher population diversity and overcomes the disadvantage of bat algorithm, which is easy to fall into local optimum. What’s more, the application range of the bat algorithm is expanded to complex range. Because of the two-dimensional properties of complex number, CBA can express a higher dimension space.

3.1.1 Initialize the complex-valued encoding population

Based on the definition interval of the problem \([A_{k} ,B_{k} ],\;\;k = 1,2,\infty \ldots ,2M\), generate 2M complex modulus and 2M phase angle randomly.

$$\rho_{k} \in \left[ {0,\frac{{A_{k} - B_{k} }}{2}} \right],\;\;k = 1,2, \ldots ,2M$$
(7)
$$\theta_{k} \in [ - 2\pi ,2\pi ],\;\;k = 1,2, \ldots ,2M$$
(8)

According to the Eq. (9), get 2M complex number:

$$X_{Rk} + iX_{Ik} = \rho_{k} (\cos \theta_{k} + i\sin \theta_{k} ),\;\;k = 1,2, \ldots ,2M$$
(9)

Thus, we obtain 2M real parts and 2M imaginary parts, and the real and imaginary parts are updated according to the following way.

3.1.2 The updating method of CBA

  1. 1.

    Update the real parts

    $$V_{R} (t + 1) = V_{R} (t) + (X_{R} (t) - best_{1} )*Q_{1} (t)$$
    (10)
    $$X_{R} (t + 1) = X_{R} (t) + V_{R} (t + 1)$$
    (11)
  2. 2.

    Update the imaginary parts

    $$V_{I} (t + 1) = V_{I} (t) + (X_{I} (t) - {\text{best}}_{2} )*Q_{2} (t)$$
    (12)
    $$X_{I} (t + 1) = X_{I} (t) + V_{I} (t + 1)$$
    (13)

    where the \(V_{R} (t),V_{I} (t)\) are the bat speed of real and imaginary, \(X_{R} (t),X_{I} (t)\) are the bat current position of real and imaginary, best1 is the best solution of real parts and best2 is the best solution of imaginary parts. \(Q_{1} (t)\) and \(Q_{2} (t)\) are the pulse frequency.

3.1.3 The calculation method of fitness value

Because the complex domain has two parts (i.e., the real and imaginary parts), when calculating the fitness value, the complex number needs to be converted into real number firstly and then calculates its fitness value. Specific practices are as follows:1. Take complex modulus as the value of the real number:

$$\rho_{k} = \sqrt {X_{Rk}^{2} + X_{Ik}^{2} } ,k = 1,2, \ldots ,M\,$$
(14)

2. The sign is determined by phase angle:

$$X_{k} = \rho_{k} \text{sgn} \left( {\sin \left( {\frac{{X_{Ik} }}{{\rho_{k} }}} \right)} \right) + \frac{{B_{k} + A_{k} }}{2},k = 1,2, \ldots ,M$$
(15)

where X n represents the converted real variables.

3.2 CBA algorithm

The complex-valued encoding idea which can be considered as an efficient global optimization strategy is introduced to the bat algorithm. Based on the two-dimensional properties of the complex number, the real and imaginary parts of complex number are updated separately. This strategy can greatly enrich the diversity of population and enhance the global search ability of individual bat. Thus, the performance of the algorithm is improved greatly. When updating two new parameters, we also introduce the differential evolution strategy “DE/best/2/bin” [26, 27] to improve the local search ability of the algorithm. In this case, CBA can balance global and local search and cope with multimodal benchmarks. The pseudo code of CBA is as follows:

4 Simulation experiments and results analysis

4.1 Simulation platform

The proposed algorithm is implemented in MATLAB. Operating system: Windows XP; CPU: AMD Athlon (tm) II X4 640 Processor, 3.01 GHz; RAM: 3 GB; Programming language: Matlab R2012 (a).

4.2 Benchmark functions

In order to verify the effectiveness of the proposed algorithm, we select fourteen standard benchmark functions [28, 29] to detect the searching capability of the proposed algorithm. Each function has its own characteristics, and a single algorithm cannot apply to every benchmark function. Therefore, the experimental results can fully reflect the performance of the algorithm.

The benchmark functions selected can be divided into three categories (i.e., high-dimensional unimodal functions, high-dimensional multimodal functions and low-dimensional functions). They are F 1, F 2, F 3, F 4 and F 5 for category I, F 6, F 7, F 8 and F 9 for category II and F 10, F 11, F 12, F 13 and F 14 for category III. In high-dimensional functions, F 2 is a classical test function. Its global minimum is in a parabolic valley, and function values change little in the valley. So, it is very difficult to find the global minimum. There are a large number of local minima in the solution space of F 6. And in low-dimensional functions, most functions have the characteristic of strong shocks. As the global minimum of most benchmark functions is zero, in order to verify the searching capability of the algorithm effectively, we select some functions with nonzero global minimum.

4.3 Parameter setting

Generally, the choice of parameters requires some experimenting. In this paper, after a lot of experimental comparison, the parameters of the algorithm are set as follows.

In BA, the parameters are generally set as follows: Pulse frequency range is \(Q_{i} \in [0,\;2]\), the maximum loudness is A 0 = 0.5, maximum pulse emission is r 0 = 0.5, attenuation coefficient of loudness is α = 0.95, increasing coefficient of pulse emission is γ = 0.05 and population size is N = 40.

In PSO, we use linear decreasing inertia weight that is \(\omega_{\hbox{max} } = 0.9\), \(\omega_{\hbox{min} } = 0.4\), and learning factor is \(C_{1} = C_{2} = 1.4962\).

In CBA, the basic parameters are the same with BA. The range of complex modulus is \(\rho_{k} \in [0,\frac{{A_{k} - B_{k} }}{2}]\), the range of phase angle is \(\theta_{k} \in [ - 2\pi ,2\pi ]\), where \([A_{k} ,B_{k} ]\) is the range of variables.

In the tests, the maximum number of iterations of each algorithm is \(iterMax = 500\).

4.4 Comparison of experiment results

For standard benchmark functions in Table 1, the comparison of test results is shown in Tables 2, 3 and 4, while comparison of searching success rate is shown in Table 5. In this paper, the results are obtained in twenty trials. The Best, Mean, Worst and Std. represent the optimal fitness value, mean fitness value, worst fitness value and standard deviation, respectively. Bold and italicized results mean that CBA is better, while underlined results mean that other algorithm is better.

Table 1 Benchmark functions
Table 2 Simulation results for test functions \(F_{i} ,i = 1,2,3,4,5\)
Table 3 Simulation results for test functions \(F_{i} ,i = 6,7,8,9\)
Table 4 Simulation results for test functions \(F_{i} ,i = 10,11,12,13,14\)
Table 5 Comparison of the optimization success rate

Seen from Table 2, in category I, CBA can find the optimal solution for F 1 and F 3 and has a very strong robustness. For other three functions, the precision of optimal fitness value and mean fitness value is higher than those of PSO and BA. For the five functions in category I, standard deviation of CBA is less than that of PSO and BA. And this means that in the optimization of high-dimensional unimodal function, CBA has better stability. Similarly, seen from Table 3, besides F 7, for other functions in category II, CBA can find out the optimal solution, and all the standard deviation is 0. Even for F 7, CBA has a higher precision of optimization. The accuracy of CBA can be higher than that of PSO and BA for 16, 17 orders of magnitude, respectively. Overall, the optimization performance of CBA is superior to PSO and BA in the high-dimensional case.

The optimal value of functions in category III is nonzero. Seen from the results in Table 4, although in functions F 10, F 11 and F 12, both PSO and CBA can find out the optimal solution, but the mean optimal value and standard deviation of CBA are smaller than those of the PSO. Only for F 14, the optimal value of CBA is slightly worse than PSO, while standard deviation of CBA is slightly larger than the BA. But the mean optimal value of CBA is better than PSO and BA. Obviously, for functions in category III, the optimization performance of CBA is still better than PSO and BA.

For functions in three categories, Figs. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 and 14 are the fitness evolution curve, Figs. 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 and 28 are the anova tests of the global minimum and Figs. 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41 and 42 are the comparisons of optimal fitness value.

Fig. 1
figure 1

D = 30, evolution curves of fitness value for F 1

Fig. 2
figure 2

D = 30, evolution curves of fitness value for F 2

Fig. 3
figure 3

D = 30, evolution curves of fitness value for F 3

Fig. 4
figure 4

D = 30, evolution curves of fitness value for F 4

Fig. 5
figure 5

D = 30, evolution curves of fitness value for F 5

Fig. 6
figure 6

D = 30, evolution curves of fitness value for F 6

Fig. 7
figure 7

D = 30, evolution curves of fitness value for F 7

Fig. 8
figure 8

D = 30, evolution curves of fitness value for F 8

Fig. 9
figure 9

D = 30, evolution curves of fitness value for F 9

Fig. 10
figure 10

D = 2, evolution curves of fitness value for F 10

Fig. 11
figure 11

D = 2, evolution curves of fitness value for F 11

Fig. 12
figure 12

D = 4, evolution curves of fitness value for F 12

Fig. 13
figure 13

D = 4, evolution curves of fitness value for F 13

Fig. 14
figure 14

D = 4, evolution curves of fitness value for F 14

Fig. 15
figure 15

D = 30, anova tests of the global minimum for F 1

Fig. 16
figure 16

D = 30, anova tests of the global minimum for F 2

Fig. 17
figure 17

D = 30, anova tests of the global minimum for F 3

Fig. 18
figure 18

D = 30, anova tests of the global minimum for F 4

Fig. 19
figure 19

D = 30, anova tests of the global minimum for F 5

Fig. 20
figure 20

D = 30, anova tests of the global minimum for F 6

Fig. 21
figure 21

D = 30, anova tests of the global minimum for F 7

Fig. 22
figure 22

D = 30, anova tests of the global minimum for F 8

Fig. 23
figure 23

D = 30, anova tests of the global minimum for F 9

Fig. 24
figure 24

D = 2, anova tests of the global minimum for F 10

Fig. 25
figure 25

D = 2, anova tests of the global minimum for F 11

Fig. 26
figure 26

D = 4, anova tests of the global minimum for F 12

Fig. 27
figure 27

D = 4, anova tests of the global minimum for F 13

Fig. 28
figure 28

D = 4, anova tests of the global minimum for F 14

Fig. 29
figure 29

D = 30, comparison of optimal fitness value for F 1

Fig. 30
figure 30

D = 30, comparison of optimal fitness value for F 2

Fig. 31
figure 31

D = 30, comparison of optimal fitness value for F 3

Fig. 32
figure 32

D = 30, comparison of optimal fitness value for F 4

Fig. 33
figure 33

D = 30, comparison of optimal fitness value for F 5

Fig. 34
figure 34

D = 30, comparison of optimal fitness value for F 6

Fig. 35
figure 35

D = 30, comparison of optimal fitness value for F 7

Fig. 36
figure 36

D = 30, comparison of optimal fitness value for F 8

Fig. 37
figure 37

D = 30, comparison of optimal fitness value for F 9

Fig. 38
figure 38

D = 2, comparison of optimal fitness value for F 10

Fig. 39
figure 39

D = 2, comparison of optimal fitness value for F 11

Fig. 40
figure 40

D = 4, comparison of optimal fitness value for F 12

Fig. 41
figure 41

D = 4, comparison of optimal fitness value for F 13

Fig. 42
figure 42

D = 4, comparison of optimal fitness value for F 14

If the error between actual optimization and theoretical optimal value is less than 1 %, count as a successful search to the optimal value. In order to fully validate the effectiveness of the algorithm, we made a statistical analysis of the optimization success rate of each algorithm. Table 5 shows that optimization success rate of each algorithm, where dimension of functions in category I and category II is 10. Figures 43 and 44 are the anova tests of the global minimum for F 2 and F 6 in the 10 dimensional case, and Fig. 45, Fig. 46 is comparison of optimal fitness value for F 2 and F 6 in the 10 dimensional case.

Fig. 43
figure 43

D = 10, anova tests of the global minimum for F 2

Fig. 44
figure 44

D = 10, anova tests of the global minimum for F 6

Fig. 45
figure 45

D = 10, comparison of optimal fitness value for F 2

Fig. 46
figure 46

D = 10, comparison of optimal fitness value for F 6

Because the optimization success rate of PSO and BA in high-dimensional search is very low, so the dimension for functions in category I and category II is set to 10. It can be seen from Table 5, except that the optimization success rate of CBA for F 5 is 0, the optimization success rate of CBA for other functions is higher than those of PSO and BA. In particular, for functions F 6, F 7 and F 8, CBA can certainly find out the optimal solution, while optimization success rate of PSO and BA is 0 and cannot find a satisfactory result. The anova function tests of the global minimum in Figs. 43 and 44 and comparison of optimal fitness value in Fig. 45, Fig. 46 also show that the CBA has better stability and higher precision of optimization.

5 Conclusions

There are many shortcomings of bat algorithm, such as poor population diversity, low precision of optimization, easy to fall into local optimum and poor optimization performance in high-dimensional case. This paper introduces the idea of complex-valued encoding into bat algorithm and proposes a novel bat algorithm based on complex-valued encoding (CBA). With the unique two-dimensional characteristics of complex number, the proposed algorithm increases the diversity of population and improves the optimization performance of the algorithm. In this article, we tested fourteen typical benchmark functions. The results of comparison with the PSO and BA show that precision of optimization, convergence speed and robustness of CBA are all better than PSO and BA. The results of simulation test show that the proposed algorithm is effective and feasible.