Black Widow Optimization (BWO) Algorithm: Mating Behaviour of Black Widow Spider for Solving Engineering Optimization Problems

1. Introduction

A new metaheuristic optimization algorithm based on mating behavior of the black widow spiders, first proposed by V. Hayyolalam and A. Pourhaji Kazem in 2020, has been used to solve different engineering and scientific problems owing to their easiness and flexibility.  The Black Widow Optimization Algorithm (BWO) is inspired by the unique mating behavior of black widow spiders. This method includes an exclusive stage, namely, cannibalism. Due to this stage, species with inappropriate fitness are omitted from the circle, thus leading to early convergence. BWO algorithm is evaluated on 51 various benchmark functions and three real-world engineering optimization problems to verify its efficiency in obtaining the optimal solutions for the problems. The BWO algorithm has various main differences compared to other methods. Providing a good performance in exploitation and exploration stages, the BWO algorithm delivers fast convergence speed and avoids local optima problem. Moreover, it should be mentioned that BWO has the ability to maintain the balance between exploitation and exploration. In other words, it is able to inspect a large area to obtain the best global solution; hence, BWO will be a good choice for solving different optimization problems with several local optima.

2. Lifecycle of Black widow spiders (Latrodectus hasselti)

Spiders are air-breathing arthropods, which have eight legs and [chelicerae] with venomous fangs. Among all orders of organisms, these species are the largest order of arachnids, and they rank seventh in total species diversity [1]. As of November 2015, taxonomists have recorded approximately 45,700 spider species and 114 families. However, dissension has been arisen within the scientists as to how all these families should be classified, more than 20 various taxonomies that have been suggested since 1900. The spider subfamily Latrodectus comprises the renowned black widows, infamous due to the excessive potency of their neurotoxic venom [2]. The subfamily has a general distribution all over the world and consists of 30 species, which have been recognized up to now. Latrodectus contains a suite of species popularly known as black widow spiders, mostly known by the red ‘‘hour-glass’’ sign upon their abdomen, as well as the Australian redback spider and the cosmopolitan brown widow [3, 4].

Figure 1: Life Cycle of Black Widow Spider

2.1. Stages of Black Widows’ Lifestyle

2.1.1. Matting Process of black widow Spider

2.1.2. Reproduction Style and Cannibalism

2.1.3. Sibling Cannibalism

2.1.1. Matting Process of black widow Spider

The Black widow is mostly nightly, and the female one remains out of sight during the day and during the night, she spins her web. Generally the female widow lives in the same site for most of her adult life. Whenever the female black widow desires to mate, she marks certain spots of her net with pheromone to attract the male. The first male entering the web renders females’ web-less attractive to rivals by web reduction. The female consumes the male during or post-mating, then she transfers eggs to her egg sock. After hatching the egg, the offspring engages in sibling cannibalism[5]. However, they stay on their mothers’ web for a short period in which they might even consume the mother. This cycle causes survival of the fit and strong individuals. The best one is the global optimum of the objective function. Figure 2(a) shows a female Black Widow on her web and also Figure 2(b) indicates a female Black Widow with her egg sac on her web.

Figure 2: (a) Female Black Widow on Her Web (b) Female Black Widow with Her Egg Sac on Her Web

2.1.2. Reproduction Style and Cannibalism

Sexual cannibalism in which a female eats a nonspecific male before, during or immediately after mating, is a fascinating behavior exhibited most commonly in invertebrates such as spiders, scorpions and praying mantis. Several female aspects such as body condition, mating status, and orientation are predicted to impact the likelihood of cannibalism, and males are expected to respond to these factors by amending their approach behaviors in ways that minimize the chance of being attacked [6]. The Black widow spider is one of the only two known animals to which the male actively plays an assistant role and helps the female in sexual cannibalism. In about two of three cases of the mating process, the female wholly eats the male while mating continues. Males who are not consumed die of their injuries in a little while after mating. It seems that the sacrifice during mating has conferred the chance of fertilization of more eggs. A female black widow may lay 4 to 10 egg sacs, each of which contains averagely around 250 eggs, though can be as few as 40 or as many as 500 [7].

2.1.3. Sibling Cannibalism

