(self, x, cfac = 1e8, tough=True, cond=1e6)
return f
ellipsoid test objective function with "constraints"
ellipsoid test objective function with "constraints"
ellipsoid test objective function with constraints
def elliconstraint(self, x, cfac = 1e8, tough=True, cond=1e6):
        """ellipsoid test objective function with "constraints" """
        N = len(x)
        f = sum(cond**(np.arange(N)[-1::-1]/(N-1)) * x**2)
        cvals = (x[0] + 1,
                 x[0] + 1 + 100*x[1],
                 x[0] + 1 - 100*x[1])
        if tough:
            f += cfac * sum(max(0,c) for c in cvals)
        else:
            f += cfac * sum(max(0,c+1e-3)**2 for c in cvals)
        return f
def elliconstraint ( self , x , cfac = 1e8 , tough = True , cond = 1e6 ) : N = len ( x ) f = sum ( cond ** ( np . arange ( N ) [ - 1 : : - 1 ] / ( N - 1 ) ) * x ** 2 ) cvals = ( x [ 0 ] + 1 , x [ 0 ] + 1 + 100 * x [ 1 ] , x [ 0 ] + 1 - 100 * x [ 1 ] ) if tough : f += cfac * sum ( max ( 0 , c ) for c in cvals ) else : f += cfac * sum ( max ( 0 , c + 1e-3 ) ** 2 for c in cvals ) return f