DwaveTranslator ¶
Utility class for converting between a DWAVE solution and our solution format.
DWaveSolutionTranslator provides methods to: - Convert a dimod-style solution into our solution Solution.
The conversions are especially required when interacting with external dwave/dimod solvers/samplers or libraries that operate on dwave/dimod-based problem-solving/ sampling.
Examples:
>>> import dimod
>>> import luna_quantum as lq
>>> dwave_sampleset = ...
>>> aqs = lq.translator.DwaveTranslator.to_aq(dwave_sampleset)
to_aq staticmethod ¶
to_aq(sample_set: SampleSet) -> Solution
to_aq(sample_set: SampleSet, *, env: Environment) -> Solution
to_aq(sample_set: SampleSet, timing: Timing, *, env: Environment) -> Solution
to_aq(
sample_set: SampleSet,
timing: Timing | None = ...,
*,
env: Environment | None = ...,
) -> Solution
Convert a DWave SampleSet to our solution format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_set | SampleSet | The SampleSet returned by a DWave solver. | required |
timing | Timing | The timing object produced while generating the result. | ... |
env | Environment | The environment of the model for which the result is produced. | ... |
Raises:
| Type | Description |
|---|---|
NoActiveEnvironmentFoundError | If no environment is passed to the method or available from the context. |
SolutionTranslationError | Generally if the solution translation fails. Might be specified by one of the two following errors. |
SampleIncorrectLengthError | If a solution's sample has a different number of variables than the model environment passed to the translator. |
SampleUnexpectedVariableError | If the sample_set contains variables that are not contained in the passed environment. |
ModelVtypeError | If the result's variable types are incompatible with the model environment's variable types. |