Spider lings hatch from their eggs after almost eight days and also in 11 days after being laid, they can emerge from the egg sac, although cooler temperatures can significantly slow their development so that emergence does not happen for months. They spend near a week inside the egg sac after hatching and feeding on the yolk and molting once. Black widow spider lings live together on the maternal web (Figure 3) for several days to a week, during which time sibling cannibalism is mostly observed [8]. They then leave by being carried on the wind. Several factors cause cannibalistic behavior, from among which being competition among predatory conspecifics and also the potential for the other possible food source in the lack of prey availability periods, are the most obvious ones. Both of these factors considerably increase in high-density populations. Thus cannibalism is frequently linked to demography and can have significant population-level effects. Population size can be controlled by density-dependent cannibalism and may be important in black widow spider [9].

Figure 3: Baby spiders leave their Egg Sac

One of the well-documented special cases of cannibalism is sibling consumption, but reasons and results are still not well understood. Like other types of cannibalism, sibling cannibalism can affect the population-level, but with appended implications for the general fitness of the cannibal and its parents and these implications may be different for various behavioral types to another. In some cases, consuming a sibling can raise parental fitness, and the happening of these behaviors is controlled by parents [10]. The precise outcome of unselective sibling cannibalism on parental fitness may affect the development of parental procreative strategies. The cannibalism reduces the number of surviving spider lings; however, it may raise parental fitness as well if survivors have enhanced body condition. If sibling cannibalism like other forms follows the same patterns, so the rates of cannibalism would rise with the number of siblings, especially if the possible cannibal is in bad condition. Moreover, in some cases, unfertilized spider lings eat, their mother very slowly. During some weeks, she is eaten away until she falls immobile and is consumed entirely. Spider lings generally perform very well in cases of matriphagy, with higher weights and survival rates than young that do not consume their mom [11, 12].

3. Optimization Based on Matting Process of Black Widow Spider

This BWO algorithm starts with an initial population of spiders, so that each spider represents a potential solution. These initial spiders, in pairs, try to reproduce the new generation. Female black widow eats the male during or after mating. Then she carries stored sperms in her sperm thecae and releases them into egg sacs. As early as 11 days after being laid, spider lings come out of the egg sacs. They cohabit on the maternal web for several days to a week, during which time sibling cannibalism is observed. They then leave by being carried on the wind.

Steps in BWO Algorithm

3.1.Initial population

3.2. Procreate

3.3. Cannibalism

3.4. Mutation

3.5. Convergence

3.6. Parameter setting

3.1. Initial population

In order to solve an optimization problem, the values of problem variables must form as an appropriate structure for the solution of the current issue. In GA and PSO terminologies, this structure is called ‘‘Chromosome’’ and ‘‘Particle position’’, respectively, but here in black widow optimization algorithm (BWO) it is called ‘‘widow’’. In Black widow Optimization Algorithm (BWO), the potential solution to each problem has been considered as a Black widow spider. Each Black widow spider shows the values of the problem variables. In this paper, in order to solve benchmark functions, the structure should be considered as an array. In a Nvar dimensional optimization problem, a widow is an array of 1 × Nvar representing the solution of the problem. The fitness of widow is obtained by evaluation of fitness function f at a widow,

To start the optimization algorithm, a candidate widow matrix of size Npop × Nvar is generated with an initial population of spiders. Then pairs of parents randomly are selected to perform the procreating step by mating, in which the male black widow is eaten by the female during or after that.

3.2. Procreate

Since the pairs are independent of each other, they start to mate in order to reproduce the new generation, in parallel, as well in nature, each pair mate in its web, separately from the others. In real-world, approximately 1000 eggs are produced in each mating, but finally, some of the spider babies are survived, which are stronger. Now, here in this algorithm in order to reproduce, an array called alpha should also be created as long as widow array with random numbers containing, then offspring is produced by using 𝛼 with the following equation, in which 𝑥1 and 𝑥2 are parents, 𝑦1 and 𝑦2 are offspring.

This process is repeated for Nvar/2 times, while randomly selected numbers should not be duplicated. Finally, the children and mom are added to an array and sorted by their fitness value, now according to cannibalism rating; some of the best individuals are added to the newly generated population. These steps apply to all pairs.

