gnm_random_bqm(variables: Union[int, Sequence[Hashable]], num_interactions: int, vartype: Union[dimod.vartypes.Vartype, str, frozenset], *, cls: None = None, random_state: Optional[Union[numpy.random.mtrand.RandomState, int]] = None, bias_generator: Optional[Callable[[int], Sequence[Union[float, numpy.floating, numpy.integer]]]] = None) dimod.binary.binary_quadratic_model.BinaryQuadraticModel[source]

Generate a random binary quadratic model with a fixed number of variables and interactions.

  • variables – Variable labels. If an int, variables are labelled [0, variables ).

  • num_interactions – The number of interactions.

  • vartype

    Variable type for the BQM. Accepted input values:

  • cls – Deprecated. Does nothing.

  • random_state – Random seed or a random state generator. Used for generating the structure of the BQM and, if bias_generator is not given, for the bias generation.

  • bias_generator – Bias generating function. Should accept a single argument n and return an ndarray of biases of length n. May be called multiple times. If not provided, uniform() is used by default.


A binary quadratic model.

Deprecated since version 0.10.13: The cls keyword argument will be removed in 0.12.0. It currently does nothing.