Requested file name changes
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
# FROM (. means local) file_name IMPORT function_name
|
||||
from .example_is_it_5 import example_is_it_5
|
||||
# FROM (. means local) file_name IMPORT class name
|
||||
from .examples import fitness_examples
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
def example_is_it_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
|
||||
16
src/fitness_function/examples.py
Normal file
16
src/fitness_function/examples.py
Normal file
@ -0,0 +1,16 @@
|
||||
class fitness_examples:
|
||||
"""Fitness function examples used"""
|
||||
|
||||
def is_it_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