@@ -323,6 +323,7 @@ class Ackley(ProblemABC):
323323 X*=0 0 0 ... 0
324324 F*=0
325325 '''
326+ name = "Ackley"
326327 def __init__ (self , nInput :int = 30 ,
327328 ub : Union [int , float , list , np .ndarray ] = 32 ,
328329 lb : Union [int , float , list , np .ndarray ] = - 32 ):
@@ -335,7 +336,7 @@ def objFunc(self, X: np.ndarray) -> np.ndarray:
335336
336337 Temp1 = np .exp (np .sqrt (np .sum (np .square (X ),axis = 1 )/ self .nInput )* - 0.2 )* - 20
337338 Temp2 = np .exp (np .sum (np .cos (2 * np .pi * X ),axis = 1 )/ self .nInput )* - 1 + 20 + np .e
338- F = (Temp1 + Temp2 ). reshape [:, np .newaxis ]
339+ F = (Temp1 + Temp2 )[:, np .newaxis ]
339340
340341 return F
341342
@@ -507,12 +508,12 @@ def objFunc(self, X: np.ndarray) -> np.ndarray:
507508 K = np .atleast_2d (np .linspace (1 , self .kMax , self .kMax ))
508509 aK = np .power (self .a , K )
509510 bK = np .power (self .b , K )
510- aK_expand = np .tile (aK . transpose () ,(1 , self .nInput ))[:, np . newaxis ]
511- bK_expand = np .tile (bK . transpose () ,(1 , self .nInput ))[:, np . newaxis ]
511+ aK_expand = np .tile (aK ,(1 , self .nInput ))
512+ bK_expand = np .tile (bK ,(1 , self .nInput ))
512513
513514
514515 X_expand = np .tile (X , (1 , self .kMax ))
515- Addition = np .sum (aK * np .cos (bK * np .pi ), axis = 1 )[:, np . newaxis ] * self .nInput
516+ Addition = np .sum (aK * np .cos (bK * np .pi )) * self .nInput
516517 F = np .sum (np .cos (2 * np .pi * (X_expand + 0.5 ) * bK_expand ) * aK_expand , axis = 1 )[:, np .newaxis ] - Addition
517518
518519 return F
0 commit comments