Swarm Intelligence Series : Bacterial Foraging Optimization Algorithm

Swarm Intelligence Series : Bacterial Foraging Optimization Algorithm

·

14 min read

We will now be exploring the bacterial foraging optimization algorithm, a sophisticated way of performing the biological meta-heuristic algorithm to solve the problem at hand through the process of mimicking the foraging behavior of bacteria in nature.

Introduction

The Bacterial Foraging Optimization Algorithm is inspired by bacterial chemotaxis, a phenomenon where bacteria tend to move toward a source of nutrients while avoiding areas with high concentrations of toxins. This algorithm has gained a significant amount of popularity in recent times due to its ability to efficiently search for the optimal solutions for a given problem in a complex, high-dimensional space. The core idea of this algorithm is the concept of foraging, which is a process that involves the exploration of the solution space to find the best possible solution. The algorithm is designed to be adaptive, meaning it can adjust and tweak its search strategy based on the current state of the search process and this adaptability is crucial for dealing with dynamic and complex optimization problems.

The Bacterial Foraging Optimization algorithm operates through the process of dividing the search space into a grid where every cell in the grid represents a potential solution to the optimization problem. The algorithm then simulates the movement of the bacteria through the grid, with each bacterium following a set of rules that can determine the direction of their movement, and these rules are inspired by the bacterial chemotaxis where bacteria move towards the area of high nutrient concentration [optimal solutions] and away from the areas of high toxin concentration [suboptimal solutions].

Inspiration for the Algorithm

An Adaptive Bacterial Foraging Optimization Algorithm with Lifecycle and  Social Learning

The bacterial foraging optimization algorithm is inspired by the behavior of the Escherichia coli or E-coli bacterium, a type of bacteria that follows a specific search strategy in the process of searching for nutrients that will be beneficial for it. This foraging process is known as chemotaxis where the bacteria tend to move towards the areas with nutrients and away from the areas with toxins and this algorithm mimics this behavior by simulating the actions of the bacteria in their hunting/foraging process.

ChemoTaxis Foraging Process in the Bacterial Foraging Optimization Algorithm

The chemotaxis process in the Bacterial Foraging Optimization algorithm involves a series of steps designed to mimic the adaptive movement of bacteria in search of nutrients and this process proves to be crucial for the exploration and optimization of solutions within the algorithm's search space. Here's a focused rundown of the chemical process :

  1. Initial Step Size Determination: Every bacterium in this algorithm starts off with an initial step size for its chemotaxis process and this step size is dynamically adjusted based on the iteration number, with a decreasing trend from a starting value to an ending value. This dynamic adjustment is designed to increase the diversity of the bacterial population and prevent them from getting stuck in the local optima.

  2. Adaptive Chemotaxis: During the foraging time, each bacterium adapts its step size based on its own best position and global best position and. And, this mechanism ensures that each bacterium has a different swimming step enhancing the diversity of the bacterial population and improves the probability of finding nutrient-rich areas.

  3. Learning from Others: This algorithm incorporates a learning strategy inspired by the Particle Swarm Optimization algorithm and this learning strategy allows the bacteria to improve their positions based on the best positions of the other bacteria and the global best position.

Therefore, the chemotaxis process in this algorithm is designed to mimic the adaptive way of movement bacteria undertake providing a dynamic and effective method for exploring the search space by incorporating the adaptive step size adjustments and a learning strategy inspired by the particle swarm optimization algorithm, this algorithm enhances its diversity and adaptability traits required for the bacterial population to have an increase in their process of feature selection and classification tasks.

Convergence

The algorithm's convergence is a balancing act. It mimics bacteria's nutrient search, employing strategies like local searching and random exploration to find the optimal solution. This balance helps it avoid getting stuck on local solutions and reach the global optimum. Think of it like searching a maze - the algorithm checks nearby paths (exploitation) while occasionally taking random turns (exploration) to avoid dead ends. However, the limited communication among "bacteria" and the need for fine-tuning parameters can sometimes slow it down. Despite these quirks, the algorithm offers a unique approach to convergence, making it a valuable tool in optimization problems. This algorithm could also be initially very slow to convey due to the tendency of the bacteria to focus on the global optimum solutions initially than the local optimum solutions.

