@@ -108,31 +108,32 @@ public void regenerate(Population population, Problem problem, Objective objecti
108
108
// Get the best member of the population:
109
109
final double [] bestMember = population .getBestMember ();
110
110
111
- // Are we going to adjust CR and F?
112
- if (this .c > 0 ) {
113
- // Yes. We will not adjust the CR first:
114
- this .cr = new NormalDistribution (this .randomGenerator , this .meanCR , 0.1 ).sample ();
115
-
116
- // Check and reset CR:
117
- this .cr = this .cr > 1 ? 1 : (this .cr < 0 ? 0 : this .cr );
118
-
119
- // OK, now we will adjust F:
120
- do {
121
- // Get the new F:
122
- this .f = new CauchyDistribution (this .randomGenerator , this .meanF , 0.1 ).sample ();
123
-
124
- // Check and reset F if required:
125
- this .f = this .f > 1 ? 1 : this .f ;
126
- } while (this .f <= 0 );
111
+ // Iterate over the current population:
112
+ for (int c = 0 ; c < population .getSize (); c ++) {
113
+ // Are we going to adjust CR and F?
114
+ if (this .c > 0 ) {
115
+ // Yes. We will not adjust the CR first:
116
+ this .cr = new NormalDistribution (this .randomGenerator , this .meanCR , 0.1 ).sample ();
117
+
118
+ // Check and reset CR:
119
+ this .cr = this .cr > 1 ? 1 : (this .cr < 0 ? 0 : this .cr );
120
+
121
+ // OK, now we will adjust F:
122
+ do {
123
+ // Get the new F:
124
+ this .f = new CauchyDistribution (this .randomGenerator , this .meanF , 0.1 ).sample ();
125
+
126
+ // Check and reset F if required:
127
+ this .f = this .f > 1 ? 1 : this .f ;
128
+ } while (this .f <= 0 );
127
129
// System.err.print(this.meanF);
128
130
// System.err.print(" ");
129
131
// System.err.print(this.cr);
130
132
// System.err.print(" ");
131
133
// System.err.println(this.f);
132
- }
134
+ }
135
+
133
136
134
- // Iterate over the current population:
135
- for (int c = 0 ; c < population .getSize (); c ++) {
136
137
// Get the candidate as the base of the next candidate (a.k.a. trial):
137
138
final double [] trial = population .getMemberCopy (c );
138
139
@@ -183,12 +184,11 @@ else if (trial[i] > problem.getUpper()[i]) {
183
184
this .goodF2 += Math .pow (this .f , 2 );
184
185
}
185
186
186
- }
187
-
188
- // Re-compute mean CR and F if required:
189
- if (this .c > 0 && this .goodF != 0 ) {
190
- this .meanCR = (1 - this .c ) * this .meanCR + this .c * this .goodCR ;
191
- this .meanF = (1 - this .c ) * this .meanF + this .c * this .goodF2 / this .goodF ;
187
+ // Re-compute mean CR and F if required:
188
+ if (this .c > 0 && this .goodF != 0 ) {
189
+ this .meanCR = (1 - this .c ) * this .meanCR + this .c * this .goodCR ;
190
+ this .meanF = (1 - this .c ) * this .meanF + this .c * this .goodF2 / this .goodF ;
191
+ }
192
192
}
193
193
}
194
194
}
0 commit comments