ran_r(r, graph, cls=<class 'dimod.binary_quadratic_model.BinaryQuadraticModel'>, seed=None)¶
Generate an Ising model for a RANr problem.
In RANr problems all linear biases are zero and quadratic values are uniformly selected integers between -r to r, excluding zero. This class of problems is relevant for binary quadratic models (BQM) with spin variables (Ising models).
This generator of RANr problems follows the definition in [Kin2015].
r (int) – Order of the RANr problem.
graph (int/tuple[nodes, edges]/list[edge]/
Graph) – The graph to build the bqm on. Either an integer n, interpreted as a complete graph of size n, a nodes/edges pair, a list of edges or a NetworkX graph.
seed (int, optional, default=None) – Random seed.
>>> import networkx as nx >>> K_7 = nx.complete_graph(7) >>> bqm = dimod.generators.random.ran_r(1, K_7) >>> max(bqm.quadratic.values()) == -min(bqm.quadratic.values()) True