Employee Bee#

(hivenas.core.abc.employee_bee)

Employee Bees’ class responsible for the exploration phase of the Artificial Bee Colony optimization.

class EmployeeBee(food_source)[source]#

Bases: ArtificialBee

Employee Bees, responsible for explorations and partial exploitation of the solution space. Employees search for food sources in the neighborhood, evaluate candidates, and compute the probabilities needed for the stochastic onlooker assignment

center_fs#

the central food souorce which can be greedy-selected by associated onlookers during exploitation. This food source holds the best fitness in the evaluated vicinity (neighbors)

Type

FoodSource

food_source#

the employee’s current food source (i.e during non-initial iterations when employees are exploiting)

Type

FoodSource

id_tracker#

the bee’s ID for logging and tracking purposes

Type

int

trials#

the number of trials/evaluations done around a given center food source. Used to abandon an area once the abandonment limit is reached

Type

int

calculate_fitness()[source]#

Calculate fitness of an EmployeeBee, given by:

\[\begin{split}fit_m (\vec{x}_{m}) = \left\{\begin{matrix}\frac{1}{{1 + f_m (\vec{x}_{m})}} & {} & {} & {{\rm if}~~{\rm{ }}f_m(\vec{x}_{m}) \ge 0}\\{1 + abs(f_m (\vec{x}_{m}))} & {} & {} & {{\rm if}~~{\rm{ }}f_m (\vec{x}_{m}) < 0}\end{matrix}\right.\end{split}\]
Returns

adjusted fitness value for the stochastic assignment operator

Return type

float

compute_probability(sum_fitness)[source]#

Calculate probability of an EmployeeBee being chosen by an OnlookerBee based on Fitess values; given by:

\[p_m = \frac{{fit_m(\vec{x_m}) }}{{\sum\limits_{m = 1}^{SN} {fit_m (\vec{x_m})} }}\]
Parameters

sum_fitness (float) – sum of all fitness values in the population, used for the roulette wheel selector

Returns

calculated probability that the current employee should be selected by an onlooker

Return type

float

evaluate(obj_interface, itr)[source]#

Evaluates sampled position and increments trial counter

Parameters
  • obj_interface (ObjectiveInterface) – the objective interface used to sample/evaluate candidates

  • itr (int) – current ABC iteration (for logging and result-saving purposes)

Returns

a Pandas Series containing the evaluation’s results (represents a row in the main results CSV file)

Return type

pandas.Series

get_center_fs()[source]#

Returns the center food source

Returns

the employee’s center food source

Return type

FoodSource

greedy_select(n_food_source, is_minimize)[source]#

Update best FoodSource to minimize or maximize fitness (elitism)

Parameters
  • n_food_source (FoodSource) – the new food source to be greedy-selected

  • is_minimize (bool) – determines whether to minimize or maximize the greedy-selection

reset(new_fs)[source]#

Resets EmployeeBee once abandonment limit is reached

Parameters

new_fs (core.abc.food_source.FoodSource) – a reintialization food source. Assigned as the center_fs

search(obj_interface)[source]#

Explore new random position (near previously-sampled position) and assigns it to the current food source

Parameters

obj_interface (ObjectiveInterface) – the given objective interface used to sample/evaluate candidates