Skip to content

Commit

Permalink
feat: add parse_generations function
Browse files Browse the repository at this point in the history
  • Loading branch information
suhdonghwi committed Jun 5, 2021
1 parent 69c5b0c commit ab099d8
Show file tree
Hide file tree
Showing 2 changed files with 312 additions and 405 deletions.
17 changes: 12 additions & 5 deletions analysis/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
import matplotlib.pyplot as plt


class Specie:
Expand Down Expand Up @@ -41,9 +42,15 @@ def __init__(self, data):
print(self.species)


file = open("./analysis/output.txt", "r")
def parse_generations(path):
file = open(path, "r")
return [
Generation(g)
for g in re.compile("[-]+\n").split(file.read())
if g.strip() != ""
]

generations = [
Generation(g) for g in re.compile("[-]+\n").split(file.read()) if g.strip() != ""
]
print(generations)

generations = parse_generations("./analysis/output.txt")
plt.plot([g.fitness_max for g in generations])
plt.show()
Loading

0 comments on commit ab099d8

Please sign in to comment.