3.3. Cannibalism

Here we have three kinds of cannibalism. The first one is sexual cannibalism, in which the female black widow eats her husband during or after mating. In this algorithm, we could recognize female and male by their fitness values. Another kind is sibling cannibalism in which the strong spider lings eat their weaker siblings. In this algorithm, we set a cannibalism rating (CR) according to which the number of survivors is determined. In some cases, the third kind of cannibalism is often observed in which the baby spiders eat their mother. We use the fitness value to determine strong or weak spider lings.

3.4. Mutation

In this stage, we randomly select Mutepop number of individuals form population. As Figure 4 illustrates, each of the chosen solutions randomly exchanges two elements in the array. Mutepop is calculated by the mutation rate.

Figure 4: Mutation

3.5. Convergence

Like other evolutionary algorithms, three stop conditions can be considered: (a) a predefined number of iterations. (B) Observance of no change in the fitness value of the best widow for several iterations. (C) Reaching to the specified level of accuracy. In the next section, BWO will be applied to some benchmark optimization problems. As optimal solutions are known for benchmark functions in advanced, so reaching a specified level of accuracy is considered as determination of accuracy level for the experimental algorithms.

3.6. Parameter setting

In the proposed BWO algorithm, there are some parameters which are essential for obtaining better results. These parameters include procreating rate (PP), cannibalism rate (CR), and mutation rate (PM). The parameters should be appropriately adjusted to improve the successfulness of the algorithm in finding superior solutions. The better tuning the amount of the parameters, the higher the chance for jumping out of any local optimum and higher ability to explore the search space globally as well. Hence, the right amount of parameters can ensure the controlling of the balance between exploitation and exploration stages. The BWO algorithm equipped with three vital controlling parameters, including PP, CR, and PM.

  • PP is the percentage of procreating, which determines how many individuals should be participated in procreate. This parameter by controlling the production of various offspring provides further diversification and gives more opportunity to explore the search space more precisely.
  • CR is the controlling parameter of the cannibalism operator, which omits the inappropriate individuals from the population. Adjusting the proper value for this parameter can ensure high performance for the exploitation stage by transferring the search agents from local to the global stage and vice versa.
  • PM is the percentage of the individuals participating in mutation. Right value for this parameter can ensure the balance between exploitation and exploration stage. This parameter can control the transferring of the search agents from the global stage to local and propel them toward the best solution as well.

4. Pseudo Code of BWO Algorithm

5. Flowchart of BWO Algorithm

Figure 5: Flowchart of BWO Algorithm

6. Application and Merits of BWO Algorithm

The proposed BWO algorithm can be applied to various kind of engineering optimization problems such as,

  • Feature selection [13],
  • Information retrieval [14],
  • Text clustering [15],
  • Hybrid clustering analysis [16],
  • Text document clustering analysis [17],
  • Document clustering [18],
  • Clustering techniques [19],
  • Cloud computing optimization in IoT [20], and so forth.
Figure 6: Applications of BWO Algorithm
  • Randomly selecting the parents for procreate step ensures the exploration of the search domain.
  • Producing numerous offspring in procreate step put emphasis on the exploration of the search domain as well.
  • The procreate step helps the BWO algorithm to overcome the local optima trap.
  • Escaping from local optima is remarkable in the BWO algorithm since it adopts numerous search agents to estimate the global optima.
  • Cannibalism step by omitting the improper solutions aids the BWO algorithm to move toward the best solution very fast.
  • The cannibalism step guarantees the high performance for the exploitation, which ensures the fast convergence of the BWO algorithm.
  • The mutation step confirms the balance between the exploitation and exploration stages.


[1]        M. Andrade and E. Banta, “Value of male remating and functional sterility in redback spiders”, Animal Behaviour, vol. 63, no. 5, pp. 857-870, 2002.

[2]        A. Luque-Chang, E. Cuevas, F. Fausto, D. Zaldívar and M. Pérez, “Social Spider Optimization Algorithm: Modifications, Applications, and Perspectives”, Mathematical Problems in Engineering, vol. 2018, pp. 1-29, 2018.

