uniform(graph: typing.Union[int, typing.Tuple[typing.Collection[typing.Hashable], typing.Collection[typing.Tuple[typing.Hashable, typing.Hashable]]], typing.Collection[typing.Tuple[typing.Hashable, typing.Hashable]], networkx.classes.graph.Graph], vartype: typing.Union[dimod.vartypes.Vartype, str, frozenset], low: float = 0, high: float = 1, cls: type = <class 'dimod.binary.binary_quadratic_model.BinaryQuadraticModel'>, seed: typing.Optional[int] = None) dimod.binary.binary_quadratic_model.BinaryQuadraticModel[source]

Generate a binary quadratic model with random biases and offset.

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

  • 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

    Variable type for the BQM. Accepted input values:

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

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

  • low – The low end of the range for the random biases.

  • high – The high end of the range for the random biases.

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

  • seed – Random seed.


A binary quadratic model.