Open arcondello opened 1 year ago
It would be useful sometimes to be able to "embed" a sampleset. Something like
import numpy as np def embed_sampleset(sampleset, embedding, *, num_qubits=None, fill_value=2): if num_qubits is None: num_qubits = max(max(chain) for chain in embedding.values()) + 1 num_samples = len(sampleset) samples = np.full((num_samples, num_qubits), fill_value) for i, v in enumerate(sampleset.variables): for c in embedding[v]: samples[:, c] = sampleset.record.sample[:, i] return samples if __name__ == '__main__': import dimod from dwave.system import DWaveSampler, EmbeddingComposite bqm = dimod.generators.gnm_random_bqm(100, 1000, "SPIN") sampleset = EmbeddingComposite(DWaveSampler()).sample(bqm, return_embedding=True, num_reads=100, answer_mode="raw") embedding = sampleset.info["embedding_context"]["embedding"] unembedded_samples = embed_sampleset(sampleset, embedding)
It would be useful sometimes to be able to "embed" a sampleset. Something like