unique qubit name generator?
I am writing a function that builds a combinational logic circuit using gates provided by dwavebinarycsp.factories.constraint.gates. The circuit has internal interconnections that are of no interest to the caller. The function has to choose names for the qubits representing those internal interconnections, and there is a risk that the caller might inadvertently use those same names for other qubits. Is there a unique qubit name generator that my function could use?
For the moment, I am dealing with this by letting the caller provide a stem to which the function appends suffixes to create qubit names. The caller is responsible for not using the stem to name other qubits. I think this will work OK, but I am a little bit uncomfortable with it, and I would like to hear what others think.
Comments
Hi Scott,
We don’t have anything like a unique name generator, however it is pretty easy to write one in Python using native libraries.
You could randomly generate a unique prefix.
Here is a code example:
import uuid
str(uuid.uuid1())
Here is a link to the documentation for the uuid library:
https://tools.ietf.org/html/rfc4122.html
You could also use the QPU as a random number generator:
https://support.dwavesys.com/hc/en-us/community/posts/360023214893-Random-number-gerator-on-a-d-wave-system
As a side note, I wanted to mention to be wary that allowing constraint violations to be introduced can cause problems to arise.
The gap size of a problem is dependent on the problem as a whole, so letting someone introduce variables could throw off the balance of your carefully crafted solution.
Gap size is briefly discussed in this community post:
https://support.dwavesys.com/hc/en-us/community/posts/360028712154
Thank you, David.
Please sign in to leave a comment.