Mathematically solved for weight

This commit is contained in:
SimpleArt
2020-12-06 11:35:30 -05:00
parent 7e4dffd646
commit ea93ad8796

View File

@ -204,14 +204,13 @@ class GA(Attributes):
for n in range(i, len(self.population)):
# Strongly cross with the best chromosome
# May reject negative weight
# May reject negative weight or division by 0
try:
tol_n = tol(n)
self.population[n] = self.crossover_individual_impl(
self,
self.population[n],
best_chromosome,
min(0.25, (2*tol_n - tol_j) / tol_n)
min(0.25, 2 * tol_j / (tol(n) - tol_j))
)
# If negative weights can't be used,