dimod.generators.power_r#

power_r(r: int, graph: int | tuple[Collection[Hashable], Collection[tuple[Hashable, Hashable]]] | Collection[tuple[Hashable, Hashable]] | Graph, *, seed: None | int | Generator = None) → BinaryQuadraticModel[source]#

Generate an Ising model for a POWERr problem.

In POWERr problems all linear biases are zero and quadratic values are integers between -r to r, excluding zero. Quadratic values are distributed as a power-law, inversely proportional to their magnitude \(P(value) \propto 1/|value|\). As a result, values with small magnitude appear in higher frequency than values with large magnitude.

This class of problems is relevant for binary quadratic models (BQM) with spin variables (Ising models).

Parameters:
  • r – Order of the POWERr 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.

  • seed – Seed for the random number generator. Passed to numpy.random.default_rng().

Returns:

A binary quadratic model.