ran_r(r: int, graph: Union[int, Tuple[Collection[Hashable], Collection[Tuple[Hashable, Hashable]]], Collection[Tuple[Hashable, Hashable]], networkx.classes.graph.Graph], cls: type = <class 'dimod.binary.binary_quadratic_model.BinaryQuadraticModel'>, seed: Optional[int] = None) dimod.binary.binary_quadratic_model.BinaryQuadraticModel[source]

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 – Order of the RANr problem.

  • 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.

  • cls – Binary quadratic model class to build from. Default is BinaryQuadraticModel.

  • seed – Random seed.


A binary quadratic model.


>>> 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())

James King, Sheir Yarkoni, Mayssam M. Nevisi, Jeremy P. Hilton, Catherine C. McGeoch. Benchmarking a quantum annealing processor with the time-to-target metric. https://arxiv.org/abs/1508.05087