Exemplo n.º 1
0
def covsel_cvx_dense(R, U, rows, cols, num_iterations=500, min_ev=1e-2):
    min_ei = smallest_ev_arpack(R, U, rows, cols)
    print "min_ei is %f" % min_ei
    if min_ei < min_ev:
        R0 = R - min_ei + min_ev
    else:
        R0 = R
    return run_cvx_dense(R0, U, rows, cols, num_iterations)
Exemplo n.º 2
0
def covsel_cvx_cholmod(
    R, U, rows, cols, k, psd_tolerance=1e-6, factor=None, num_iterations=500, finish_early=True, debug=True
):
    if debug:
        tic("smallest ev", "covsel_cvx_cholmod")
    min_ei = smallest_ev_arpack(R, U, rows, cols)
    if debug:
        tic("min_ei is %f" % min_ei, "covsel_cvx_cholmod")
    if min_ei < 0:
        R0 = R - min_ei + 1e-3
    else:
        R0 = R
    return run_cvx_cholmod(R0, U, rows, cols, k, psd_tolerance, factor, num_iterations, finish_early)
Exemplo n.º 3
0
def covsel_quick(R,U,rows,cols,lbda=1e6):
  min_ei = smallest_ev_arpack(R, U, rows, cols)
  if min_ei < 0:
    print "min_ei is %f"%min_ei
    R0 = R - min_ei + 1e-3
  else:
    R0 = R
  n = len(R)
  m = len(U)
  S = build_dense(R0, U, rows, cols)
  
  L=lbda * np.ones((n,n),dtype=np.double)
  L[np.arange(n),np.arange(n)] = 0
  L[rows,cols]=0
  L[cols,rows]=0
  
  (X_, W_, opt, time) = run_quic(S, L)
  D = X_.diagonal()
  P = X_[rows,cols]
  R2 = W_.diagonal()
  U2 = W_[rows,cols]
  print "Quic: Error is %f diag, %f outer"%(linalg.norm(R0-R2),linalg.norm(U-U2))
  return (D,P)