Issue with Factoring with D-Wave Quantum Computers example
Hello
I have tried to factor numbers other than the "21" given in the example given in the Jupyter Notebook and got wrong answers. I tried 22 and 24.
Did anyone encounter something similar?
Thanks
Comments
Nasser,
The factoring example in the Notebook is set up as a CSP for a multiplication circuit for multiplying two 3-bit numbers. Since 22 and 24 have factors which need more than 3 bits (that is outside the range 0-7), it cannot return a correct solution.
To try factoring other numbers, increase the number of bits in the multiplicands (a and b) and the product (p).
I hope this helps answer your question.
Ed
Thank you very much. But I tested it with 4bits and it always gave bad results.
This is the whole code:
Thanks again.
Thanks for including your code. From that, I can see the problem is not in your code in the main notebook. The extra bits (a3, b3) for handling 4-bit multiplicands also need to be added in the to_base_ten function in convert.py. Your sampler was finding the correct solution, but it was being printed incorrectly.
Also, contrary to what the notebook says, I found I needed to increase the num_reads from the value of 100 to 1000 to make it more likely I would get a correct solution in the sample.
If this does not solve it for you, please let us know what results you are seeing.
Ed
Thanks a lot. It finally worked. I defined and changed the convert function and increased the number of reads function in the code:
You were of great help.
Please sign in to leave a comment.