(self, x, alpha=1e2)
return f if len(f) > 1 else f[0]
Rosenbrock test objective function
Rosenbrock test objective function
Rosenbrock test objective function
def rosen(self, x, alpha=1e2):
        """Rosenbrock test objective function"""
        x = [x] if np.isscalar(x[0]) else x  # scalar into list
        f = [sum(alpha*(x[:-1]**2-x[1:])**2 + (1.-x[:-1])**2) for x in x]
        return f if len(f) > 1 else f[0]  # 1-element-list into scalar
def rosen ( self , x , alpha = 1e2 ) : x = [ x ] if np . isscalar ( x [ 0 ] ) else x # scalar into list f = [ sum ( alpha * ( x [ : - 1 ] ** 2 - x [ 1 : ] ) ** 2 + ( 1. - x [ : - 1 ] ) ** 2 ) for x in x ] return f if len ( f ) > 1 else f [ 0 ] # 1-element-list into scalar