3

I'm finding CVXPY is randomly failing with the following error:

ArpackError: ARPACK error 3: No shifts could be applied during a cycle of the Implicitly restarted 
Arnoldi iteration. One possibility is to increase the size of NCV relative to NEV. 

The code below is a minimal example where it is just trying to do mean variance optimisation with no constraints, identity correlation matrix, and normally distributed mean vector. Roughly once in every thousand runs this fails. It doesn't seem to matter which solver I ask it to use, which makes me think it is failing setting up the problem?

import cvxpy as cp
import numpy as np

n = 199

np.random.seed(100)
mu = np.random.normal(size = n)

C = np.eye(n)

for repeat in range(1000):

    x = cp.Variable(n)

    mean = x.T @ mu
    variance = cp.quad_form(x, C)

    objective = cp.Maximize(mean - variance)
    constraints = []
    prob = cp.Problem(objective, constraints)

    result = prob.solve()
    print(repeat, end = " ")
Corvus
  • 7,548
  • 9
  • 42
  • 68
  • 3
    I reproduced your problem and it is exclusively about scipy. You can make a loop that just calls the eigsh eigenvalue method on np.eye(n) in the same fashion cvxpy would and already that will fail. Very interesting, perhaps should be reported as a scipy.sparse.linalg issue – Michal Adamaszek Sep 20 '20 at 21:13

0 Answers0