Added the termination features
This commit is contained in:
@ -1 +1,2 @@
|
||||
from .default_fitness_example import default_fitness_example
|
||||
# FROM (. means local) file_name IMPORT function_name
|
||||
from .is_the_value_5 import is_the_value_5
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
def default_fitness_example():
|
||||
pass
|
||||
14
src/fitness_function/is_the_value_5.py
Normal file
14
src/fitness_function/is_the_value_5.py
Normal file
@ -0,0 +1,14 @@
|
||||
def is_the_value_5(chromosome):
|
||||
"""A very simple case test function - If the chromosomes gene value is a 5 add one
|
||||
to the chromosomes overall fitness value."""
|
||||
|
||||
# Overall fitness value
|
||||
fitness = 0
|
||||
# For each gene in the chromosome
|
||||
for gene in chromosome.genes:
|
||||
# Check if its value = 5
|
||||
if(gene.value == 5):
|
||||
# If its value is 5 then add one to
|
||||
# the overal fitness of the chromosome.
|
||||
fitness += 1
|
||||
return fitness
|
||||
Reference in New Issue
Block a user