@@ -191,7 +191,7 @@ struct UncorrelatedCovarianceTransformation <: RotationMatrixBasedCrossoverTrans
191191 UncorrelatedCovarianceTransformation(1.0, 0.5, 0.95, [1.0630691323565e-311 1.0630691151907e-311 … 1.063069230316e-311 1.063069119645e-311; 1.0630691158705e-311 1.063069115333e-311 … 1.063069172704e-311 1.0630692904614e-311; … ; 1.063069115428e-311 1.063069114246e-311 … 1.063069124886e-311 1.0630694190924e-311; 1.0630691153804e-311 1.0630691141986e-311 … 1.0630691348624e-311 1.063069428614e-311], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], UInt16[], UInt16[])
192192 ```
193193 """
194- function UncorrelatedCovarianceTransformation (pb, a, num_dims; ps = 1.0 )
194+ function UncorrelatedCovarianceTransformation (pb, a, num_dims; ps= 1.0 )
195195 if ps <= 0.0 || ps > 1.0
196196 throw (ArgumentError (" ps must be in the range (0, 1]." ))
197197 end
@@ -202,13 +202,23 @@ struct UncorrelatedCovarianceTransformation <: RotationMatrixBasedCrossoverTrans
202202 throw (ArgumentError (" a must be in the range (0, 1]." ))
203203 end
204204 B = Matrix {Float64} (undef, num_dims, num_dims)
205- return new (ps, pb, a, B, zeros (num_dims), zeros (num_dims), Vector {UInt16} (undef, 0 ), Vector {UInt16} (undef, 0 ))
205+ return new (
206+ ps,
207+ pb,
208+ a,
209+ B,
210+ zeros (num_dims),
211+ zeros (num_dims),
212+ Vector {UInt16} (undef, 0 ),
213+ Vector {UInt16} (undef, 0 ),
214+ )
206215 end
207-
208216end
209217
210218initialize! (transformation:: NoTransformation , population_size) = nothing
211- function initialize! (transformation:: RotationMatrixBasedCrossoverTransformation , population_size)
219+ function initialize! (
220+ transformation:: RotationMatrixBasedCrossoverTransformation , population_size
221+ )
212222 resize! (transformation. idxs, population_size)
213223 transformation. idxs .= 1 : population_size
214224 return nothing
@@ -241,7 +251,9 @@ function update_transformation!(transformation::CovarianceTransformation, popula
241251
242252 return nothing
243253end
244- function update_transformation! (transformation:: UncorrelatedCovarianceTransformation , population)
254+ function update_transformation! (
255+ transformation:: UncorrelatedCovarianceTransformation , population
256+ )
245257 # get correlation for each pair of vectors in population
246258 cor_mat = cor (stack (population. current_generation. candidates))
247259
@@ -262,8 +274,8 @@ function update_transformation!(transformation::UncorrelatedCovarianceTransforma
262274
263275 # find points where two candidates are strongly correlated
264276
265- @inbounds for j in axes (cor_mat,2 )
266- for i in j + 1 : size (cor_mat,1 )
277+ @inbounds for j in axes (cor_mat, 2 )
278+ for i in (j + 1 ) : size (cor_mat, 1 )
267279 abs_x = abs (cor_mat[i, j])
268280 if abs_x >= transformation. a
269281 # Base.push!(transformation.pairs, SVector(i, j))
@@ -274,7 +286,6 @@ function update_transformation!(transformation::UncorrelatedCovarianceTransforma
274286 end
275287 end
276288
277-
278289 # if we're removing all but one idx, set transformation to identity and return
279290 if length (transformation. cidxs) >= length (transformation. idxs) - 1
280291 fill_identity! (transformation. B)
@@ -288,7 +299,11 @@ function update_transformation!(transformation::UncorrelatedCovarianceTransforma
288299 setdiff! (transformation. idxs, transformation. cidxs)
289300
290301 # get number of candidates to use for covariance based on remaining candidates
291- n = clamp (ceil (Int, transformation. ps * length (transformation. idxs)), 2 , length (transformation. idxs))
302+ n = clamp (
303+ ceil (Int, transformation. ps * length (transformation. idxs)),
304+ 2 ,
305+ length (transformation. idxs),
306+ )
292307
293308 # Get indices of n best remaining candidates
294309 idxs = view (transformation. idxs, 1 : n)
@@ -321,7 +336,9 @@ function to_transformed(transformation::RotationMatrixBasedCrossoverTransformati
321336end
322337
323338from_transformed! (transformation:: NoTransformation , mt, m) = nothing
324- function from_transformed! (transformation:: RotationMatrixBasedCrossoverTransformation , mt, m)
339+ function from_transformed! (
340+ transformation:: RotationMatrixBasedCrossoverTransformation , mt, m
341+ )
325342 mul! (m, transformation. B, mt)
326343 return nothing
327344end
0 commit comments