# dwave.embedding.chain_breaks.MinimizeEnergy¶

class MinimizeEnergy(bqm, embedding)[source]

Unembed samples by minimizing local energy for broken chains.

Parameters
• bqm (`BinaryQuadraticModel`) – Binary quadratic model associated with the source graph.

• embedding (dict) – Mapping from source graph to target graph as a dict of form {s: [t, …], …}, where s is a source-model variable and t is a target-model variable.

Examples

This example embeds from a triangular graph to a square graph, chaining target-nodes 2 and 3 to represent source-node c, and unembeds minimizing the energy for the samples. The first two sample have unbroken chains, the second two have broken chains.

```>>> import dimod
>>> import numpy as np
...
>>> h = {'a': 0, 'b': 0, 'c': 0}
>>> J = {('a', 'b'): 1, ('b', 'c'): 1, ('a', 'c'): 1}
>>> embedding = {'a': [0], 'b': [1], 'c': [2, 3]}
>>> cbm = dwave.embedding.MinimizeEnergy(bqm, embedding)
>>> samples = np.array([[+1, -1, +1, +1],
...                     [-1, -1, -1, -1],
...                     [-1, -1, +1, -1],
...                     [+1, +1, -1, +1]], dtype=np.int8)
>>> chains = [embedding['a'], embedding['b'], embedding['c']]
>>> unembedded, idx = cbm(samples, chains)
>>> unembedded
array([[ 1, -1,  1],
[-1, -1, -1],
[-1, -1,  1],
[ 1,  1, -1]], dtype=int8)
>>> idx
array([0, 1, 2, 3])
```
__init__(bqm, embedding)[source]

Methods

 `__init__`(bqm, embedding)