| 1 Initialization |
| 2 For : |
| 3 For : |
| 4 For : |
| 5 For : |
| 6 |
| 7 Generate a tumble angle for bacterium ; |
| 8 Update the position of bacterium by (2.1); |
| 9 Recalculate the |
| 10 |
| 11 While () |
| 12 If |
| 13 ; |
| 14 Run one more step using (2.1); |
| 15 Recalculate the ; |
| 16 ; |
| 17 Else |
| 18 ; |
| 19 End if |
| 20 End while |
| 21 End for |
| 22 Update the best value achieved so far; |
| 23 End for |
| 24 Sort the population according to ; |
| 25 For : |
| 26 Bacterium () = Bacterium (); |
| 27 End For |
| 28 End for |
| 29 For : |
| 30 If ( ) |
| 31 Move Bacterium to a random position |
| 32 End if |
| 33 End for |
| 34 End for |