Skip to content

Commit

Permalink
Add best fitness log message
Browse files Browse the repository at this point in the history
  • Loading branch information
reinterpretcat committed Oct 7, 2024
1 parent fd3d623 commit 6355721
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions experiments/etc/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def solve_scientific(self, scientific_format, problem_path, config_path, solutio
raise ValueError('cannot get solution statistic')

# expected:
# fitness: (0.000, 92.000, 53389.603),
# best fitness: (0.000, 92.000, 53389.603),
for best in re.finditer(
r"fitness: \((?P<unassigned>[\d.]+),?\s*(?P<tours>[\d.]+)?\s*, (?P<cost>[\d.]+)\)",
r"best fitness: \((?P<unassigned>[\d.]+),?\s*(?P<tours>[\d.]+)?\s*, (?P<cost>[\d.]+)\)",
p.stdout):
pass

Expand Down
5 changes: 5 additions & 0 deletions rosomaxa/src/evolution/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ where
let speed = generations as Float / self.time.elapsed_secs_as_float();

self.log(format!("[{elapsed}s] total generations: {generations}, speed: {speed:.2} gen/sec",).as_str());
if let Some(best) = population.ranked().next() {
self.log(format!("\tbest fitness: ({})", format_fitness(best.fitness())).as_str());
} else {
self.log("no solutions found");
}

self.metrics.duration = elapsed;
self.metrics.speed = speed;
Expand Down

0 comments on commit 6355721

Please sign in to comment.