dimod.generators.gnm_random_bqm#

gnm_random_bqm(variables: int | Sequence[Hashable], num_interactions: int, vartype: Vartype | str | frozenset, *, cls: None = None, random_state: RandomState | int | None = None, bias_generator: Callable[[int], Sequence[float | floating | integer]] | None = None) BinaryQuadraticModel[source]#

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

Parameters:
  • 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.

Returns:

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.