Steps taken by the Algorithm

Figure 2 | Bacterial Foraging Optimization Based on Self-Adaptive  Chemotaxis Strategy

The Bacterial foraging optimization algorithm that has been inspired by the foraging behaviour of bacterial like E-coli involves several key steps to find optimal solutions to optimization problems here are the steps it takes -

  1. Initialization: The algorithm gets started with the initialization of a population or a sample set of bacterial where each bacterium represents a potential solution in the search space and each position of the bacterium is randomly generated within the problem's search space

  2. ChemoTaxis: Every bacterium in the population performs the chemotaxis step which involves moving towards areas of high fitness [optimal solutions] and away from areas with low fitness [suboptimal solutions]. This movement is guided by a random direction and a step size. The bacteria in general tend to tumble [change direction as required] and swim [move in a determined direction] with the goal of exploring the search space to solve the problem at hand.

  3. Reproduction: After the chemotaxis step, the algorithm applies a reproduction mechanism, which mimics the "Survival of the Fittest" principle, and the fitness of each bacterium is evaluated and the healthier bacteria are more likely to reproduce, creating new bacteria with similar positions and this process helps maintain diversity in the population and prevents the premature convergence to the suboptimal solutions.

  4. Elimination and Dispersal: To adapt to the changes in the search space and to avoid getting stuck in the local optima, the algorithm includes a mechanism for eliminating poor-performing bacteria and dispersing the remaining bacterium to new positions. This step helps in exploring new areas of the search space and potentially finding better solutions.

  5. Cooperative Learning Strategy: The Bacterial Foraging Optimization algorithm incorporates a learning strategy that is cooperative in nature which allows the bacteria to learn from each other and the global best bacterium adjusting their positions based on the information retrieved so far. This cooperative learning process enhances the algorithm's cover ability to find the global optima and improves the accuracy of convergence.

  6. Iteration: Steps 2 and 5 run for a predetermined set of iterations or until the termination criterion is met like reaching the maximum number of iterations or achieving a satisfactory level of fitness.

  7. Termination: Once the termination criterion is set for the specific optimization algorithm in hand, the algorithm selects the best solution found during the search process as the potential optimal solution to the optimization problem that is being solved.

Search Parameters Used by the Bacterial Foraging Optimization Algorithm

The Bacterial foraging optimization algorithm employs several key search parameters to guide its optimization process and these parameters are crucial for controlling the behavior of the bacteria during the search process and ensuring the algorithm's effectiveness in finding optimal solutions. The key parameters used for the search process are -

  1. Number of Bacteria [Sb]: This parameter represents the total population of the bacteria or solutions used in the algorithm and a higher number of bacteria can lead to a more robust search process as it increases the amount of diversity in the population being used and enhances the overall algorithm's ability to explore the search space and the common value used is 10 in general.

  2. Number of Chemotaxis Cycles [Nc]: This parameter is used to determine the number of times every bacterium can perform the chemotaxis step that involves moving towards the area of high fitness and away from the areas of low fitness. More cycles can lead to deeper exploration of the search space but could also lead to an increase in the computation search complexity of the algorithm. The common value used for this in general is 8.

  3. Scaling Factor (σ): The scaling factor is used to adjust the step size of the bacteria during the chemotaxis process. A smaller scaling factor can lead to a larger step size allowing bacteria to explore new areas of the search space more aggressively. Conversely, a larger scaling factor results in smaller step sizes, promoting finer-grained exploration.

  4. Step Size [R]: The step size parameter is mainly used to control the distance each bacterium can move during the chemotaxis process and a larger step size can lead to a faster exploration of the search space but may also increase the risk of overshooting optimal solutions.

  5. Number of Bacteria to Reproduce [Sr]: This parameter specifies the number of bacteria that are selected for reproduction after each chemotaxis cycle, reproduction helps maintain diversity in the population and prevents premature convergence to suboptimal solutions.

  6. Reproduction Frequency: This parameter controls how often the reproduction tends to occur in the search process and a higher frequency can lead to a more dynamic population as it allows bacteria to reproduce more frequently and this adapts to changes in the search space.

  7. Maximum Number of Generations (GMMAX): This parameter sets the maximum number of iterations or generations for the algorithm to run. It acts as a termination criterion to prevent the algorithm from running indefinitely. NTS-MBFOA uses a maximum of 15,000 generations.

