diff --git a/artificial_bee_colony/src/bee.rs b/artificial_bee_colony/src/bee.rs index 082f50a..38bba2a 100644 --- a/artificial_bee_colony/src/bee.rs +++ b/artificial_bee_colony/src/bee.rs @@ -4,7 +4,7 @@ use crate::food::FoodSource; pub enum Bee {} impl Bee { - pub fn worker_bee( + pub fn employed_bee( food_sources: &mut [FoodSource], index: usize, decision_variable_count: usize, @@ -31,7 +31,7 @@ impl Bee { } let mut candidate_coordinates = food_sources[index].coordinates.clone(); candidate_coordinates[selected_coordinate_index] = candidate_one_index; - let candidate = FoodSource::get(candidate_coordinates); + let candidate = FoodSource::new(candidate_coordinates); food_sources[index].try_counter += 1; if candidate.fitness > food_sources[index].fitness { food_sources[index] = candidate; @@ -49,7 +49,7 @@ impl Bee { ) { let fitness_for_index = food_sources[index].fitness; if fitness_for_index / total_fitness <= rand::thread_rng().gen_range(0.0..=1.0) { - Self::worker_bee( + Self::employed_bee( food_sources, index, decision_variable_count, @@ -74,7 +74,7 @@ impl Bee { + rand::thread_rng().gen_range(0.0..=1.0) * (upper_bound - lower_bound); coordinates_for_new.push(random); } - let new_food_source = FoodSource::get(coordinates_for_new); + let new_food_source = FoodSource::new(coordinates_for_new); food_sources[most_tried_index] = new_food_source; } } diff --git a/artificial_bee_colony/src/food.rs b/artificial_bee_colony/src/food.rs index 3693ab5..deba108 100644 --- a/artificial_bee_colony/src/food.rs +++ b/artificial_bee_colony/src/food.rs @@ -11,7 +11,7 @@ pub struct FoodSource { } impl FoodSource { - pub fn get(coordinates: Vec) -> Self { + pub fn new(coordinates: Vec) -> Self { let mut food_source = FoodSource { fitness: 0.0, function_calculation: 0.0, @@ -55,7 +55,7 @@ impl FoodSource { let random = rand::thread_rng().gen_range(lower_bound..=upper_bound); coordinates.push(random); } - food_sources.push(FoodSource::get(coordinates)); + food_sources.push(FoodSource::new(coordinates)); } food_sources } diff --git a/artificial_bee_colony/src/main.rs b/artificial_bee_colony/src/main.rs index 1ac6971..26ea227 100644 --- a/artificial_bee_colony/src/main.rs +++ b/artificial_bee_colony/src/main.rs @@ -13,7 +13,7 @@ fn main() { ); for run_counter in 0..input.run { - let mut best_food_source = FoodSource::get(vec![]); + let mut best_food_source = FoodSource::new(vec![]); for food_source in &food_sources { if best_food_source.fitness < food_source.fitness { best_food_source @@ -24,7 +24,7 @@ fn main() { } for _ in 0..input.iteration { for index in 0..input.food_source_number as usize { - Bee::worker_bee( + Bee::employed_bee( &mut food_sources, index, input.decision_variable_count,