diff --git a/__pycache__/RotTable.cpython-37.pyc b/__pycache__/RotTable.cpython-37.pyc index 0f0c7511895c47a8cfeb05cd095f0bbee2f31924..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 Binary files a/__pycache__/RotTable.cpython-37.pyc and b/__pycache__/RotTable.cpython-37.pyc differ diff --git a/__pycache__/Traj3D.cpython-37.pyc b/__pycache__/Traj3D.cpython-37.pyc deleted file mode 100644 index 1c96963aabd1b568f33a524d629ac0fbd51f9518..0000000000000000000000000000000000000000 Binary files a/__pycache__/Traj3D.cpython-37.pyc and /dev/null differ diff --git a/__pycache__/croisement.cpython-37.pyc b/__pycache__/croisement.cpython-37.pyc deleted file mode 100644 index 24659b511a06317791374055d8756a71bf947669..0000000000000000000000000000000000000000 Binary files a/__pycache__/croisement.cpython-37.pyc and /dev/null differ diff --git a/__pycache__/individu.cpython-37.pyc b/__pycache__/individu.cpython-37.pyc index 1d266105529cfa0c43eefd0edc5dcaf184adefec..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 Binary files a/__pycache__/individu.cpython-37.pyc and b/__pycache__/individu.cpython-37.pyc differ diff --git a/__pycache__/population.cpython-37.pyc b/__pycache__/population.cpython-37.pyc deleted file mode 100644 index ac693785cdf9586e97d434cfe6cf9ec4648b1453..0000000000000000000000000000000000000000 Binary files a/__pycache__/population.cpython-37.pyc and /dev/null differ diff --git a/croisement.py b/croisement.py index 2bdb485cc5acfb57439e45e856e88296edb25876..96f85a8a89e1dcaa97cbed0f06233942ee36f211 100644 --- a/croisement.py +++ b/croisement.py @@ -18,7 +18,7 @@ ROT_TABLE = {\ "TA": [36, 0.9, 0, 1.1, 2, 0],\ "TC": [36.9, 5.3, -120, 0.9, 6, 0],\ "TG": [34.5, 3.5, 64, 0.9, 34, 0],\ - "TT": [35.62, 7.2, 154, 0.06, 0.6, 0]\ + "TT": [35.62, 7.2, -154, 0.06, 0.6, 0]\ } @@ -26,30 +26,71 @@ def croisement_un_point(parent1, parent2): enfant1 = Individu(RotTable()) enfant2 = Individu(RotTable()) comp = 0 - point_crois= numpy.random.random_integers(0,16) + point_crois= numpy.random.random_integers(0,8) for doublet in ROT_TABLE: + if doublet == "GA": + break if comp < point_crois: enfant1.table.rot_table[doublet] = parent1.table.rot_table[doublet] + correspondent_doublet1 = enfant1.table.corr()[doublet] + enfant1.table.rot_table[correspondent_doublet1] = parent1.table.rot_table[correspondent_doublet1] + enfant1.table.rot_table[correspondent_doublet1][2] *= -1 + enfant2.table.rot_table[doublet] = parent2.table.rot_table[doublet] + correspondent_doublet2 = enfant2.table.corr()[doublet] + enfant2.table.rot_table[correspondent_doublet2] = parent2.table.rot_table[correspondent_doublet2] + enfant2.table.rot_table[correspondent_doublet2][2] *= -1 + else : enfant1.table.rot_table[doublet] = parent2.table.rot_table[doublet] + correspondent_doublet1 = enfant1.table.corr()[doublet] + enfant1.table.rot_table[correspondent_doublet1] = parent2.table.rot_table[correspondent_doublet1] + enfant1.table.rot_table[correspondent_doublet1][2] *= -1 + enfant2.table.rot_table[doublet] = parent1.table.rot_table[doublet] + correspondent_doublet2 = enfant2.table.corr()[doublet] + enfant2.table.rot_table[correspondent_doublet2] = parent1.table.rot_table[correspondent_doublet1] + enfant2.table.rot_table[correspondent_doublet2][2] *= -1 + comp += 1 return enfant1, enfant2 def croisement_deux_points(parent1, parent2): - enfant1 = RotTable() - enfant2 = RotTable() + enfant1 = Individu(RotTable()) + enfant2 = Individu(RotTable()) comp = 0 - point_crois1= numpy.random.random_integers(0,16) - point_crois2= numpy.random.random_integers(0,16) + point_crois1= numpy.random.random_integers(0,8) + point_crois2= numpy.random.random_integers(0,8) for doublet in ROT_TABLE: if comp < min(point_crois1,point_crois2) or comp > max(point_crois1,point_crois2): - enfant1.rot_table[doublet] = parent1.rot_table[doublet] - enfant2.rot_table[doublet] = parent2.rot_table[doublet] + enfant1.table.rot_table[doublet] = parent1.table.rot_table[doublet] + correspondent_doublet1 = enfant1.table.corr()[doublet] + enfant1.table.rot_table[correspondent_doublet1] = parent1.table.rot_table[correspondent_doublet1] + enfant1.table.rot_table[correspondent_doublet1][2] *= -1 + + enfant2.table.rot_table[doublet] = parent2.table.rot_table[doublet] + correspondent_doublet2 = enfant2.table.corr()[doublet] + enfant2.table.rot_table[correspondent_doublet2] = parent2.table.rot_table[correspondent_doublet2] + enfant2.table.rot_table[correspondent_doublet2][2] *= -1 + else : - enfant1.rot_table[doublet] = parent2.rot_table[doublet] - enfant2.rot_table[doublet] = parent1.rot_table[doublet] + enfant1.table.rot_table[doublet] = parent2.table.rot_table[doublet] + correspondent_doublet1 = enfant1.table.corr()[doublet] + enfant1.table.rot_table[correspondent_doublet1] = parent2.table.rot_table[correspondent_doublet1] + enfant1.table.rot_table[correspondent_doublet1][2] *= -1 + + enfant2.table.rot_table[doublet] = parent1.table.rot_table[doublet] + correspondent_doublet2 = enfant2.table.corr()[doublet] + enfant2.table.rot_table[correspondent_doublet2] = parent1.table.rot_table[correspondent_doublet1] + enfant2.table.rot_table[correspondent_doublet2][2] *= -1 comp += 1 - return enfant1, enfant2 \ No newline at end of file + return enfant1, enfant2 + +# parent1 = Individu(RotTable()) +# parent2 = Individu(RotTable()) +# print("parent1: ", parent1.table.rot_table) +# print("parent2: ", parent2.table.rot_table) +# enfant1, enfant2 = croisement_un_point(parent1, parent2) +# print("enfant1: ", enfant1.table.rot_table) +# print("enfant2: ", enfant2.table.rot_table) \ No newline at end of file