feat: fitness evaluation is added to output

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-11-20 00:20:40 +03:00
parent 8eda015039
commit 812c34051d
4 changed files with 31 additions and 23 deletions

View file

@ -33,7 +33,7 @@ impl Bee {
candidate_coordinates[selected_coordinate_index] = candidate_one_index;
let candidate = FoodSource::new(candidate_coordinates);
food_sources[index].try_counter += 1;
if candidate.fitness > food_sources[index].fitness {
if candidate.fitness_calculation > food_sources[index].fitness_calculation {
food_sources[index] = candidate;
food_sources[index].try_counter = 0;
}
@ -47,7 +47,7 @@ impl Bee {
upper_bound: f64,
lower_bound: f64,
) {
let fitness_for_index = food_sources[index].fitness;
let fitness_for_index = food_sources[index].fitness_calculation;
if fitness_for_index / total_fitness <= rand::thread_rng().gen_range(0.0..=1.0) {
Self::employed_bee(
food_sources,