def solve_isotropic_covariance(u, v, d, g_norm_square, p, P, \
                               lam10_init=None, lam20_init=None,
                               lam11_init=None, lam21_init=None):

    """ return the solution to the optimization problem
        Args:
        u ([type]): [the coordinate variance of the negative examples]
        v ([type]): [the coordinate variance of the positive examples]
        d ([type]): [the dimension of activation to protect]
        g_norm_square ([type]): [squared 2-norm of g_0 - g_1,
            i.e. |g^{(0)} - g^{(1)}|_2^2]
        P ([type]): [the power constraint value]
    """
    if u == np.float32(0.0) and v == np.float32(0.0):
        return solve_zero_uv(g_norm_square=g_norm_square, p=p, P=P)

    # logging.info("solve_isotropic_covariance, uv!=0")
    ordering = [0, 1, 2]
    random.shuffle(x=ordering)

    solutions = []
    if u <= v:
        # logging.info("solve_isotropic_covariance, u<=v")
        for i in range(NUM_CANDIDATE):
            if i % 3 == ordering[0]:
                # print('a')
                if lam20_init:  # if we pass an initialization
                    lam20 = lam20_init
                    # print('here')
                else:
                    lam20 = np.float32(random.random() * P / \
                                       (np.float32(1.0) - p) / d)
                lam10, lam11 = None, None
                # print('lam21', lam21)
            elif i % 3 == ordering[1]:
                # print('b')
                if lam11_init:
                    lam11 = lam11_init
                else:
                    lam11 = np.float32(random.random() * P / p)
                lam10, lam20 = None, None
                # print('lam11', lam11)
            else:
                # print('c')
                if lam10_init:
                    lam10 = lam10_init
                else:
                    lam10 = np.float32(random.random() * \
                                       P / (np.float32(1.0) - p))
                lam11, lam20 = None, None
            solutions.append(
                solve_small_neg(
                    u=u,
                    v=v,
                    d=d,
                    g_norm_square=g_norm_square,
                    p=p,
                    P=P,
                    lam10=lam10,
                    lam11=lam11,
                    lam20=lam20))

    else:
        # logging.info("solve_isotropic_covariance, u>v")
        for i in range(NUM_CANDIDATE):
            if i % 3 == ordering[0]:
                if lam21_init:
                    lam21 = lam21_init
                else:
                    lam21 = np.float32(random.random() * P / p / d)
                lam10, lam11 = None, None
                # print('lam21', lam21)
            elif i % 3 == ordering[1]:
                if lam11_init:
                    lam11 = lam11_init
                else:
                    lam11 = np.float32(random.random() * P / p)
                lam10, lam21 = None, None
                # print('lam11', lam11)
            else:
                if lam10_init:
                    lam10 = lam10_init
                else:
                    lam10 = np.float32(random.random() * P / (1 - p))
                lam11, lam21 = None, None
                # print('lam10', lam10)
            solutions.append(
                solve_small_pos(
                    u=u,
                    v=v,
                    d=d,
                    g_norm_square=g_norm_square,
                    p=p,
                    P=P,
                    lam10=lam10,
                    lam11=lam11,
                    lam21=lam21))

    lam10, lam20, lam11, lam21, objective = min(solutions, key=lambda x: x[-1])

    #print('sum', p * lam11 + p*(d-1)*lam21 + (1-p) * lam10 + (1-p)*(d-1)*lam20)

    return (lam10, lam20, lam11, lam21, objective)
 return the solution to the optimization problem
        Args:
        u ([type]): [the coordinate variance of the negative examples]
        v ([type]): [the coordinate variance of the positive examples]
        d ([type]): [the dimension of activation to protect]
        g_norm_square ([type]): [squared 2-norm of g_0 - g_1,
            i.e. |g^{(0)} - g^{(1)}|_2^2]
        P ([type]): [the power constraint value]
    
example/privacy/label_protection/solver.py