Introduction

There are many basic laws of existence in nature, such as cooperation and competition, genetic variation, and survival of the fittest. In recent years, some scholars have been inspired by nature-based processes and applied these inspirations to the domain of computing. Genetic algorithms (GAs)1 are inspired by the process of biological evolution through selection, inheritance and mutation. Differential evolution (DE)2 is inspired by the process of cooperation and competition among individuals in a biological population. DE converges faster and more accurately in minimizing possible nonlinear and nondifferentiable continuous space function problems. The group search optimizer (GSO)3 is inspired by the process of production and consumption. GSO performs better than the other algorithms in a multimodal benchmark function with a few local minima.

Similarly, some researchers have proposed optimization algorithms inspired by animal behaviour to solve optimization problems. Kennedy4 proposed particle swarm optimization (PSO), which is inspired by the social behaviour of foraging birds, to effectively pursue the optimization of nonlinear functions in multidimensional space. To better optimize multivariable functions, Karaboga5 proposed an artificial bee colony algorithm (ABC) inspired by the honey bees social behaviour. ABC is used only to optimize 10-, 20- and 30-dimensional functions. The firefly algorithm (FA)6 utilizes the influence of light on fireflies, and the FA shows a significantly improved performance over PSO in multimodal optimization problems. The cuckoo search optimization7 mimics the parasitic behaviour of the cuckoo bird. The chicken swarm optimization (CSO)8 simulates the hierarchical structure of chicken flocks and the foraging behaviour of chickens, including roosters and hens. The dragonfly algorithm (DA)9 simulates the survival behaviour of dragonflies, including separation, parade, aggregation, predation and escape. DA lacks a width search for high-dimensional space, so it performs poorly in high-dimensional optimization problems. The DA algorithm is superior to other algorithms for optimizations in 30 dimensions. The lion optimization algorithm (LOA)10 is an algorithm inspired by a simulation of lions’ behaviours of solitude and cooperation. The LOA outperforms other optimization algorithms in only 30 dimensions of the benchmark function, and it tends to fall into a local optimum prematurely in high-dimensional problems. Inspired by the process of finding the shortest distance between ants’ food and their residence, Dorigo11 proposed the ant colony optimization algorithm (ACO). The whale optimization algorithm (WAO)12 simulates the hunting of prey, prey envelopment, and the bubble net hunting behaviour of humpback whales. There are also some nature-inspired and animal-inspired algorithms that are extensively used by researchers in various fields, such as path design13,14,15, control autoregressive models16,17,18,19 and urban development20,21.

According to the no free lunch theorem, every optimization problem cannot be solved by only one algorithm. Therefore, it is necessary to develop or improve additional metaheuristic optimization algorithms to address different types of optimization problems. A high-dimensional optimization problem is a typical representative of an optimization problem. With the continuous development of blockchain technology22,23,24,25, big data26,27 and practical nanotechnology28,29,30, the dimensionality of optimization problems is increasing dramatically. Li31 proposed a dimension dynamic sine cosine algorithm (DDSCA). In the DDSCA, the solution of each dimension is obtained first, and then the greedy algorithm is used to combine the solution of other dimensions and form a new solution. Yang32 introduced an elitist oriented particle swarm optimization algorithm (EDPSO), which uses historical information about particles to efficiently solve high-dimensional optimization problems. Chen33 designed an Efficient hierarchical surrogate assisted differential evolution (EHSDE), which balances exploration and development in a high-dimensional optimized space using a hierarchical approach. On the one hand, the above algorithms cannot effectively balance between depth searches and breadth searches in high-dimensional spaces. On the other hand, these algorithms cannot jump to the local optimum in the initial stages of the search, or are unable to search for a preferable value after jumping out of the local optimum. So, it is also crucial to develop a new optimization algorithm to solve high-dimensional optimization problems as effectively as possible.

This paper introduces a new optimization algorithm, which is named hermit crab optimization algorithm (HCOA), to solve high-dimensional optimization problems. It is inspired by the distinctive behaviour of hermit crabs in searching for, and changing to, appropriate houses to survive during their continuous growth. More specifically, the main research contributions of this paper are as follows:

  1. 1.

    Optimal search: The hermit crabs search in the vicinity of the alpha hermit crab of the entire population. In adherence to this rule, HCAO guarantees the accuracy of the search.

  2. 2.

    Historical path search: The hermit crabs search around the historical path of the population’s alpha hermit crabs. With this strategy, the HCOA balances between breadth and depth searches in a high-dimensional space, and helps the HCOA to jump out of the local optimum.

The remaining sections of the manuscript are organized as follows. “Materials and methods” elaborates on the proposed algorithm in detail. “Results” shows the details and results of the simulation experiments. “Conclusions” concludes this work and presents future works.

Materials and methods

Behaviour of hermit crab

