:py:mod:`omnisolver.pt.bqm_tools` ================================= .. py:module:: omnisolver.pt.bqm_tools .. autoapi-nested-parse:: Helper functions for converting BQM into a more PT friendly representation. Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: omnisolver.pt.bqm_tools.vectorize_bqm omnisolver.pt.bqm_tools.adjacency_list_from_couplings .. py:function:: vectorize_bqm(bqm: dimod.BQM) -> Tuple[numpy.ndarray, numpy.ndarray] Convert BQM into dense vector of biases and matrix of couplings. .. warning:: This function assumes that variables are labelled 0,...,N-1, otherwise it will behave unexpectedly. :param bqm: Binary Quadratic Model to be vectorized :return: A tuple (h_vec, j_mat) comprising vector of biases and a matrix of quadratic coefficients. Missing biases and couplings are set to 0. .. py:function:: adjacency_list_from_couplings(j_mat: numpy.ndarray) -> Tuple[numpy.ndarray, numpy.ndarray] Produce adjacency-list representation of given Ising graph. :param j_mat: symmetric matrix of Ising model couplings. :return: a tuple (adjacency_list, neighbours_count) such that: - neighbours_count.shape == (N,) and neighbours_count[i] contains number of neighbours of i-th spin - adjacency_list.shape == (N, max(neighbours_count)) and adjacency_list[i, j] is i-th spin j-th neighbour (for j < neighbours_count[j]