diff --git a/individu.py b/individu.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..02c676cb171bfb49572264d1c6d4f55371c35ec2 100644 --- a/individu.py +++ b/individu.py @@ -0,0 +1,33 @@ +from table_rotation import table_rotation +from traj3D import * +import numpy as np +from math import sqrt + +class Individu(): + + def __init__(self, rot_table): + self.rot_table = rot_table + self.score = None + + def evaluate(self, brin): + traj = Traj3D() + traj.compute(brin, self.rot_table) + traj_array = np.array(traj.getTraj()) + + first_nucleotide = traj_array[0, :] + last_nucleotide = traj_array[-1, :] + distance = sqrt(sum((last_nucleotide - last_nucleotide) ** 2)) + + first_name = brin[0] + last_name = brin[-1] + + rot_computed = rot_table[last_name+first_name] + rot_traj = first_name - last_name + diff_angle = sum(abs(rot_computed - rot_traj)) + + self.score = 1/(distance + diff_angle) + + + def mutation(self): + + return mutation