dimod.generators.ran_r

ran_r(r, graph, cls=<class 'dimod.binary_quadratic_model.BinaryQuadraticModel'>, seed=None)[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].

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

  • cls (type, optional) – Binary quadratic model class to build from. Default is BinaryQuadraticModel.

  • seed (int, optional, default=None) – Random seed.

Returns

BinaryQuadraticModel.

Examples:

>>> 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
Kin2015

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