[3]        E. Cuevas, M. Cienfuegos, D. Zaldívar and M. Pérez-Cisneros, “A swarm optimization algorithm inspired in the behavior of the social-spider”, Expert Systems with Applications, vol. 40, no. 16, pp. 6374-6384, 2013.

[4]        J. Bansal, H. Sharma, S. Jadon and M. Clerc, “Spider Monkey Optimization algorithm for numerical optimization”, Memetic Computing, vol. 6, no. 1, pp. 31-47, 2014.

[5]        M. Elgar and D. Nash, “Sexual cannibalism in the garden spider Araneus diadematus”, Animal Behaviour, vol. 36, no. 5, pp. 1511-1517, 1988.

[6]        L. Forster, “The Stereotyped Behavior of Sexual Cannibalism in Latrodectus-Hasselti Thorell (Araneae, Theridiidae), the Australian Redback Spider”, Australian Journal of Zoology, vol. 40, no. 1, p. 1, 1992.

[7]        B. Baur, “Population regulation in the land snail Arianta arbustorum: density effects on adult size, clutch size and incidence of egg cannibalism”, Oecologia, vol. 77, no. 3, pp. 390-394, 1988.

[8]        L. Forster, “The Stereotyped Behavior of Sexual Cannibalism in Latrodectus-Hasselti Thorell (Araneae, Theridiidae), the Australian Redback Spider”, Australian Journal of Zoology, vol. 40, no. 1, p. 1, 1992.

[9]        M. Downes, “Fecundity and fertility in Latrodectus hasselti (Araneae: Theridiidae)”, Austral Ecology, vol. 10, no. 3, pp. 261-264, 1985.

[10]      V. Seligy, “Postembryonic development of the spider Enoplognatha ovata (Clerck) (Araneae: Theridiidae)”, Zoological Journal of the Linnean Society, vol. 50, no. 1, pp. 21-31, 1971.

[11]      Y. Liu, A. Maas and D. Waloszek, “Early development of the anterior body region of the grey widow spider Latrodectus geometricus Koch, 1841 (Theridiidae, Araneae)”, Arthropod Structure & Development, vol. 38, no. 5, pp. 401-416, 2009.

[12]      S. Mirjalili, S. Saremi and S. Mirjalili, “Designing evolutionary feedforward neural networks using social spider optimization algorithm”, Neural Computing and Applications, vol. 26, no. 8, pp. 1919-1928, 2015.

[13]      L. Abualigah, “Feature Selection and Enhanced Krill Herd Algorithm for Text Document Clustering”, Studies in Computational Intelligence, 2019.

[14]      L. Qasim Abualigah and E. S.Hanandeh, “Applying Genetic Algorithms to Information Retrieval Using Vector Space Model”, International Journal of Computer Science, Engineering and Applications, vol. 5, no. 1, pp. 19-28, 2015.

[15]      L. Abualigah and A. Khader, “Unsupervised text feature selection technique based on hybrid particle swarm optimization algorithm with genetic operators for the text clustering”, The Journal of Supercomputing, vol. 73, no. 11, pp. 4773-4795, 2017.

[16]      L. Abualigah, A. Khader and E. Hanandeh, “A combination of objective functions and hybrid Krill herd algorithm for text document clustering analysis”, Engineering Applications of Artificial Intelligence, vol. 73, pp. 111-125, 2018.

[17]      L. Abualigah, A. Khader and E. Hanandeh, “A new feature selection method to improve the document clustering using particle swarm optimization algorithm”, Journal of Computational Science, vol. 25, pp. 456-466, 2018.

[18]      L. Abualigah and A. Khader, “Unsupervised text feature selection technique based on hybrid particle swarm optimization algorithm with genetic operators for the text clustering”, The Journal of Supercomputing, vol. 73, no. 11, pp. 4773-4795, 2017.

[19]      V. Hayyolalam and A. Pourhaji Kazem, “A systematic literature review on QoS-aware service composition and selection in cloud environment”, Journal of Network and Computer Applications, vol. 110, pp. 52-74, 2018.

[20]      B. Pourghebleh and V. Hayyolalam, “A comprehensive and systematic review of the load balancing mechanisms in the Internet of Things”, Cluster Computing, 2019.

Leave a Reply

%d bloggers like this: