omnisolver.pt.bqm_tools#

Helper functions for converting BQM into a more PT friendly representation.

Module Contents#

Functions#

vectorize_bqm(→ Tuple[numpy.ndarray, numpy.ndarray])

Convert BQM into dense vector of biases and matrix of couplings.

adjacency_list_from_couplings(→ Tuple[numpy.ndarray, ...)

Produce adjacency-list representation of given Ising graph.

omnisolver.pt.bqm_tools.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.

Parameters:

bqm – Binary Quadratic Model to be vectorized

Returns:

A tuple (h_vec, j_mat) comprising vector of biases and a matrix of quadratic coefficients. Missing biases and couplings are set to 0.

omnisolver.pt.bqm_tools.adjacency_list_from_couplings(j_mat: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray]#

Produce adjacency-list representation of given Ising graph.

Parameters:

j_mat – symmetric matrix of Ising model couplings.

Returns:

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]