-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
95 lines (79 loc) · 2.82 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from simpgenalg import geneticAlgorithm
#from dashtest import generationViewer
def num_matching(lst):
return sum([abs(val-indx) for indx, val in enumerate(lst)])
vga_params = dict(function=num_matching,\
n_gens=200,\
num_genes=10, \
dtype=int, \
max=10, \
min=0, \
xov_op='uniform_crossover',\
mut_op='uniform_mutation',\
mut_rate=0.1,\
xov_rate=0.8,
maximize=False,
cmpr_map_dist=False)
bsga_params = dict(function=num_matching,\
representation='binary',\
n_gens=200,\
num_genes=10, \
gene_size=4, \
xov_op='twopt',\
mut_op='uniform_mutation',\
mut_rate=0.1,\
xov_rate=0.8,
maximize=False,
cmpr_map_dist=False)
var_pga_params = dict(function=num_matching,\
representation='proportional',\
map_fxn=3,\
min=0,
max=10,
n_noncoding_chars=1,\
lenmin=30,
lenmax=300,
n_gens=200,\
num_genes=10, \
xov_op='homologous_onept',\
mut_op='uniform_mutation',\
homology_threshold=0,\
window_size=5,\
mut_rate=0.1,\
xov_rate=0.8,
maximize=False,
cmpr_map_dist=False)
pga_params = dict(function=num_matching,\
representation='proportional',\
map_fxn=3,\
min=0,
max=10,
n_noncoding_chars=1,\
len=100,
n_gens=200,\
num_genes=10, \
xov_op='homologous_onept',\
mut_op='uniform_mutation',\
homology_threshold=0.5,\
window_size=5,\
mut_rate=0.1,\
xov_rate=0.8,
maximize=False,
cmpr_map_dist=False)
fga_params = dict(function=num_matching,\
representation='floating',\
min=0)
ga = geneticAlgorithm(**vga_params)
rslts = ga.run(n=1)
dataframes = rslts.to_df()
dataframes[0].to_csv('indvs.csv')
dataframes[1].to_csv('pops.csv')
#generationViewer(indvs='indvs.csv', stats='pops.csv', debug=True)
'''
from simpgenalg.representations.vector import vectorRepresentation
test1 = vectorRepresentation(lenLim=(10,10), dtype=int, min=0, max=1)
test2 = vectorRepresentation(lenLim=(10,10), dtype=int, min=0, max=1)
#test1.set_fit(10)
#test2.set_fit(200)
print(test1 < test2)
'''