Update README.md
This commit is contained in:
40
README.md
40
README.md
@ -30,39 +30,31 @@ Put the out here
|
|||||||
import random
|
import random
|
||||||
import EasyGA
|
import EasyGA
|
||||||
|
|
||||||
# Setup the default genetic algorithm
|
# Create the Genetic algorithm
|
||||||
ga = EasyGA.GA()
|
ga = EasyGA.GA()
|
||||||
|
|
||||||
# User set sizes
|
# Makes a new gene
|
||||||
ga.population_size = 10
|
new_gene = ga.make_gene("HelloWorld")
|
||||||
ga.chromosome_length = 10
|
# Makes a chromosome to store genes in
|
||||||
ga.generations = 10
|
new_chromosome = ga.make_chromosome()
|
||||||
|
# Makes a Population to store chromosomes in
|
||||||
|
new_population = ga.make_population()
|
||||||
|
|
||||||
# The user defined gene function
|
ga.initialize()
|
||||||
def user_gene_function():
|
|
||||||
pass
|
|
||||||
|
|
||||||
# The user defined Fitness function that gives the chromosome some kind of fitness
|
print(ga.population)
|
||||||
def user_fitness_function(chromosome):
|
|
||||||
pass
|
|
||||||
|
|
||||||
# The user defined initialization function
|
for chromosome in ga.population.chromosomes:
|
||||||
def user_initialization_function():
|
print(chromosome.genes[0].__dict__)
|
||||||
pass
|
|
||||||
|
|
||||||
# User sets the gene function
|
|
||||||
ga.gene = user_gene_function
|
|
||||||
# Set the fitness functions
|
|
||||||
ga.fitness = user_fitness_function
|
|
||||||
# Changing the initialization function.
|
|
||||||
ga.initialization = user_initialization_function
|
|
||||||
# Run the customized genetic algorithm
|
|
||||||
ga.eveolve()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Output:
|
### Output:
|
||||||
```python
|
```python
|
||||||
Put the out here
|
<initialization.population_structure.population.population object at 0x7f993002fdf0>
|
||||||
|
{'fitness': None, 'value': 47}
|
||||||
|
{'fitness': None, 'value': 4}
|
||||||
|
{'fitness': None, 'value': 68}
|
||||||
|
{'fitness': None, 'value': 57}
|
||||||
```
|
```
|
||||||
|
|
||||||
# How Testing works
|
# How Testing works
|
||||||
|
|||||||
Reference in New Issue
Block a user