Problem 4: Find the Number of Ground States for a Two-Qubit System



  • According your DWave API this is the outcome:

    x0 = 1 |  x1 = 0 | Energy = -0.200000 | Probability = 41.300000 %
    x0 = 0 | x1 = 1 | Energy = -0.200000 | Probability = 58.700000 %

    Here is the code:
    @Edit: PS Thanks and Credits to Yasas for the DWave Problem3 code kindly posted that led me into the Python API properly. If the answer is right, I'll split the first place with you mate :)

    # Calogero Zarbo, Docebo, 09-Feb-2019
    # D-Wave Challenge 4

    from dwave.system.samplers import DWaveSampler
    from dwave.system.composites import EmbeddingComposite
    import dimod

    shots = 1000
    linear = {1: q0, 2: q1}
    quadratic = {(1, 2): q01}
    bqm = dimod.BinaryQuadraticModel(linear, quadratic, 0.0, dimod.BINARY)

    sampler = EmbeddingComposite(DWaveSampler())
    response = sampler.sample(bqm, num_reads=shots)

    for res in['sample', 'energy', 'num_occurrences']):
    print('|x0 = %s |x1 = %s | Energy = %f | Probability = %f %% ' % (res.sample[1],res.sample[2],, res.num_occurrences*100/shots))
    Comment actions Permalink
  • Good job Calogero!

    I got the same. 

    Answer: Two ground states. 

    Bonus Answer: This represents a NOT gate.

    In the below code, I tried the manual embedding as explained in D-Wave documentation as well as automatic embedding. Each method gave the same results. 

    For manual embedding, I used q-bits 0 and 1. However, as the unit cell architecture q-bits 0 and 1 does not have a physical coupling link. Then, how does the code work?



    Comment actions Permalink
  • Hello Yasas,

    I think I can answer your embedding question without spoiling the challenge for others.

    I noticed you used EmbeddingComposite in all your methods. EmbeddingComposite actually does the embedding step automatically, so it allows the user to enter qubits and connections that does not necessarily match the structure of the QPU.

    It is actually possible to sample the QPU directly with DWaveSampler - in this case your qubits and connectors need to match the QPU's structure.

    Comment actions Permalink
  • Thanks for posting your answers Calogero and Yasas!  You are both correct: the answer is 2 ground states.

    Please now try your hand at solving Problem 5, just posted. 

    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post