# Submitting a Problem to the D-Wave System¶

This section shows what it looks like to use the Ocean software to submit an exactly-one-true problem and output the states returned. It assumes that you have already defined a problem that can be expressed on the working graph; see the preceding sections to see how to get to this point.

Before you can submit a problem to the system, you must have an account and an API token; visit Leap to sign up for an account and get your token.

Note

The example that follows assumes that the requisite information for problem submission through SAPI has been configured. This is typically done as a first step when you install the Ocean SDK. For more information, including Ocean SDK installation instructions and detailed examples, see the Ocean software documentation.

## Submit the Problem¶

When you submit a problem, you can either minor-embed it onto the Chimera topology manually, or use the Ocean tools to determine a minor-embedding automatically for you.

### Manual Minor-Embedding¶

Because we previously worked out an embedding for a system with the necessary qubits present, we can directly set qubits on the QPU. In the Automated Minor-Embedding section, we use an Ocean software tool to automate the minor-embedding so we can submit the problem using the original QUBO variables.

>>> from dwave.system import DWaveSampler
>>> sampler_manual = DWaveSampler(solver={'qpu': True})
>>> # Set Q for the minor-embedded problem QUBO
>>> qubit_biases = {(0, 0): 0.3333, (1, 1): -0.333, (4, 4): -0.333, (5, 5): 0.333}
>>> coupler_strengths = {(0, 4): 0.667, (0, 5): -1, (1, 4): 0.667, (1, 5): 0.667}
>>> Q = dict(qubit_biases)
>>> Q.update(coupler_strengths)
>>> # Sample once on a D-Wave system and print the returned sample
>>> print(sampleset.first.sample)
{0: 1, 1: 0, 4: 0, 5: 1}


Note

Because the yield of a working graph is typically less than the total number of qubits and couplers that are fabricated and physically present in a QPU, we must first verify that the qubits we selected are active. For example, to check the qubits in the first unit cell:

>>> print(sampler_manual.nodelist[0:8])
[0, 1, 2, 3, 4, 5, 6, 7]


Likewise for the selected couplers. If any are inactive, we can use a different unit cell.

### Automated Minor-Embedding¶

The Ocean software can accept problems defined with the QUBO or Ising variables by heuristically finding a minor-embedding.

>>> from dwave.system import DWaveSampler, EmbeddingComposite
>>> sampler_auto = EmbeddingComposite(DWaveSampler(solver={'qpu': True}))
>>> # Set Q for the problem QUBO
>>> linear = {('x0', 'x0'): -1, ('x1', 'x1'): -1, ('x2', 'x2'): -1}
>>> quadratic = {('x0', 'x1'): 2, ('x0', 'x2'): 2, ('x1', 'x2'): 2}
>>> Q = dict(linear)
>>> # Minor-embed and sample 1000 times on a default D-Wave system
>>> print(sampleset)
x0 x1 x2 energy num_oc. chain_.
0  0  0  1   -1.0     293     0.0
1  1  0  0   -1.0     445     0.0
2  0  1  0   -1.0     261     0.0
3  0  1  1    0.0       1     0.0
['BINARY', 4 rows, 1000 samples, 3 variables]


Again in the results of 10000 reads, we see that the lowest energy occurs for the 3 valid states for our problem. Although 4 unique states are returned, the lowest energy occurs for the 3 valid states, which are the most frequent solution (num_oc, the number of occurrences of a returned state, are in the hundreds).

## Check the Solution¶

Let’s take a look at the solution of the manually embedded submission, mapping it back to the variables in our original problem. We have a valid solution to the exactly-one-true problem: $a$ and $c$ are FALSE; $b$ is TRUE. Both of the chained qubits, 0 and 5, return the same value.

 Variables b c a b Qubit 0 1 4 5 Returned Values 1 0 0 1

## Increase the Number of Reads¶

Here, we increase the number of reads of the manually embedded submission to 10,000. Increasing the number of reads usually returns more variation in the returned solutions.

>>> sampleset = sampler_manual.sample_qubo(Q, num_reads=1000)
>>> print(sampleset)
0  1  4  5  energy num_oc.
0  1  0  0  1 -0.3337    3002
1  0  0  1  0  -0.333    3266
2  0  1  0  0  -0.333    3720
3  0  0  0  0     0.0       1
4  0  0  1  1     0.0       3
5  1  1  0  1  0.0003       2
6  1  0  1  1  0.0003       2
7  1  1  0  0  0.0003       2
8  0  1  1  0   0.001       2
['BINARY', 9 rows, 10000 samples, 4 variables]


In the results of 10,000 reads, we can see that the lowest energy occurs for the 3 valid states for our problem, which are by far the most frequent solution. Although there are only 3 valid answers to our 3-variable exactly-one-true problem, additional, higher-energy states are returned. Returning a range of solutions is useful for sampling problems.