fanok.sdp package¶
Submodules¶
fanok.sdp.sdp module¶
-
fanok.sdp.sdp.asdp(Sigma: numpy.ndarray, blocks: int = 2, gamma_tol: float = 1e-05, **kwargs)¶ Solves the SDP in two steps. First the covariance is approximated with a block-diagonal matrix. Sub-SDPs are solved in these blocks. Then, a one-dimensional SDP is efficiently solved with bisection in order to make the solution feasible.
Parameters: - Sigma – Covariance matrix
- blocks – Number of clusters
- gamma_tol – Tolerance threshold when solving the one-dimensional SDP
- kwargs – Extra keyword arguments given to the SDP solver
-
fanok.sdp.sdp.cov_to_cor(Sigma: numpy.ndarray)¶ Converts a covariance matrix to a correlation matrix.
Parameters: Sigma – Covariance matrix
-
fanok.sdp.sdp.cvx_sdp_full(Sigma: numpy.ndarray, solver: str = None, clip: bool = True, **kwargs)¶ Solves the SDP with CVXPY.
Parameters: - Sigma – Covariance matrix
- solver – Which solver to use. Defaults to SCS
- clip – Whether or not to clip the solution (on the correlation matrix)
into [0, 1]. It is only supposed to fix eventual numerical approximations of the solver. Defaults to True :param kwargs: Extra keyword arguments passed to the solver
-
fanok.sdp.sdp.make_asdp_clusters(Sigma: numpy.ndarray, blocks: int = 2)¶ Approximates the covariance matrix Sigma with a block diagonal matrix.
Parameters: - Sigma – Covariance matrix
- blocks – Number of clusters
-
fanok.sdp.sdp.sdp_equi(Sigma: numpy.ndarray)¶ Returns the minimum eigenvalue of 2 * Sigma. This is a cheap way to find a feasible solution to the SDP but knockoffs generated with it might lead to a low statistical power.
Parameters: Sigma – Covariance matrix. It is scaled to a correlation matrix and the result is scaled back at the end.
-
fanok.sdp.sdp.sdp_full(Sigma: numpy.ndarray, max_iterations: int = None, lam: float = None, mu: float = None, tol: float = -1, eps=1e-05, return_objectives: bool = False)¶ Solves the SDP with a fast coordinate ascent algorithm. Wrapper of the efficient Cython implementation.
Parameters: - Sigma – Covariance matrix
- max_iterations – Maximum number of coordinate cycles
- lam – Initial barrier coefficient parameter. Most
you don’t need to change this parameter because the default value automatically adapts to the problem. :param mu: Barrier coefficient decay parameter. Should be comprised between 0 and 1. Lower values are ore aggressive but might not converge to the optimal value (machine precision is reached faster). Defaults to 0.8.
-
fanok.sdp.sdp.sdp_low_rank(d: numpy.ndarray, U: numpy.ndarray, singular_values: numpy.ndarray = None, max_iterations: int = None, lam: float = None, mu: float = None, tol: float = -1, eps: float = 1e-05, return_objectives: bool = False)¶ Solves the low-rank SDP with coordinate ascent. The covariance Sigma is supposed to have the special structure Sigma = diag(d) + U * eigs * U^T Wrapper of the efficient Cython implementation.
Parameters: - d – Positive diagonal term of the factor model
- U – Low-rank term of the factor model
- singular_values – Optional singular_values of the low-rank term
- max_iterations – Maximum number of coordinate cycles
- lam – Initial barrier coefficient parameter. Most
you don’t need to change this parameter because the default value automatically adapts to the problem. :param mu: Barrier coefficient decay parameter. Should be comprised between 0 and 1. Lower values are ore aggressive but might not converge to the optimal value (machine precision is reached faster). Defaults to 0.8. :param return_objectives: Whether or not the sequences of objectives should be returned. Defaults to False
-
fanok.sdp.sdp.solve_full_sdp(Sigma: numpy.ndarray, mode: str = 'equi', return_diag: bool = False, **kwargs)¶ Solves the SDP with one of the available methods (“equi”, “sdp”, “cvx”, “asdp”).
Parameters: - Sigma – Covariance matrix
- mode – Method to solve the SDP
- return_diag – Whether to return a diagonal matrix or not
(just the solution vector). Defaults to False.