Hermit crabs are arthropods similar to shrimp and crabs that live mainly in coastal areas. They are also omnivorous and are known as the “scavengers” of the seashore, eating everything from algae and food scraps to parasites, and they play an essential role in the ecological balance. However, hermit crabs rely heavily on their houses for survival, and years of research have shown that proper houses help hermit crabs survive, feed and resist predators, and if hermit crabs lose their houses, the soft tissue structures of their abdomens become exposed and unprotected. Hermit crabs may die if they live in unsuitable houses or have no houses to live in for a long time. As they grow, hermit crabs are continuously searching and acquiring houses that are appropriate for their survival. Its population behaviour of searching for, and changing to, new houses is a unique natural process. The hermit crabs search for a proper house to survive in their surrounding location or host an aged house that other crabs have shed. If the hermit crab is unable to find a suitable new house, it must return to its original house.

Hermit crab optimization algorithm

Inspired by the constant house-searching and house-changing behaviour of hermit crabs, we idealize the characteristics of hermit crabs’ behaviours. Relating the process of hermit crabs’ house searching and house changing to the objective function to be optimized, we are able to design a hermit crab-inspired optimization algorithm (the HCOA). In hermit crab populations, there are many factors involved in selecting the right house, including size, species and colour. In the HCOA, for simplicity, we assume that each hermit crab has no mass or volume, and represents only a point in space, and each point is a solution to a certain problem. The fitness of each hermit crab for a new house is associated with the optimal value of the target function, and an adaptation degree analogy is associated with the house. Because of the large and variable distribution of crustaceans in coastal areas, we randomly generate a large number of houses in the HCOA. Based on the behaviour of the hermit crabs, we use two house-searching and house-changing rules, which are denoted as the optimal search and the historical path search. These two strategies can help the HCOA balance the breadth searches and width searches in a high-dimensional search space, and increase the possibility of jumping out of a local optimum. The search diagram for the HCOA is shown in Fig. 1. At the same time, the basic steps of the HCOA are summarized using the pseudocode displayed in algorithm 1, and the HCOA flowchart is displayed in Fig. 2. The two the HCOA search strategies create only linear transformations in the time complexity. Therefore, the time complexity of an the HCOA is still linear complexity O(n).

Figure 1
figure 1

The search diagram for the HCOA.

Figure 2
figure 2

The flowchart of the HCOA.

figure a

Optimal search

The alpha hermit crab of the crab population gains more valuable survival experience than the other hermit crabs, and it is more experienced in finding a new house. Therefore, other hermit crabs are more likely to find more appropriate houses in the vicinity of the population’s alpha hermit crab. If other hermit crabs find a more appropriate house than the one it currently has, it changes houses. By comparison, if it does not find a more suitable house, it continues to use the original house in order to survive. In the HCOA, after each calculation of the function fitness, the fitness of all the hermit crabs is ranked. The hermit crab with the best fitness is selected for comparison with the alpha hermit crab. If a hermit crab with the best fitness is better, then it is more experienced in survival than the existing alpha hermit crab. The optimal search process is summarized in the pseudocode shown in Algorithm 2. With the guidance of this rule, the HCOA can accurately find the optimal solution.

$$\begin{aligned} \alpha &= (Alpha^{t}+Pbest^{t})/2 \nonumber \\ \delta &= \Vert Alpha^{t}-Pbest^{t}\Vert \nonumber \\ Pcandidate^{t+1}(\gamma )&= GD(\alpha ,\delta ) \end{aligned}$$
(1)

In the (t)th generation, the alpha hermit crab finds the most appropriate house position \(Alpha^t\). \(Pbest^{t}(\gamma )\) means that each hermit crab in the population finds the (t)th most appropriate house’s position, and \(Pcandidate^{t+1}(\gamma )\) is the \((t + 1)\)th candidate house’s position. \(GD(\alpha ,\delta )\) is a Gaussian distribution with mean \(\alpha\) and standard deviation \(\delta\), which is used to simulate the distribution of the houses.

figure b

Historical path search

The alpha hermit crab from the entire crab population is replaced when other hermit crabs have a more appropriate house than the alpha hermit crab. However, each generation of alpha hermit crabs in the population sheds its original house when it seeks a more appropriate house. The original house remains in place, while the alpha hermit crab replaces it with a more appropriate house. These original houses may be used by other hermit crabs. It is also possible that more appropriate houses exist around these houses for other hermit crabs to live in. The houses abandoned by alpha hermit crabs change with the environment and hermit crab behaviours. On the one hand, they may simply disappear; on the other hand, they may appear near their original location. Therefore, other hermit crabs want to find a more suitable house. In the HCOA, other hermit crabs search around the historical path of the five houses where the alpha hermit crab has recently left, because there may be a better chance of finding a house that suits them. A historical path means that the HCOA has deeper search spaces. A hermit crab may find a better house nearby on the five historical paths and attain a house replacement. This search process increases the HCOA width search in high-dimensional space. If a more suitable shell is not found, the hermit crab returns to its original shell. The historical path search process can be summarized in the pseudocode shown in Algorithm 3.

