-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
118 lines (79 loc) · 3.31 KB
/
README
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
Implementation of CGP
=====================
Autor: Jan Viktorin
The application contains a modular implementation of CGP. The module
cgp.c talks to the rest of the application through the interfaces
func.h, chromo.h and fitness.h. Other modules implement these interfaces
and thus define the problem that is to be solved by the CGP.
Currently the only implemented problem is 'design of sorting networks'.
##
## Common usage
##
Example of an execution in one thread and using Swap&Compare primitives.
$ make
$ ./cgp
Example of an execution with OpenMP and using Swap&Compare primitiv.
$ make OPENMP=1
$ ./cgp
##
## Advanced compilation
##
The compilation can be configured:
* allow OpenMP
$ make OPENMP=1
* use different primitives (cells of the CGP matrix):
$ make FUNC_MOD=<module implementing the inteface func.h>.o
* use different fitness implementation:
$ make FITNESS=<module implementation the interface fitness.h>.o
Modules:
* func_minmax.o implementation of primitives And, Or, And3, Or3
* func_swap.o implementation of primitives Swap&Compare
* func_gates.o implementation of other gates as primitives
* fitness_bits64.o implementation of fitness to find a sorting network
(uses 64b integers)
##
## Advanced execution
##
As a result of the compilation there is an executable called cgp
that accepts three optional arguments.
$ ./cgp [runs] [output file] [chromosomes count]
runs ... how many times perform the evolution
vystupni soubor ... where to place the successful chromosomes
pocet chromozomu ... number of chromosomes that can be read from stdin
(thus it performs an optimalization)
During execution the cgp program prints the count of processed
generations, its speed (generations per second) and the best
fitness.
Best fitness ( 24707, 24236/s): 281
When an acceptable solution is found it prints
Success: <fitness>
and stores the chromosome to the output file (success.chr).
The current implementation always runs until the CGP_GENER count of
generations is reached. That happens because it tries to optimize
the count of used primitives (as less as possible).
This approach allows to find the best possible sorting networks.
##
## Configuration
##
The file cgp_config.h defines few constants that affects the CGP:
* matrix size
* Lback
* population size
* generations count (limit)
* number of inputs
* number of outputs
* number of mutations per chromsome
* probability of every mutation
##
## Utilities
##
To debug and analyze results there are few simple utilities:
* alap-tool loads a chromosome from stdin and prints result after ALAP
* fitness-tool [count] loads a `count` of chromosomes from stdin and prints their fitness
* mut-tool [count] loads a `count` of chromosomes from stdin and performs mutations
* eval-tool [file.chr] evaluates a chromosome using data from stdin (emulation of the circuit)
* bitgen-tool [width] generates bit vectors for the given bit `width` (possible to use as input
for eval-tool)
* chromo-tool [count] generates a `count` of chromosomes at random
* togv.awk AWK script to convert chromosome to graphviz format
$ head -1 success.chr | awk -f togv.awk | dot -Tpdf > success.pdf