forked from hoehrmann/pngwolf
-
Notifications
You must be signed in to change notification settings - Fork 4
/
galib247.patch
163 lines (142 loc) · 6.48 KB
/
galib247.patch
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
diff --git a/galib/ga/GA1DArrayGenome.C b/galib/ga/GA1DArrayGenome.C
index d7471e8..24cc149 100644
--- a/galib/ga/GA1DArrayGenome.C
+++ b/galib/ga/GA1DArrayGenome.C
@@ -50,7 +50,7 @@ GAGenome(DEFAULT_1DARRAY_INITIALIZER,
evaluator(f);
userData(u);
nx=minX=maxX=length;
- crossover(DEFAULT_1DARRAY_CROSSOVER);
+ this->crossover(DEFAULT_1DARRAY_CROSSOVER);
}
@@ -222,10 +222,10 @@ GA1DArrayGenome<T>(length, f, u){
aset = new GAAlleleSet<T>[1];
aset[0] = s;
- initializer(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_INITIALIZER);
- mutator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_MUTATOR);
- comparator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_COMPARATOR);
- crossover(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_CROSSOVER);
+ this->initializer(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_INITIALIZER);
+ this->mutator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_MUTATOR);
+ this->comparator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_COMPARATOR);
+ this->crossover(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_CROSSOVER);
}
template <class T>
@@ -238,10 +238,10 @@ GA1DArrayGenome<T>(sa.size(), f, u) {
for(int i=0; i<naset; i++)
aset[i] = sa.set(i);
- initializer(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_INITIALIZER);
- mutator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_MUTATOR);
- comparator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_COMPARATOR);
- crossover(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_CROSSOVER);
+ this->initializer(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_INITIALIZER);
+ this->mutator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_MUTATOR);
+ this->comparator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_COMPARATOR);
+ this->crossover(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_CROSSOVER);
}
diff --git a/galib/ga/GA2DArrayGenome.C b/galib/ga/GA2DArrayGenome.C
index 64cede5..a9cc01c 100644
--- a/galib/ga/GA2DArrayGenome.C
+++ b/galib/ga/GA2DArrayGenome.C
@@ -39,7 +39,7 @@ GAGenome(DEFAULT_2DARRAY_INITIALIZER,
{
evaluator(f);
userData(u);
- crossover(DEFAULT_2DARRAY_CROSSOVER);
+ this->crossover(DEFAULT_2DARRAY_CROSSOVER);
nx=minX=maxX=width; ny=minY=maxY=height;
}
@@ -269,10 +269,10 @@ GA2DArrayGenome<T>(width,height,f,u){
aset = new GAAlleleSet<T>[1];
aset[0] = s;
- initializer(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_INITIALIZER);
- mutator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_MUTATOR);
- comparator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_COMPARATOR);
- crossover(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_CROSSOVER);
+ this->initializer(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_INITIALIZER);
+ this->mutator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_MUTATOR);
+ this->comparator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_COMPARATOR);
+ this->crossover(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_CROSSOVER);
}
template <class T>
@@ -286,10 +286,10 @@ GA2DArrayGenome<T>(width,height, f, u) {
for(int i=0; i<naset; i++)
aset[i] = sa.set(i);
- initializer(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_INITIALIZER);
- mutator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_MUTATOR);
- comparator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_COMPARATOR);
- crossover(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_CROSSOVER);
+ this->initializer(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_INITIALIZER);
+ this->mutator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_MUTATOR);
+ this->comparator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_COMPARATOR);
+ this->crossover(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_CROSSOVER);
}
diff --git a/galib/ga/GA3DArrayGenome.C b/galib/ga/GA3DArrayGenome.C
index 62219d2..4fd4f38 100644
--- a/galib/ga/GA3DArrayGenome.C
+++ b/galib/ga/GA3DArrayGenome.C
@@ -39,7 +39,7 @@ GAGenome(DEFAULT_3DARRAY_INITIALIZER,
{
evaluator(f);
userData(u);
- crossover(DEFAULT_3DARRAY_CROSSOVER);
+ this->crossover(DEFAULT_3DARRAY_CROSSOVER);
nx=minX=maxX=w; ny=minY=maxY=h; nz=minZ=maxZ=d;
}
@@ -322,10 +322,10 @@ GA3DArrayGenome<T>(w,h,d,f,u) {
aset = new GAAlleleSet<T>[1];
aset[0] = s;
- initializer(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_INITIALIZER);
- mutator(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_MUTATOR);
- comparator(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_COMPARATOR);
- crossover(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_CROSSOVER);
+ this->initializer(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_INITIALIZER);
+ this->mutator(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_MUTATOR);
+ this->comparator(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_COMPARATOR);
+ this->crossover(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_CROSSOVER);
}
template <class T>
@@ -339,10 +339,10 @@ GA3DArrayGenome<T>(w,h,d, f, u) {
for(int i=0; i<naset; i++)
aset[i] = sa.set(i);
- initializer(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_INITIALIZER);
- mutator(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_MUTATOR);
- comparator(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_COMPARATOR);
- crossover(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_CROSSOVER);
+ this->initializer(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_INITIALIZER);
+ this->mutator(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_MUTATOR);
+ this->comparator(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_COMPARATOR);
+ this->crossover(GA3DArrayAlleleGenome<T>::DEFAULT_3DARRAY_ALLELE_CROSSOVER);
}
diff --git a/galib/ga/GAIncGA.C b/galib/ga/GAIncGA.C
index 77b38ab..5f73e6c 100644
--- a/galib/ga/GAIncGA.C
+++ b/galib/ga/GAIncGA.C
@@ -237,6 +237,16 @@ GAIncrementalGA::step()
stats.numeval += c1 + c2;
+#ifdef _OPENMP
+ #pragma omp parallel sections
+ {
+ #pragma omp section
+ child1->evaluate();
+ #pragma omp section
+ child2->evaluate();
+ }
+#endif
+
if(rs == PARENT){
child1 = pop->replace(child1, mom);
if(mom == dad) // this is a possibility, if so do worst
diff --git a/galib/ga/gaerror.C b/galib/ga/gaerror.C
index c19d03d..8600518 100644
--- a/galib/ga/gaerror.C
+++ b/galib/ga/gaerror.C
@@ -21,7 +21,7 @@ char _gaerrbuf2[120];
static STD_OSTREAM *__gaErrStream = & STD_CERR;
#endif
static GABoolean __gaErrFlag = gaTrue;
-static char *__gaErrStr[] = {
+static const char *__gaErrStr[] = {
"error reading from file: ",
"error writing to file: ",
"unexpected EOF encountered during read.",