-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
36 lines (24 loc) · 830 Bytes
/
test.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
31
32
33
34
35
36
from GeneticAlgorithm import GeneticAlgorithm
from StoppingCondition import StoppingCondition
from CrossoverOperator import CrossoverOperator
from GeneticProblem import GeneticProblem
from StoppingCondition import ElapsedTimeStoppingCondition
class SimpleStoppingCondition(StoppingCondition):
def __init__(self):
pass
def is_satisfied(self):
return True
class SimpleCrossOver(CrossoverOperator):
def crossover(self, ch1, ch2):
return True
class SimpleGeneticProblem(GeneticProblem):
def decode(self, chromosome):
pass
def fitness(self, chromosome):
pass
sc = ElapsedTimeStoppingCondition(0.0008)
co = SimpleCrossOver()
gp = SimpleGeneticProblem(["a", "b", "c"], 2)
ga = GeneticAlgorithm(2, 2, 0.2, 0.9, sc, co)
ga.instantiate_problem(gp)
print(ga.execute())