dimod.generators.ran_r#
- ran_r(r: int, graph: int | Tuple[Collection[Hashable], Collection[Tuple[Hashable, Hashable]]] | Collection[Tuple[Hashable, Hashable]] | Graph, cls: None = None, seed: int | None = None) 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
tor
, 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 – Order of the RANr problem.
graph – 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 – Deprecated. Does nothing.
seed – Random seed.
- Returns:
A binary quadratic model.
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
Deprecated since version 0.10.13: The
cls
keyword argument will be removed in 0.12.0. It currently does nothing.