fix: 🚑 this much as bee can't be lying
This commit is contained in:
parent
812c34051d
commit
e9d8b8dbde
2 changed files with 19 additions and 14 deletions
|
@ -14,7 +14,7 @@ impl FoodSource {
|
||||||
pub fn new(coordinates: Vec<f64>) -> Self {
|
pub fn new(coordinates: Vec<f64>) -> Self {
|
||||||
let mut food_source = FoodSource {
|
let mut food_source = FoodSource {
|
||||||
fitness_calculation: 0.0,
|
fitness_calculation: 0.0,
|
||||||
function_calculation: 0.0,
|
function_calculation: 1.0,
|
||||||
coordinates,
|
coordinates,
|
||||||
try_counter: 0,
|
try_counter: 0,
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,10 +17,7 @@ fn main() {
|
||||||
let mut best_food_source = FoodSource::new(vec![]);
|
let mut best_food_source = FoodSource::new(vec![]);
|
||||||
for food_source in &food_sources {
|
for food_source in &food_sources {
|
||||||
if best_food_source.fitness_calculation < food_source.fitness_calculation {
|
if best_food_source.fitness_calculation < food_source.fitness_calculation {
|
||||||
best_food_source
|
best_food_source = food_source.clone();
|
||||||
.coordinates
|
|
||||||
.clone_from(&food_source.coordinates);
|
|
||||||
best_food_source.fitness_calculation = food_source.fitness_calculation;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _ in 0..input.iteration {
|
for _ in 0..input.iteration {
|
||||||
|
@ -50,7 +47,14 @@ fn main() {
|
||||||
most_tried_index = i;
|
most_tried_index = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
best_food_source = food_sources[most_tried_index].clone();
|
|
||||||
|
for food_source in &food_sources {
|
||||||
|
if best_food_source.fitness_calculation < food_source.fitness_calculation {
|
||||||
|
best_food_source = food_source.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if food_sources[most_tried_index].try_counter > input.food_source_try_limit {
|
||||||
Bee::scout_bee(
|
Bee::scout_bee(
|
||||||
&mut food_sources,
|
&mut food_sources,
|
||||||
most_tried_index,
|
most_tried_index,
|
||||||
|
@ -61,6 +65,7 @@ fn main() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function_results.push(best_food_source.function_calculation);
|
function_results.push(best_food_source.function_calculation);
|
||||||
fitness_results.push(best_food_source.fitness_calculation);
|
fitness_results.push(best_food_source.fitness_calculation);
|
||||||
give_output(
|
give_output(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue