-
Notifications
You must be signed in to change notification settings - Fork 0
/
algorimths.py
30 lines (26 loc) · 1.3 KB
/
algorimths.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Examples module for users on how to create algorithms and testing"""
from gevopy import algorithms
from gevopy.tools import crossover, mutation, selection
# ------------------------------------------------------------------
# Basic Uniform Selection ------------------------------------------
# This algorithm selects both matching partners using an uniform
# distribution. Due to the fact that fitness does not play any role
# on the selection of phenotypes, adaptation to the environment is
# fully random.
class BasicUniform(algorithms.Standard):
selection1 = selection.Uniform()
selection2 = selection.Uniform()
crossover = crossover.OnePoint()
mutation = mutation.SinglePoint()
# ------------------------------------------------------------------
# Simple Ponderated Selection --------------------------------------
# This algorithm selects one matching partners using a ponderated
# distribution and the second with an uniform. Ponderated gives all
# phenotypes a chance to reproduce proportional to the fitness score.
# However, the posibility that best matches best is reduced agains
# two times ponderated.
class BasicPonderated(algorithms.Standard):
selection1 = selection.Ponderated()
selection2 = selection.Uniform()
crossover = crossover.OnePoint()
mutation = mutation.SinglePoint()