dimod.generators.uniform

uniform(graph, vartype, low=0.0, high=1.0, cls=<class 'dimod.binary_quadratic_model.BinaryQuadraticModel'>, seed=None)[source]

Generate a binary quadratic model with random biases and offset.

Biases and offset are drawn from a uniform distribution range (low, high).

Parameters
  • graph (int/tuple[nodes, edges]/list[edge]/Graph) – The graph to build the binary quadratic model (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.

  • vartype (Vartype/str/set) –

    Variable type for the BQM. Accepted input values:

    • Vartype.SPIN, 'SPIN', {-1, 1}

    • Vartype.BINARY, 'BINARY', {0, 1}

  • low (float, optional, default=0.0) – The low end of the range for the random biases.

  • high (float, optional, default=1.0) – The high end of the range for the random biases.

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

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

Returns

BinaryQuadraticModel