منبع:
Bees Algorithm - Swarm Algorithms - Clever Algorithms
كد:
Input: $Problem_{size}$, $Bees_{num}$, $Sites_{num}$, $EliteSites_{num}$, $PatchSize_{init}$, $EliteBees_{num}$, $OtherBees_{num}$
Output: $Bee_{best}$
Population $\leftarrow$ InitializePopulation($Bees_{num}$, $Problem_{size}$)
While ($\neg$StopCondition())
EvaluatePopulation(Population)
$Bee_{best}$ $\leftarrow$ GetBestSolution(Population)
NextGeneration $\leftarrow \emptyset$
$Patch_{size}$ $\leftarrow$ ( $PatchSize_{init}$ $\times$ $PatchDecrease_{factor}$ )
$Sites_{best}$ $\leftarrow$ SelectBestSites(Population, $Sites_{num}$)
For ($Site_{i}$ $\in$ $Sites_{best}$)
$RecruitedBees_{num}$ $\leftarrow$ $\emptyset$
If ($i <$ $EliteSites_{num}$)
$RecruitedBees_{num}$ $\leftarrow$ $EliteBees_{num}$
Else
$RecruitedBees_{num}$ $\leftarrow$ $OtherBees_{num}$
End
Neighborhood $\leftarrow$ $\emptyset$
For ($j$ To $RecruitedBees_{num}$)
Neighborhood $\leftarrow$ CreateNeighborhoodBee($Site_{i}$, $Patch_{size}$)
End
NextGeneration $\leftarrow$ GetBestSolution(Neighborhood)
End
$RemainingBees_{num}$ $\leftarrow$ ($Bees_{num}$ - $Sites_{num}$)
For ($j$ To $RemainingBees_{num}$)
NextGeneration $\leftarrow$ CreateRandomBee()
End
Population $\leftarrow$ NextGeneration
End
Return ($Bee_{best}$)