Variations of the Bacterial Foraging Optimization Algorithm

The Bacterial Foraging Optimization algorithm has inspired a variety of variations to enhance its performance across different optimization problems. These variations aim to address the limitations of the original algorithm, such as slow convergence and difficulty in handling high-dimensional optimization problems. Here are some notable variations of the BFO algorithm:

  1. Adaptive Chemotaxis Bacterial Foraging Optimization (ACBFO): This variation introduces adaptive chemotaxis, where the step size of the bacterium's movement is dynamically adjusted based on the bacterium's current position and the concentration of nutrients in the search space. This adaptive step size adjustment is designed to increase the diversity of the bacterial population and prevent them from getting stuck in local optima.

  2. Hybrid BFO (H-BFO): This variation combines the algorithm with other optimization algorithms, such as Particle Swarm Optimization (PSO) and Differential Evolution (DE). This hybrid approach allows H-BFO to leverage the strengths of both the algorithm and the hybrid optimization algorithms, leading to improved performance in finding optimal solutions.

  3. Adaptive BFO (ABFO): It introduces adaptive mechanisms to adjust the parameters of the BFO algorithm, such as the number of bacteria in the population, the step size, and the mutation rate. These adaptive mechanisms are designed to enhance the algorithm's ability to navigate complex, high-dimensional search spaces and find optimal solutions.

  4. Improved BFO (iBFO): It aims to improve the original bacterial foraging optimization algorithm by introducing innovative strategies for the movement, reproduction, and elimination of the bacteria taking part in the search process. These improvements are designed to enhance the algorithm's efficiency and effectiveness in solving optimization problems.

  5. Enhanced BFO (eBFO): This focuses on enhancing the bacterial foraging optimization algorithm through the introduction of new strategies for exploring the search space, such as the use of pheromone trails to guide the bacteria toward areas of high fitness. This approach is designed to improve the algorithm's ability to find optimal solutions in complex, high-dimensional spaces.

Applications of the Bacterial Foraging Optimization Algorithm in Machine Learning

The Bacterial Foraging Optimization Algorithm has found applications across various fields due to its adaptability, efficiency in navigating complex search spaces, and ability to solve non-gradient optimization problems. Its hybridization with other algorithms and its application in gradient descent search algorithms, among other uses, highlight its versatility and effectiveness in solving complex optimization problems. Some of its applications in ML are -

  1. Gradient Descent Search Algorithm: The bacterial foraging algorithm is used to enhance gradient descent search algorithms. By mimicking the chemotaxis process it takes, the algorithm can navigate through a search space in a much more effective manner potentially leading to much better solutions and the algorithm's ability to adapt to changes in the search space and its inherent ability to avoid the local optima make it a valuable tool for the gradient descent optimization algorithm.

  2. Hybridization with other algorithms: This algorithm has also been used to hybridize with other soft computing algorithms to improve their performance and by combining the strengths of the algorithm with those of other optimization algorithms, the hybrid models can achieve better optimization results. This approach allows for the exploration of new optimization strategies and the development of more effective solutions.

  3. Utilized to solve non gradient descent problems: This algorithm has been utilized to solve non gradient optimization problems and since its process mimics the behaviour of real bacteria and how they forage, it acts like a powerful tool because of its chemotaxis process which involves the movement of the bacteria towards nutrient gradients and away from the toxic environment, it is used to solve complex optimization problems where the traditional approach of using a gradient-based way of solving the problem may not prove to be as effective.

  4. Hyperparameter optimization: It is also used to optimize the hyperparameters utilized by machine learning models such as neural networks to improve their accuracy and performance as well.

Applications of the Bacterial Foraging Optimization Algorithm in Real-life Problems

This algorithm is also used to solve some crucial real-world problems that cannot be solved in a deterministic manner like -

  1. Robotics: This algorithm can be used to optimize the movements and actions of robots, enabling them to perform tasks more efficiently.

  2. Engineering Design: This algorithm can be used to optimize the design of structures, mechanical systems, and control systems by finding the best possible configuration based on a set of constraints and objectives.

  3. Finance Optimization: In finance, this algorithm can be used to optimize investment portfolios, and risk management strategies and make better financial models as well.

  4. Bioinformatics: This algorithm can be used in bioinformatics for the optimization of DNA sequences, protein structures, and genetic algorithms.