$$\begin{aligned} \beta&= (Pbest^{t}(\gamma )+Ghistory^{t}(\omega ))/2 \nonumber \\ \lambda&= \Vert Pbest^{t}((\gamma ))-Ghistory^{t}(\omega )\Vert \nonumber \\ Candiate\_pbest^{t+1}(\gamma ,\omega )&= GD(\beta ,\lambda ) \end{aligned}$$
(2)
$$\begin{aligned} Pbest^{t+1}(\gamma )&= \left\{ \begin{aligned}&Candidate\_pbest^{t+1}(\gamma , \omega ),if(\text {F(}Pbest^{t})>F(Candidate\_pbest^{t+1}(\gamma , \omega )) \\&Pbest^{t}(\gamma ),else \\ \end{aligned} \right. \end{aligned}$$
(3)

In the (t)th generation, the best personal position for each hermit crab is \(Pbest^{t}(\gamma )\). By the definition of the HCOA, \(\omega =(1, 5)\) is the alpha hermit crab in most recent history to shed the first few houses, and the population’s current alpha hermit crabs keep the houses it recently replaced. We use \(Ghistory^{t}(\omega )\) to record the population’s alpha hermit crabs houses’ historical position. \(Candiate\_pbest^{t+1}(\gamma , \omega )\) means hermit crabs search around the \(\omega\) houses’ positions. \(GD(\beta ,\lambda )\) is a Gaussian distribution with mean \(\beta\) and standard \(\lambda\), which is used to simulate the distribution of houses. F is the indicator test function.

figure c

Results

Experimental methods

To reflect the comprehensive performance of the HCOA, we choose the CEC2017 benchmark function34. The CEC2017 benchmark function includes a unimodal function (\(f1-f2\)), simple multipeak function (\(f3-f9\)), hybrid function (\(f10-f19\)) and composition function (\(f20-f29\)). The test dimensions are 10, 30, 50 and 100. The highest dimension of 100 recommended in the CEC2017 benchmark function is chosen to show the reasonableness of the experiment. Five well-known parameter-free mate-heuristics, BBPSO35, PBBPSO36, DLSBBPSO37, TBBPSO38 and ETBBPSO39 are used as comparison groups. To reduce the impact of chance errors on the experimental results, all the trials are attempted 37 times. All the algorithms have a population size of 100 and a maximum number of iterations of 1.00E+4 and use the same settings as in the original paper.

Experimental results

To better analyse the experimental results, GT is used to measure the performance of each algorithm. In this work, GT is defined as \(\left\| Gobaloptimum-theoreticaloptimum \right\|\).

Specific numerical results, including the mean value (MV) and standard deviation (Std) of 37 independent runs, are displayed in Tables 1 and 2. The Friedman statistic test is used to analyse the results. The rank results (RRs) are also shown in Tables 1 and 2. The average rank point of the HCOA is 1.4828, which is 56.121% better than the second ranked algorithm BBPSO. the HCOA provides a solution to high-dimensional optimization problems. The average ranks are shown at the bottom of Table 2. The results of the first ranking of the HCOA out of 29 benchmarking functions in CEC2017 are in Table 3, and the remaining ranking results are in Table 4.

Table 1 Experimental results, of the HCOA, DLSBBPSO, TBBPSO, BBPSO, ETBBPSO and PBBPSO for \(f_1 - f_{15}\).
Table 2 Experimental results, of the HCOA ,DLSBBPSO, TBBPSO, BBPSO, ETBBPSO and PBBPSO for \(f_{16} - f_{29}\). The mean ranking points are at the end of the table.
Table 3 Result analysis of the HCOA, Part 1.
Table 4 Result analysis of the HCOA, Part 1.
Figure 3
figure 3

Convergence diagram, \(f_{1}\), (a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 4
figure 4

Convergence diagram, \(f_{2}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 5
figure 5

Convergence diagram, \(f_{3}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 6
figure 6

Convergence diagram, \(f_{4}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 7
figure 7

Convergence diagram, \(f_{5}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 8
figure 8

Convergence diagram, \(f_{6}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 9
figure 9

Convergence diagram, \(f_{7}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 10
figure 10

Convergence diagram, \(f_{8}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 11
figure 11

Convergence diagram, \(f_{9}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 12
figure 12

Convergence diagram, \(f_{10}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

To demonstrate the convergence performance of the HCOA, the GT in different iterations for the HCOA, BBPSO, PBBPSO, DLSBBPSO, TBBPSO and ETBBPSO are also shown in Figs. 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 and 31. The scale on the vertical axis represents the value of CE. The horizontal coordinate denotes the number of generations, and the vertical coordinate denotes the value of GT.

Figure 13
figure 13

Convergence diagram, \(f_{11}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 14
figure 14

Convergence diagram, \(f_{12}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 15
figure 15

Convergence diagram, \(f_{13}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 16
figure 16

Convergence diagram, \(f_{14}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 17
figure 17

Convergence diagram, \(f_{15}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 18
figure 18

Convergence diagram, \(f_{16}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 19
figure 19

Convergence diagram, \(f_{17}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 20
figure 20

Convergence diagram, \(f_{18}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

After comparing and counting, HCAO ranks first in the number of functions among the 29 benchmarked functions in CEC2017 with 23, ranked second, third, and fifth with two each, and none ranked fourth and sixth. And the ranking shows that HCAO has a better performance at simple multipeak function (f3–f9), hybrid function (f10–f19), and composition function than other algorithms.

According to Figs. 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 and 31, except for f1, f8, f9, f13, f19, f24 and f25, the HCOA is significantly better than the other algorithms in terms of convergence speed and accuracy. The time complexity of the five optimization algorithms for the HCOA and the control group are linearly transformed by addition and subtraction without changing the order of magnitude of the time complexity. Therefore, the time complexity of the HCOA and the other optimization algorithms are the same O(n).

Figure 21
figure 21

Convergence diagram, \(f_{19}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 22
figure 22

Convergence diagram, \(f_{20}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 23
figure 23

Convergence diagram, \(f_{21}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 24
figure 24

Convergence diagram, \(f_{22}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 25
figure 25

Convergence diagram, \(f_{23}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 26
figure 26

Convergence diagram, \(f_{24}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 27
figure 27

Convergence diagram, \(f_{25}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Comparison with the new parameter-free algorithm

To further prove the superiority of the HCOA algorithm in high-dimensional optimization problems, we choose the state-of-the-art method, the BPSO-CM40 algorithm, as the control group, to conduct experiments on the highest dimension of 100 recommended by CEC2017. To minimize the effect of chance errors on the experimental results, all the trials are attempted 37 times with a population size of 100 and a maximum number of iterations of 1.00E+4. In addition, the overall effectiveness (OE) of the HCOA and BPSO-CM is computed by the results in Tables 5 and 6. The OE is calculated by Eq. (4).

$$\begin{aligned} OE=\frac{N-L}{N}*100\% \end{aligned}$$
(4)

where N is the number of benchmark functions, and L represents the target algorithm loss in the competition. The OE results are shown in Table 5. The results indicate that the HCOA has the best performance.

Figure 28
figure 28

Convergence diagram, \(f_{26}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 29
figure 29

Convergence diagram, \(f_{27}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 30
figure 30

Convergence diagram, \(f_{28}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Figure 31
figure 31

Convergence diagram, \(f_{29}\),(a) generation 0-6*10E3, (b) iteration 6*10E3-10*E4.

Table 5 Experimental Results of the HCOA and BPSO-CM for \(f_1 - f_{15}\).
Table 6 Experimental Results of the HCOA and BPSO-CM for \(f_16 - f_{29}\). The OE are at the end of the table.

It can be seen from Tables 5 and 6 that the HCOA performs better than BPSO-CM in 20 functions. Meanwhile, the OE of the HCOA reaches 68.97%, which is 37.94% higher than the 31.03% of BPSO-CM. The experimental results show that the HCOA can provide a high precision solution for single objective high-dimensional optimization problems.

Conclusions

A novel hermit crab optimization algorithm (the HCOA) that produces high-precision results for high-dimensional optimization problems is proposed in this paper. the HCOA achieves high-accuracy resolution of single-objective optimization problems by modelling the behaviour of hermit crab populations. The optimal search and the historical path search are used in the HCOA to balance the depth search and breadth search. The cooperation of the optimal search and historical path search achieves high-precision optimization in high-dimensional spaces. Moreover, both the optimal search and the historical path search have linear computation times, which means that the time complexity of the HCOA is O(n).

In the experimental part of this paper, the CEC2017 benchmark functions are used. In a total of 29 test functions, the HCOA scores 23 firsts. Compared with the state-of-the-art BBPSO-based method, BPSO-CM and the HCOA win 20 of 29 tests. All the experimental results demonstrate that the HCOA generates highly accurate and robust results for high-dimensional optimization problems.

However, the HCOA cannot be applied to multiobjective optimization problems and single-objective noncontinuous optimization problems. Furthermore, in the unimodal functions of CEC2017, the performance of the HCOA is inferior to that of BPSO-CM. Therefore, one of the main future research directions is applying the HCOA to multiobjective optimization problems. Additionally, due to the linear time complexity, combining the HCOA with other famous evolutionary strategies, such as SE and PSO, to achieve higher accuracy and greater robustness is another solid option.