Zaktualizuj 'DNA.py'
This commit is contained in:
parent
1e695efca7
commit
72e3ff9f1b
5
DNA.py
5
DNA.py
@ -6,11 +6,10 @@ import numpy as np
|
||||
|
||||
class DNA:
|
||||
|
||||
def __init__(self, target, recordDistance):
|
||||
def __init__(self, target):
|
||||
shuffle(target)
|
||||
self.genes = target.copy()
|
||||
self.fitness = 1.0
|
||||
self.recordDistance = recordDistance
|
||||
|
||||
def calcFitness(self, A):
|
||||
start = [0, 0]
|
||||
@ -25,7 +24,7 @@ class DNA:
|
||||
|
||||
def crossover(self, partner):
|
||||
|
||||
child = DNA(self.genes, self.recordDistance)
|
||||
child = DNA(self.genes)
|
||||
start = abs(random.randint(0, len(self.genes)) - 1)
|
||||
end = abs(random.randint(start - 1, len(self.genes)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user