Limitations

The Bacterial foraging optimizations come with their own set of limitations that have been identified, some of them are -

  1. Slow Initial Convergence: One of the primary limitations of this algorithm is its slow initial convergence rate, especially for benchmarking functions like the sum of different powers for example this slow start is attributed to the tendency of the bacteria to focus on exploitation at a global level in the early iterations where they tend towards the globally optimal solution without first exploring the local search space effectively which can lead to premature convergence.

  2. Poor Performance in High-Dimensional Spaces: This algorithm can potentially struggle and degrade in its performance when working in a high-dimensional space or as the number of dimensions in the problem increases, making it less effective in finding optimal solutions in complex, high-dimensional search spaces and this limitation is particularly pronounced for functions with a lot of local optima causing the algorithm to get stuck in any one of them.

  3. Lack of detailed Swarm Communication: This algorithm lacks detailed swarm communication which can negatively impact its convergence capability and accuracy and in nature, the bacteria tend to communicate with each other to share information about the environment including the presence of nutrients and toxins. The lack of such communication on the algorithm can limit its ability to adapt to changes in the search space and improve its performance over time.

  4. Inadequately maintaining Diversity: The algorithm may struggle to maintain a sufficient level of diversity, especially in the early iterations and this lack of diversity can hinder the algorithm's ability to explore the search space more effectively and find optimal solutions.

  5. Constant Chemotaxis Step Size: The chemotaxis step size in the algorithm is set as a constant number in general regardless of the condition of every bacterium and this can limit the algorithm's ability to adapt to its search strategy based on the current state of the search process.

Code Implementation with MealPy

The Bacterial Foraging Optimization Algorithm can be implemented using the MealPy Library in Python in the following way -

 import numpy as np
 from mealpy import FloatVar, BFO

 def objective_function(solution):
     return np.sum(solution**2)

 problem_dict = {
     "bounds": FloatVar(lb=(-10.,) * 30, ub=(10.,) * 30, name="delta"),
     "obj_func": objective_function,
     "minmax": "min",
 }

 model = BFO.OriginalBFO(epoch=1000, pop_size=50, Ci = 0.01, Ped = 0.25, Nc = 5, Ns = 4, d_attract=0.1, w_attract=0.2, h_repels=0.1, w_repels=10)
 g_best = model.solve(problem_dict)
 print(f"Solution: {g_best.solution}, Fitness: {g_best.target.fitness}")
 print(f"Solution: {model.g_best.solution}, Fitness: {model.g_best.target.fitness}")

Conclusion

In conclusion, Bacterial Foraging Optimization stands as a remarkable example of biologically inspired optimization algorithms, showcasing the potential of nature's mechanisms to guide the development of sophisticated computational models. This article has explored the origins and biological inspiration behind the algorithm, delving into its principles and the role it plays within the broader field of metaheuristic algorithms. Through a detailed examination, we have seen how the algorithm's biological components, such as chemotaxis and reproduction, are translated into computational strategies for solving complex optimization problems.

While it offers numerous advantages, including its simplicity, adaptability, and effectiveness in solving complex optimization problems, it also presents certain limitations, such as sensitivity to parameter settings and computational resource requirements. Recognizing these challenges and opportunities is crucial for further research and development in this field.

Looking ahead, the potential for this algorithm to be used in new domains, including engineering design, menu planning, and power generation optimization, is vast. Future research directions, such as improving the efficiency of BFO, exploring its integration with other optimization algorithms, and adapting it to new optimization challenges, are promising avenues for further exploration.

The journey through Bacterial Foraging Optimization has underscored the importance of blending biological insights with computational techniques to tackle the complexities of optimization. As we continue to explore and refine this approach, it is clear that this algorithm and its variants will remain at the forefront of computational biology and optimization research, offering new perspectives and solutions to some of the most challenging problems in these fields.

Did you find this article valuable?

Support Akash Gss by becoming a sponsor. Any amount is appreciated!