Minor bugs
This commit is contained in:
@ -165,7 +165,7 @@ class Crossover_Methods:
|
|||||||
yield random.randint(*sorted([value_1, value_2]))
|
yield random.randint(*sorted([value_1, value_2]))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
yield random.uniform([value_1, value_2])
|
yield random.uniform(value_1, value_2)
|
||||||
except:
|
except:
|
||||||
yield ValueError("Unhandled gene type found. Use integer or float genes.")
|
yield ValueError("Unhandled gene type found. Use integer or float genes.")
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ def add_by_tolerance_goal(termination_impl):
|
|||||||
def new_method(ga):
|
def new_method(ga):
|
||||||
|
|
||||||
# If tolerance is set, check it.
|
# If tolerance is set, check it.
|
||||||
if ga.tolerance_goal is not None:
|
if ga.tolerance_goal is not None and ga.population is not None:
|
||||||
best_fitness = ga.population[0].fitness
|
best_fitness = ga.population[0].fitness
|
||||||
threshhold_fitness = ga.population[round(ga.percent_converged*len(ga.population))].fitness
|
threshhold_fitness = ga.population[round(ga.percent_converged*len(ga.population))].fitness
|
||||||
tol = ga.tolerance_goal * (1 + abs(best_fitness))
|
tol = ga.tolerance_goal * (1 + abs(best_fitness))
|
||||||
|
|||||||
Reference in New Issue
Block a user