node-red-quantum / node-red-contrib-quantum

Quantum computing functionality for Node-RED
https://node-red-quantum.github.io/
Apache License 2.0
16 stars 2 forks source link

Simplify quantum circuit initialisation process #112

Closed bbaayezi closed 3 years ago

bbaayezi commented 3 years ago

Enhancement Description

The following statements references to @Theo-Reignier

When I first wrote the register node js files, I had to convey 2 validations:

  1. Ensure all registers are initialized before running qc = QuantumCircuit
  2. Ensure all register nodes have finished running before quantum registers output qubit objects Now, here is an animation that illustrates the order of execution of the nodes in Node-RED: https://nodered.org/blog/content/images/2019/08/flow2-async.svg

Following the order of execution, I think these 2 validations can be simplified a lot:

  1. The last output of 'QuantumCircuit' will be the last register to be initialized. Therefore, we can just pass a variable to the last output of 'QuantumCircuit' that tells the 'register' node to initialize qc .
  2. The second validation is not even required anymore, the qubits objects will always be evaluated after the register nodes & qc are all initialized.