PenaltyModelCache.retrieve(samples_like, graph_like, *, linear_bound: Tuple[float, float] = (-2, 2), quadratic_bound: Tuple[float, float] = (-1, 1), min_classical_gap: float = 2) Tuple[BinaryQuadraticModel, float][source]#

Retrieve a penalty model from the database.

  • samples_like

    The set of feasible states that form the ground states of the generated binary quadratic model.

    ’samples_like’ is an extension of NumPy’s array_like. See dimod.as_samples().

  • graph_like

    Defines the structure of the desired binary quadratic model. Each node in the graph represents a variable and each edge defines an interaction between two variables. Can be given as a networkx.Graph, a int, or as a sequence of variable labels.

    If given as a sequence of labels, the structure will be fully-connected, with the variables labelled according to the sequence.

    If given as an int, the structure will be fully-connected with the variables labelled range(n).

    The nodes of the graph must be a superset of the labels of samples_like.

    If not provided, defaults to a fully connected graph with nodes that are the variables of samples_like.

  • linear_bound – The range allowed for the linear biases of the binary quadratic model.

  • quadratic_bound – The range allowed for the quadratic biases of the binary quadratic model.

  • min_classical_gap – This is a threshold value for the classical gap. It describes the minimum energy gap between the highest feasible state and the lowest infeasible state.


A 2-tuple of the binary quadratic model and the classical gap. Note that the binary quadratic model always has vartype 'SPIN'.