dimod.SampleSet.from_samples_bqm¶
-
classmethod
SampleSet.from_samples_bqm(samples_like, bqm, **kwargs)[source]¶ Build a sample set from raw samples and a binary quadratic model.
The binary quadratic model is used to calculate energies and set the
vartype.Parameters: - samples_like – A collection of raw samples. ‘samples_like’ is an extension of NumPy’s array_like.
See
as_samples(). - bqm (
BinaryQuadraticModel) – A binary quadratic model. - info (dict, optional) – Information about the
SampleSetas a whole formatted as a dict. - num_occurrences (array_like, optional) – Number of occurrences for each sample. If not provided, defaults to a vector of 1s.
- aggregate_samples (bool, optional, default=False) – If True, all samples in returned
SampleSetare unique, with num_occurrences accounting for any duplicate samples in samples_like. - sort_labels (bool, optional, default=True) – Return
SampleSet.variablesin sorted order. For mixed (unsortable) types, the given order is maintained. - **vectors (array_like) – Other per-sample data.
Returns: Examples
>>> bqm = dimod.BinaryQuadraticModel.from_ising({}, {('a', 'b'): -1}) >>> samples = dimod.SampleSet.from_samples_bqm({'a': -1, 'b': 1}, bqm)
- samples_like – A collection of raw samples. ‘samples_like’ is an extension of NumPy’s array_like.
See