(self, x)
return 10*N + sum(x**2 - 10*np.cos(2*np.pi*x))
Rastrigin test objective function
Rastrigin test objective function
Rastrigin test objective function
def rastrigin(self, x):
        """Rastrigin test objective function"""
        if not np.isscalar(x[0]):
            N = len(x[0])
            return [10*N + sum(xi**2 - 10*np.cos(2*np.pi*xi)) for xi in x]
            # return 10*N + sum(x**2 - 10*np.cos(2*np.pi*x), axis=1)
        N = len(x)
        return 10*N + sum(x**2 - 10*np.cos(2*np.pi*x))
def rastrigin ( self , x ) : if not np . isscalar ( x [ 0 ] ) : N = len ( x [ 0 ] ) return [ 10 * N + sum ( xi ** 2 - 10 * np . cos ( 2 * np . pi * xi ) ) for xi in x ] # return 10*N + sum(x**2 - 10*np.cos(2*np.pi*x), axis=1) N = len ( x ) return 10 * N + sum ( x ** 2 - 10 * np . cos ( 2 * np . pi * x ) )