CN115438791A - Method and device for solving Bayesian network based on quantum line - Google Patents

Method and device for solving Bayesian network based on quantum line Download PDF

Info

Publication number
CN115438791A
CN115438791A CN202110627291.7A CN202110627291A CN115438791A CN 115438791 A CN115438791 A CN 115438791A CN 202110627291 A CN202110627291 A CN 202110627291A CN 115438791 A CN115438791 A CN 115438791A
Authority
CN
China
Prior art keywords
quantum
bayesian network
nodes
node
constructing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110627291.7A
Other languages
Chinese (zh)
Inventor
窦猛汉
李叶
刘焱
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Origin Quantum Computing Technology Co Ltd
Original Assignee
Origin Quantum Computing Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Origin Quantum Computing Technology Co Ltd filed Critical Origin Quantum Computing Technology Co Ltd
Priority to CN202110627291.7A priority Critical patent/CN115438791A/en
Publication of CN115438791A publication Critical patent/CN115438791A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena

Landscapes

  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Condensed Matter Physics & Semiconductors (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Artificial Intelligence (AREA)
  • Complex Calculations (AREA)

Abstract

The invention discloses a method and a device for solving a Bayesian network based on quantum wires, wherein the method comprises the following steps: receiving and responding to the editing operation of the Bayesian network aiming at the target system, and displaying the edited Bayesian network; receiving and responding to the calculation operation aiming at the Bayesian network, and constructing quantum wires corresponding to the Bayesian network; and operating the quantum circuit, and outputting and displaying the probability distribution of the nodes of the Bayesian network. By utilizing the embodiment of the invention, the quantum computation mode of the Bayesian network can be realized, the computation complexity of the Bayesian network is reduced, the high-efficiency computation is realized, and the processing supporting a large-scale multi-node network model is realized by utilizing the superposition characteristic of quantum states with less storage and computation resources.

Description

Method and device for solving Bayesian network based on quantum line
Technical Field
The invention belongs to the technical field of quantum computation, and particularly relates to a method and a device for solving a Bayesian network based on quantum wires.
Background
Quantum computers are physical devices that perform high-speed mathematical and logical operations, store and process quantum information in compliance with the laws of quantum mechanics. When a device processes and calculates quantum information and runs quantum algorithms, the device is a quantum computer. Quantum computers are a key technology under study because they have the ability to handle mathematical problems more efficiently than ordinary computers, for example, they can speed up the time to break RSA keys from hundreds of years to hours.
The Bayesian network is a probabilistic graph model and is suitable for solving a specific type of complex random system, and the complex random system is assumed to have a plurality of key factor nodes, most nodes have no direct causal relationship, the causal relationship among the directly related nodes is unidirectional, and no node capable of advancing back to the complex random system along the unidirectional causal relationship exists. However, the existing bayesian network technology can only solve the problem that the complex random system is not displayed intuitively enough, the computation complexity of probability solution in the system cannot be reduced, and the computation complexity of data amount of the existing classical bayesian network technology increases exponentially with the increase of the number of nodes of the complex random system, so that the problem of large scale processing is difficult.
Based on this, it is necessary to implement a quantum computation method of a bayesian network to solve the deficiencies in the prior art.
Disclosure of Invention
The invention aims to provide a method and a device for solving a Bayesian network based on quantum lines, which are used for solving the defects in the prior art, can reduce the computational complexity of the Bayesian network, realize high-efficiency computation, and utilize the superposition characteristic of quantum states, thereby realizing the processing supporting a large-scale multi-node network model with less storage and computation resources.
One embodiment of the present application provides a method of solving a bayesian network based on quantum wires, the method comprising:
receiving and responding to the editing operation of the Bayesian network aiming at the target system, and displaying the edited Bayesian network;
receiving and responding to the calculation operation aiming at the Bayesian network, and constructing quantum lines corresponding to the Bayesian network;
and operating the quantum wires, and outputting and displaying the probability distribution of the nodes of the Bayesian network.
Optionally, the receiving and responding to an editing operation of the bayesian network for the target system and displaying the edited bayesian network includes:
receiving and responding to selection operation aiming at a preset system or a self-defined system, and displaying an initial Bayesian network corresponding to the selected system in an editing area;
and receiving and responding to the editing operation aiming at the initial Bayesian network, and displaying the edited Bayesian network.
Optionally, the constructing a quantum wire corresponding to the bayesian network includes:
acquiring each node contained in the Bayesian network and causal relationship among the nodes; wherein the causal relationship comprises: conditional probability between nodes;
constructing, for a root node of the respective nodes, a first sub-quantum wire that prepares a superposition state of qubits, wherein a node corresponds to one or a group of qubits, the superposition state comprising: each state of the root node and its probability distribution;
respectively constructing second sub-quantum lines which correspond to the causal relationship and are used for coding the conditional probability for every two nodes with the causal relationship in each node;
and obtaining the quantum wires corresponding to the Bayesian network according to the first sub quantum wire and the second sub quantum wire.
Optionally, the constructing, for a root node in the respective nodes, a first sub-quantum wire for preparing a superposition state of qubits includes:
determining the number of quantum bits required for coding the state of the root node as a first number and a preset number of quantum logic gates as a second number according to the number of the states of the root node;
determining parameters of the preset quantum logic gate according to the probability distribution of the root node;
and constructing a first sub-quantum line for encoding the state of the root node and the probability distribution thereof according to the first number of quantum bits, the second number of preset quantum logic gates and the parameters of the preset quantum logic gates.
Optionally, the constructing, for each two nodes having a causal relationship among the nodes, a second sub-quantum line corresponding to the causal relationship and used for encoding the conditional probability includes:
determining a cause node and an effect node in the two nodes with causal relationship;
respectively constructing quantum logic gate combinations which are applied to the result nodes when the reason nodes take different states;
and constructing a second sub-quantum circuit corresponding to the causal relationship according to the quantum logic gate combination and the conditional probability between the reason node and the result node.
Optionally, the operating the quantum wires and outputting and displaying the probability distribution of the nodes of the bayesian network includes:
and operating the quantum circuit, measuring the quantum bit of the node corresponding to the Bayesian network in the quantum circuit, and obtaining and displaying the probability distribution of the node.
Optionally, the method further includes: and outputting and displaying the state of the target system and the probability thereof.
Yet another embodiment of the present application provides an apparatus for solving a bayesian network based on quantum wires, the apparatus comprising:
the first display module is used for receiving and responding to the editing operation of the Bayesian network aiming at the target system and displaying the edited Bayesian network;
the receiving and constructing module is used for receiving and responding to the calculation operation aiming at the Bayesian network and constructing the quantum line corresponding to the Bayesian network;
and the second display module is used for operating the quantum lines and outputting and displaying the probability distribution of the nodes of the Bayesian network.
A further embodiment of the application provides a storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the method of any of the above when executed.
Yet another embodiment of the present application provides an electronic device, comprising a memory having a computer program stored therein and a processor configured to execute the computer program to perform the method described in any of the above.
Compared with the prior art, the method for solving the Bayesian network based on the quantum wires, provided by the invention, receives and responds to the editing operation of the Bayesian network aiming at the target system, and displays the edited Bayesian network; receiving and responding to the calculation operation aiming at the Bayesian network, and constructing quantum wires corresponding to the Bayesian network; the quantum circuit is operated, the probability distribution of the nodes of the Bayesian network is output and displayed, so that a quantum computing mode of the Bayesian network is realized, the computing complexity of the Bayesian network can be reduced, high-efficiency computing is realized, and the superposition characteristic of quantum states is utilized, so that the processing supporting a large-scale multi-node network model is realized with less storage and computing resources.
Drawings
Fig. 1 is a block diagram of a hardware structure of a computer terminal of a method for solving a bayesian network based on quantum wires according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a method for solving a bayesian network based on quantum wires according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a first sub-quantum circuit for encoding the state of a root node and its probability distribution according to an embodiment of the present invention;
FIG. 4 is a diagram of a first sub-quantum circuit for encoding the state of a root node and its probability distribution according to another embodiment of the present invention;
FIG. 5 is a schematic diagram of a causal relationship construction process quantum circuit between nodes according to an embodiment of the present invention;
FIG. 6 is a diagram of a second sub-quantum circuit corresponding to causal relationship between nodes according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a quantum circuit corresponding to a target network according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an apparatus for solving a bayesian network based on quantum wires according to an embodiment of the present invention.
Detailed Description
The embodiments described below with reference to the drawings are illustrative only and should not be construed as limiting the invention.
The embodiment of the invention firstly provides a method for solving a Bayesian network based on quantum wires, which can be applied to electronic equipment, such as computer terminals, specifically common computers, quantum computers and the like.
This will be described in detail below by way of example as it would run on a computer terminal. Fig. 1 is a block diagram of a hardware structure of a computer terminal of a method for solving a bayesian network based on quantum wires according to an embodiment of the present invention. As shown in fig. 1, the computer terminal may include one or more processors 102 (only one is shown in fig. 1) (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data, and optionally, may further include a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the computer terminal. For example, the computer terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store software programs and modules of application software, such as program instructions/modules corresponding to the method for implementing a bayesian network based on quantum wires in the embodiment of the present application, and the processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, so as to implement the method described above. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to a computer terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal. In one example, the transmission device 106 includes a Network adapter (NIC) that can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 can be a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
It should be noted that a true quantum computer is a hybrid structure, which includes two major components: one part is a classic computer which is responsible for executing classic calculation and control; the other part is quantum equipment which is responsible for running quantum programs so as to realize quantum computation. The quantum program is a string of instruction sequences which can run on a quantum computer and are written by quantum languages such as Qrun languages, so that the support on the operation of a quantum logic gate is realized, and the quantum computation is finally realized. In particular, a quantum program is a sequence of instructions that operate quantum logic gates in a time sequence.
In practical applications, due to the limited development of quantum device hardware, quantum computation simulation is usually required to verify quantum algorithms, quantum applications, and the like. The quantum computing simulation is a process of realizing the simulation operation of a quantum program corresponding to a specific problem by means of a virtual architecture (namely a quantum virtual machine) built by resources of a common computer. In general, it is necessary to build quantum programs for a particular problem. The quantum program referred by the embodiment of the invention is a program which is written in a classical language and used for representing quantum bits and evolution thereof, wherein the quantum bits, quantum logic gates and the like related to quantum computation are all represented by corresponding classical codes.
A quantum circuit, which is an embodiment of a quantum program and also a weighing sub-logic circuit, is the most common general quantum computation model, and represents a circuit that operates on a quantum bit under an abstract concept, and the circuit includes the quantum bit, a circuit (timeline), and various quantum logic gates, and finally, a result is often read through a quantum measurement operation.
Unlike conventional circuits that are connected by metal lines to pass either voltage or current signals, in quantum circuits, the lines can be viewed as being connected by time, i.e., the state of a qubit evolves naturally over time, in the process being operated on as indicated by the hamiltonian until a logic gate is encountered.
The quantum program refers to the total quantum wire, wherein the total number of quantum bits in the total quantum wire is the same as the total number of quantum bits of the quantum program. It can be understood that: a quantum program may consist of quantum wires, measurement operations for quantum bits in the quantum wires, registers to hold measurement results, and control flow nodes (jump instructions), and a quantum wire may contain tens to hundreds or even thousands of quantum gate operations. The execution process of the quantum program is a process executed for all the quantum logic gates according to a certain time sequence. It should be noted that timing is the time sequence in which the single quantum logic gate is executed.
It should be noted that in the classical calculation, the most basic unit is a bit, and the most basic control mode is a logic gate, and the purpose of the control circuit can be achieved through the combination of the logic gates. Similarly, the way qubits are handled is quantum logic gates. The quantum state can be evolved by using quantum logic gates, which are the basis for forming quantum circuits, including single-bit quantum logic gates, such as Hadamard gates (H gates, hadamard gates), pauli-X gates (X gates), pauli-Y gates (Y gates), pauli-Z gates (Z gates), RX gates, RY gates, RZ gates, and the like; multi-bit quantum logic gates such as CNOT gates, CR gates, isswap gates, toffoli gates, etc. Quantum logic gates are typically represented using unitary matrices, which are not only in matrix form, but also an operation and transformation. The function of a general quantum logic gate on a quantum state is calculated by multiplying a unitary matrix by a matrix corresponding to a quantum state right vector.
Quantum states, i.e. logical states of qubits, in quantaIn an algorithm (or quantum program) using binary representation, e.g. a group of qubits q 0 、q 1 、q 2 Represents the 0 th, 1 st and 2 nd quantum bits, and is ordered from the high order to the low order as q 2 q 1 q 0 The quantum states corresponding to the set of qubits have a total quantum bit count of 2 to the power of 2, which means 8 eigenstates (definite states): |000>、|001>、|010>、|011>、|100>、|101>、|110>、|111>The bits of each quantum state correspond to qubits, e.g. |000>State, 000 corresponds to q from high to low 2 q 1 q 0 ,|>Is a dirac symbol.
Illustrating the logic state of a single qubit in terms of a single qubit
Figure BDA0003102039940000071
May be at |0>State, |1>State, |0>Sum of states |1>The superposition state (uncertain state) of the states can be specifically expressed as
Figure BDA0003102039940000072
Where a and b are complex numbers representing the amplitude (magnitude of probability) of the quantum state, the square of the amplitude representing the probability, | a 2 、|b| 2 Represents |0>State, |1>Probability of state, | a 2 +|b| 2 In short, a quantum state is a superposed state composed of eigenstates, and is in a uniquely determined eigenstate when the probability of the other state is 0.
Referring to fig. 2, fig. 2 is a schematic flowchart of a method for solving a bayesian network based on quantum wires according to an embodiment of the present invention, where the method includes the following steps:
s201, receiving and responding to the editing operation of the Bayesian network aiming at the target system, and displaying the edited Bayesian network;
the Bayesian network is a probability graph model, is one of the most effective analysis models for the current uncertainty and probabilistic problems, can well represent a complex random system containing various condition control factors, and performs computational analysis and decision.
The Bayesian network has a plurality of nodes, most of the nodes have no direct causal relationship, the directly related causal relationship among the nodes is unidirectional, nodes which can advance to the Bayesian network along the unidirectional causal relationship do not exist, and a complex random system which can be discrete, sparse and has a unidirectional acyclic causal relationship can be displayed more intuitively.
Specifically, a selection operation for a preset system or a custom system may be received and responded, and an initial bayesian network corresponding to the selected system is displayed in the editing area; and receiving and responding to the editing operation aiming at the initial Bayesian network, and displaying the edited Bayesian network.
The target system may be a preset system, such as an oil stock price prediction system (assuming that the target system corresponds to a 4-node initial bayesian network), a bank liquidity risk assessment system (assuming that the target system corresponds to a 10-node initial bayesian network), or the like, or a custom system, in which no corresponding initial bayesian network exists (it can be understood that the initial bayesian network is empty), and may be edited and constructed by a user.
If the preset system is selected by the user, the corresponding initial Bayesian network can be displayed in the editable area of the terminal interface. For example, for a petroleum stock price presetting system, the corresponding initial network nodes include: bank interest rate, stock market quotation, oil stock price, the limit between the node includes:
bank interest rate → stock market quotation;
stock market → oil stock price;
oil market → oil stock prices;
wherein, the initial conditional probability of each node is also included; then, the initial conditional probability value can be modified in response to the editing operation of the initial conditional probability of the node, and the edited and modified bayesian network can be displayed.
If the user triggers and selects the user-defined system, no initial network can be displayed in the editing area, and editing function options for network construction, such as function buttons for adding nodes and the like, can be displayed. And editing nodes and edges of the Bayesian network by triggering the function options, and setting the conditional probability of the nodes, thereby generating and displaying the edited Bayesian network.
S202, receiving and responding to the calculation operation aiming at the Bayesian network, and constructing quantum lines corresponding to the Bayesian network;
specifically, after the bayesian network is edited, a calculation operation for the network may be triggered to solve the state of each node and its probability distribution. First, a quantum line corresponding to the bayesian network can be constructed to function as a quantum bayesian network equivalent to a bayesian network in the field of classical calculation. The function of equivalent solving can be achieved by operating the quantum Bayesian network. One preferred implementation of constructing the corresponding quantum wires is as follows:
s2021, acquiring each node contained in the Bayesian network and causal relationship among the nodes; wherein the causal relationship comprises: conditional probability between nodes;
specifically, the causal relationships among the nodes and the nodes included in the bayesian network may be obtained by first obtaining the causal relationships among all root nodes and non-root nodes in each node, where the causal relationships among the non-root nodes may include a directional relationship among the nodes and a conditional probability distribution of each state when the node includes several states.
Illustratively, a target network including four nodes a, B, C, and D is obtained, and the specific pointing relationship among the nodes is: a → B → C → D, where the root node A contains two states, each with a 50% probability. The above example only describes a plurality of states included in a node and a condition probability distribution condition of each state by using a root node, states included in other nodes and corresponding condition probability distributions are not expanded here, but it should be noted that the sum of the probability distributions corresponding to each node state is 1.
S2022, constructing a first sub-quantum line for preparing a superposition state of qubits for a root node of the respective nodes, wherein a node corresponds to one or a group of qubits, the superposition state comprising: each state of the root node and its probability distribution;
specifically, the first step of the first sub-quantum-line structure is to perform corresponding quantum bit initialization on all root nodes, that is, to complete the preparation of the superposition state of corresponding quantum bits according to the probability distribution of the root nodes, and specifically includes the following steps:
step A: and determining the number of quantum bits required for coding the state of the root node as a first number and a preset number of quantum logic gates as a second number according to the number of the states of the root node.
Specifically, from the number of states M of the root node, a first number M of qubits required can be determined, wherein,
Figure BDA0003102039940000091
wherein, the vertex angle bracket represents rounding up; according to the state number M of the root node, the required second number D of preset quantum logic gates can also be determined, wherein D = M-1.
And B, step B: and determining the parameters of the preset quantum logic gate according to the probability distribution of the root node.
Specifically, according to the probability distribution of the root node, the parameters of the preset quantum logic gate are determined, the used preset quantum logic gate is preferably a rotary logic gate RY, and the matrix form of the preset quantum logic gate RY is as follows:
Figure BDA0003102039940000092
the gate RY of the quantum logic gate realizes that:
RY(θ)|0>=cos(θ/2)|0>+sin(θ/2)|1>
and determining the parameter of the preset quantum logic gate, namely determining the parameter theta of the RY gate.
Illustratively, assume that there is a 4-state root node A, noted as
Figure BDA0003102039940000093
Where Σ p ij 2 =1,p ij 2 As root node AProbability of occurrence of the same state.
That is, the first number of qubits required to encode the state of the root node is 2, and the second number is preset to be 3. And assume that
Figure BDA0003102039940000094
Note the book
Figure BDA0003102039940000101
Figure BDA0003102039940000102
Therefore, the idea of the quantum line corresponding to the specific encoding root node is to always split the line from top to bottom, and implement the line by using a series of controlled revolving gates (controlled RY gates), and the specific implementation process includes:
firstly, the probabilities corresponding to the 4 states of the root node are equally divided into two groups, wherein one group is (P) 00 、P 01 ) The other group is (P) 10 、P 11 ). And coding the root of the square sum of the 2 probabilities of each group as an amplitude value to the amplitude of the quantum state of the first qubit to obtain a coded final state, namely:
Figure BDA0003102039940000103
at this time, after the first equipartition, by applying RY gate to the first qubit, that is:
Figure BDA0003102039940000104
it is possible to obtain,
Figure BDA0003102039940000105
that is to say that the position of the first electrode,by setting theta 1 The value of (3) can be obtained by the amplitude value coding described above, and the specific value of the rotation angle θ of the RY gate in the following figures can be determined in the same manner.
Continuing to perform the data splitting of the second step to obtain 4 groups of data, realizing amplitude encoding of 2 quantum bits and 4 quantum states in total, and obtaining:
Figure BDA0003102039940000106
Figure BDA0003102039940000107
and C: and constructing a first sub-quantum line for encoding the state of the root node and the probability distribution thereof according to the first number of quantum bits, the second number of preset quantum logic gates and the parameters of the preset quantum logic gates.
Specifically, following the above example, using 2 qubits and 3 preset quantum logic gates, i.e. specific values of the rotation angle θ of the confirmed RY gate, a first sub-quantum-circuit diagram of the state of the encoding root node and its probability distribution is obtained as shown in fig. 3. In order to vividly show the controlled condition of the RY gate of the quantum logic gate, the hollow circle in the figure of the application represents 0 control, and represents RY (theta) when the quantum state of the qubit is 0 2 ) Quantum logic gates are implemented; the solid black circle represents the 1 control, indicating RY (θ) when the quantum state of the qubit is 1 3 ) Quantum logic gates are implemented and the lines between the circles represent the controlled.
It should be noted that if the root node only includes 2 states, only one qubit is needed; if the root node contains more than 2 states, a group of qubits is needed, and in order to save computational resources, the specific number of the group of qubits is specifically determined according to the number of states.
For example, assuming that there is 8 state root node a, similarly, the first number of qubits required for encoding the states of the root node is 3, and the second number of preset quantum logic gates is 7, the specific implementation process includes:
the probabilities corresponding to the 8 states of the root node are divided into two groups, one group is (P) 000 、P 001 、P 010 、P 011 ) The other group is (P) 100 、P 101 、P 110 、P 111 ). And coding the root of the square sum of the 2 probabilities of each group as an amplitude value to the amplitude of the quantum state of the first qubit to obtain a coded final state, namely:
Figure BDA0003102039940000111
secondly, further splitting the two groups of data obtained in the step to obtain 4 groups of data, wherein each group has two data, namely (P) 000 、P 001 )、(P 010 、P 011 )、(P 100 、P 101 )、(P 110 、P 111 ) And 4 groups of data. The root of the sum of squares of each set of data is encoded as an amplitude value onto the 4 amplitudes of the first two qubits, respectively. Obtaining:
Figure BDA0003102039940000112
Figure BDA0003102039940000121
and finally, carrying out data splitting in the third step to obtain eight groups of data, realizing coding of 3 quantum bits and 8 quantum states in total, and obtaining:
|000>→P 000 |000>+P 001 |001>
|010>→P 010 |010>+P 011 |011>
|100>→P 100 |100>+P 101 |101>
|110>→P 110 |110>+P 111 |111>
at this time, after the third averaging, for the amplitude encoding of the eight-element vector, the final quantum state including the 8 quantum states encoded on the 3 qubits is output, and the parameter θ of the RY gate is output 1 To theta 7 Can be derived from the 2-bit, 4-state root example described above in a similar manner, resulting in another first sub-quantum-wire schematic diagram encoding the state of the root and its probability distribution as shown in fig. 4.
S2023, for each two nodes having a causal relationship among the nodes, respectively constructing a second sub-quantum line corresponding to the causal relationship and used for encoding the conditional probability;
specifically, the second sub quantum wires may be configured to play a role in corresponding causality and for encoding conditional probabilities, and a preferred configuration may include:
1, determining a cause node and an effect node in the two nodes with the causal relationship;
specifically, two nodes in all the nodes having a causal relationship are determined, that is, the two nodes have a unidirectional directional relationship and conditional probability, for example, if the node a points to the node B and the node B does not point to the node a, the node a and the node B are said to have a causal relationship, where a is a cause node and B is a result node.
2, respectively constructing quantum logic gate combinations which are applied to the result nodes when the reason nodes take different states;
for example, assuming that there is a M-state cause node a to determine 1K-state result node B in a single direction, the causal relationship between AB nodes can be decomposed into different amplitude encoding processes for B when a takes different states, so as to obtain a quantum circuit diagram of the inter-node causal relationship construction process provided in this embodiment as shown in fig. 5. The PreA block in the figure represents the initialization quantum wire associated with node A, and the A0B, A1B blocks and subsequent ellipses represent the quantum logic gate combinations that A applies to B in different states.
Fig. 4 shows only A0B when a =0 and A1B when a = 1. Each controlled quantum gate combination AiB (i is more than or equal to 0 and less than or equal to M-1) can be regarded as a small root node initialization amplitude coding quantum circuit, and the number of the controlled quantum gate combinations AiB is equal to the state number of the node A.
And 3, constructing a second sub-quantum circuit corresponding to the causal relationship according to the quantum logic gate combination and the conditional probability between the reason node and the result node.
Illustratively, a causal node a with 4 states determines 1 causal node B with 4 states in a unidirectional manner, and the causal relationship between AB nodes is decomposed into different amplitude encoding processes for B when a takes different states, respectively, so as to obtain a second sub-quantum-circuit diagram corresponding to the causal relationship between nodes as shown in fig. 6, where an A0B module represents the quantum logic gate combination that a applies to B in the first state, and the remaining A1B, A2B, and A3B represent the quantum logic gate combination that a applies to B in the remaining different states.
It should be noted that the quantum logic gate combinations of the modules A0B and A1B, A2B and A3B are the same, and only the specific value and controlled state of the rotation angle θ of each RY gate are different.
S2024, obtaining a quantum line corresponding to the bayesian network according to the first sub-quantum line and the second sub-quantum line.
Specifically, the first sub-quantum wires and the second sub-quantum wires may be combined in sequence to obtain the quantum wires corresponding to the bayesian network. Each node corresponds to one or a group of qubits and each edge corresponds to a group of quantum logic gates.
Illustratively, following the above example, the first sub-quantum wire and the second sub-quantum wire representing the 4 states of the encoding root node and the probability distribution thereof are sequentially combined to obtain a quantum wire diagram corresponding to the target network as shown in fig. 7.
And S203, operating the quantum wires, and outputting and displaying the probability distribution of the nodes of the Bayesian network.
Specifically, a quantum line may be operated, and quantum bits corresponding to nodes of the bayesian network in the quantum line are measured to obtain and display probability distribution of the nodes. The result output of the quantum Bayesian network depends on the measurement of quantum bits in quantum wires, and the probability distribution of all or local network nodes can be obtained by measuring the quantum bit combination corresponding to all or local nodes.
Illustratively, continuing to take the petroleum stock price prediction system as an example, the edited states of each node of the network and their conditional probabilities are set as follows:
bank interest rate: low: 75%, high: 25 percent;
stock market quotation:
the bank interest rate is low, corresponding to the stock market quotation-bad: 30 percent, good: 70 percent;
the bank has high interest rate, corresponding to the stock market quotation-bad: 80%, good: 20 percent;
petroleum market conditions: bad: 60%, good: 40 percent;
oil stock price:
stock market price is bad, oil market price is bad, corresponding to oil stock price-low: 90%, high: 10 percent;
the stock market is bad in market quotation and good in petroleum quotation, and corresponds to the petroleum stock price-low: 50%, high: 50 percent;
good stock market behavior, bad petroleum market behavior, corresponding to petroleum stock price-low: 40%, high: 60 percent;
good stock market and good petroleum market, corresponding to the petroleum stock price-low: 20%, high: 80 percent.
By operating the quantum Bayesian network corresponding to the system, the node probability distribution of the global node is solved as follows:
bank interest rate: low: 75%, high: 25 percent;
stock market quotation: bad: 42.5%, good: 57.5 percent;
petroleum market conditions: bad: 60 percent, good: 40 percent;
oil stock price: low: 49.8%, high: 50.2 percent.
Specifically, the method may further include: and outputting and displaying the state of the target system and the probability thereof. For example, for an oil stock price prediction system, the maximum possible states of the system are: the bank interest rate is low, the stock market is good, the petroleum market is bad, the petroleum stock price is high, and the occurrence probability is as follows: 75% 70% 60% =18.9%; tracing the cause of the result; oil stocks are expensive, most likely due to: the bank interest rate is low, the stock market is good, the petroleum market is bad, the probability of occurrence is: 75%. 70%. 60% =31.5%.
In practical application, the secondary editing operation aiming at the current Bayesian network can be received through the secondary editing function button, the node, the edge and the conditional probability of the current Bayesian network are edited on the basis of the current Bayesian network, and the secondarily edited Bayesian network is displayed, so that further calculation and exploration of a related system are facilitated.
As can be seen, the edited bayesian network is displayed by receiving and responding to the editing operation of the bayesian network for the target system; receiving and responding to the calculation operation aiming at the Bayesian network, and constructing quantum lines corresponding to the Bayesian network; the quantum circuit is operated, the probability distribution of the nodes of the Bayesian network is output and displayed, so that a quantum computing mode of the Bayesian network is realized, the computing complexity of the Bayesian network can be reduced, high-efficiency computing is realized, and the superposition characteristic of quantum states is utilized, so that the processing supporting a large-scale multi-node network model is realized with less storage and computing resources.
Referring to fig. 8, fig. 8 is a schematic structural diagram of an apparatus for solving a bayesian network based on quantum wires according to an embodiment of the present invention, and the apparatus may include, corresponding to the flow shown in fig. 2:
a first display module 801, configured to receive and respond to an editing operation on a bayesian network of a target system, and display the edited bayesian network;
a receiving construction module 802, configured to receive and respond to a computation operation on the bayesian network, and construct a quantum wire corresponding to the bayesian network;
and a second display module 803, configured to run the quantum wires, and output and display a probability distribution of nodes of the bayesian network.
Specifically, the receiving and displaying module is specifically configured to:
receiving and responding to selection operation aiming at a preset system or a user-defined system, and displaying an initial Bayesian network corresponding to the selected system in an editing area;
and receiving and responding to the editing operation aiming at the initial Bayesian network, and displaying the edited Bayesian network.
Specifically, the receiving and constructing module includes:
the system comprises an acquisition unit, a judgment unit and a display unit, wherein the acquisition unit is used for acquiring each node contained in the Bayesian network and causal relationship among the nodes; wherein the causal relationship comprises: conditional probability between nodes;
a first constructing unit, configured to construct, for a root node of the respective nodes, a first sub-quantum line that prepares a superposition state of qubits, wherein a node corresponds to one or a group of qubits, the superposition state including: each state of the root node and its probability distribution;
a second constructing unit, configured to construct, for each two nodes having a causal relationship among the nodes, a second sub-quantum line corresponding to the causal relationship and used for encoding the conditional probability;
and the obtaining unit is used for obtaining the quantum wire corresponding to the Bayesian network according to the first sub-quantum wire and the second sub-quantum wire.
In particular, the first construction unit is specifically configured to:
determining the number of quantum bits required for coding the states of the root nodes as a first number and the number of preset quantum logic gates as a second number according to the number of the states of the root nodes;
determining parameters of the preset quantum logic gate according to the probability distribution of the root node;
and constructing a first sub-quantum line for encoding the state of the root node and the probability distribution thereof according to the first number of quantum bits, the second number of preset quantum logic gates and the parameters of the preset quantum logic gates.
Specifically, the second construction unit is specifically configured to:
determining a cause node and an effect node in the two nodes with causal relationship;
respectively constructing quantum logic gate combinations which are applied to the result nodes when the reason nodes take different states;
and constructing a second sub-quantum circuit corresponding to the causal relationship according to the quantum logic gate combination and the conditional probability between the reason node and the result node.
Specifically, the second display module is specifically configured to:
and operating the quantum circuit, measuring the quantum bit of the node corresponding to the Bayesian network in the quantum circuit, and obtaining and displaying the probability distribution of the node.
Specifically, the apparatus further comprises: and the third display module is used for outputting and displaying the state and the probability of the target system.
As can be seen, the edited bayesian network is displayed by receiving and responding to the editing operation of the bayesian network for the target system; receiving and responding to the calculation operation aiming at the Bayesian network, and constructing quantum lines corresponding to the Bayesian network; the quantum circuit is operated, the probability distribution of the nodes of the Bayesian network is output and displayed, so that the quantum computing mode of the Bayesian network is realized, the computing complexity of the Bayesian network can be reduced, the efficient computing is realized, and the superposition characteristic of quantum states is utilized, so that the processing supporting a large-scale multi-node network model is realized with less storage and computing resources.
An embodiment of the present invention further provides a storage medium, where a computer program is stored, where the computer program is configured to execute the steps in any one of the method embodiments described above when the computer program is run.
Specifically, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
s1, receiving and responding to an editing operation of a Bayesian network aiming at a target system, and displaying the edited Bayesian network;
s2, receiving and responding to the calculation operation aiming at the Bayesian network, and constructing quantum lines corresponding to the Bayesian network;
and S3, operating the quantum line, and outputting and displaying the probability distribution of the nodes of the Bayesian network.
An embodiment of the present invention further provides an electronic device, which includes a memory and a processor, where the memory stores a computer program, and the processor is configured to execute the computer program to perform the steps in any one of the method embodiments described above.
Specifically, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Specifically, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, receiving and responding to editing operation of a Bayesian network aiming at a target system, and displaying the edited Bayesian network;
s2, receiving and responding to the calculation operation aiming at the Bayesian network, and constructing quantum lines corresponding to the Bayesian network;
and S3, operating the quantum line, and outputting and displaying the probability distribution of the nodes of the Bayesian network.
The construction, features and functions of the present invention are described in detail in the embodiments illustrated in the drawings, which are only preferred embodiments of the present invention, but the present invention is not limited by the drawings, and all equivalent embodiments modified or changed according to the idea of the present invention should fall within the protection scope of the present invention without departing from the spirit of the present invention covered by the description and the drawings.

Claims (10)

1. A method for solving a bayesian network based on quantum wires, the method comprising:
receiving and responding to the editing operation of the Bayesian network aiming at the target system, and displaying the edited Bayesian network;
receiving and responding to the calculation operation aiming at the Bayesian network, and constructing quantum wires corresponding to the Bayesian network;
and operating the quantum wires, and outputting and displaying the probability distribution of the nodes of the Bayesian network.
2. The method of claim 1, wherein receiving and displaying the edited bayesian network in response to editing operations for the bayesian network of the target system comprises:
receiving and responding to selection operation aiming at a preset system or a self-defined system, and displaying an initial Bayesian network corresponding to the selected system in an editing area;
and receiving and responding to the editing operation aiming at the initial Bayesian network, and displaying the edited Bayesian network.
3. The method of claim 1, wherein constructing the quantum wires corresponding to the bayesian network comprises:
acquiring each node contained in the Bayesian network and causal relationship among the nodes; wherein the causal relationship comprises: conditional probability between nodes;
constructing, for a root node of the respective nodes, a first sub-quantum wire that prepares a superposition state of qubits, wherein a node corresponds to one or a group of qubits, the superposition state comprising: each state of the root node and its probability distribution;
respectively constructing second sub-quantum lines which correspond to the causal relationship and are used for coding the conditional probability for every two nodes with the causal relationship in each node;
and obtaining the quantum wire corresponding to the Bayesian network according to the first sub-quantum wire and the second sub-quantum wire.
4. The method of claim 3, wherein constructing a first sub-quantum wire that prepares a superposition state of qubits for a root node of the respective nodes comprises:
determining the number of quantum bits required for coding the state of the root node as a first number and a preset number of quantum logic gates as a second number according to the number of the states of the root node;
determining parameters of the preset quantum logic gate according to the probability distribution of the root node;
and constructing a first sub-quantum line for encoding the state of the root node and the probability distribution thereof according to the first number of quantum bits, the second number of preset quantum logic gates and the parameters of the preset quantum logic gates.
5. The method according to claim 4, wherein the constructing, for each two causal nodes in the respective nodes, a second sub-quantum wire corresponding to the causal relationship and used for encoding the conditional probability comprises:
determining a cause node and an effect node in the two nodes with causal relationship;
respectively constructing quantum logic gate combinations which are applied to the result nodes when the reason nodes take different states;
and constructing a second sub-quantum circuit corresponding to the causal relationship according to the quantum logic gate combination and the conditional probability between the reason node and the result node.
6. The method of claim 1, wherein the running the quantum wires, outputting and displaying a probability distribution of nodes of the bayesian network comprises:
and operating the quantum circuit, measuring the quantum bits of the nodes corresponding to the Bayesian network in the quantum circuit, and obtaining and displaying the probability distribution of the nodes.
7. The method according to any one of claims 1-6, further comprising:
and outputting and displaying the state of the target system and the probability thereof.
8. An apparatus for solving a bayesian network based on quantum wires, the apparatus comprising:
the first display module is used for receiving and responding to the editing operation of the Bayesian network aiming at the target system and displaying the edited Bayesian network;
the receiving and constructing module is used for receiving and responding to the calculation operation aiming at the Bayesian network and constructing the quantum wires corresponding to the Bayesian network;
and the second display module is used for operating the quantum line and outputting and displaying the probability distribution of the nodes of the Bayesian network.
9. A storage medium, in which a computer program is stored, wherein the computer program is arranged to perform the method of any of claims 1 to 7 when executed.
10. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, and wherein the processor is arranged to execute the computer program to perform the method of any of claims 1 to 7.
CN202110627291.7A 2021-06-04 2021-06-04 Method and device for solving Bayesian network based on quantum line Pending CN115438791A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110627291.7A CN115438791A (en) 2021-06-04 2021-06-04 Method and device for solving Bayesian network based on quantum line

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110627291.7A CN115438791A (en) 2021-06-04 2021-06-04 Method and device for solving Bayesian network based on quantum line

Publications (1)

Publication Number Publication Date
CN115438791A true CN115438791A (en) 2022-12-06

Family

ID=84272204

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110627291.7A Pending CN115438791A (en) 2021-06-04 2021-06-04 Method and device for solving Bayesian network based on quantum line

Country Status (1)

Country Link
CN (1) CN115438791A (en)

Similar Documents

Publication Publication Date Title
CN113222155B (en) Quantum circuit construction method and device, electronic device and storage medium
CN112633508B (en) Quantum circuit generation method and device, storage medium and electronic device
CN112232513A (en) Quantum state preparation method and device
CN111563599A (en) Quantum line decomposition method and device, storage medium and electronic device
CN112633507A (en) Method and device for encoding complex vector to quantum circuit
CN113222161B (en) Implementation method and device of custom quantum logic gate
CN113222153B (en) Quantum state simulation method and device, storage medium and electronic device
CN114358318B (en) Machine learning framework-based classification method and related device
CN114358216B (en) Quantum clustering method based on machine learning framework and related device
CN115759413A (en) Meteorological prediction method and device, storage medium and electronic equipment
CN114358319A (en) Machine learning framework-based classification method and related device
CN113222151B (en) Quantum state transformation method and device
CN116090568B (en) Method and device for determining size relation between quantum data and classical floating point data
CN112396166A (en) Graph convolution neural network training method and device based on mixed granularity aggregator
CN115271076A (en) Construction method and device of quantum circuit corresponding to Bayesian network
CN115879562B (en) Quantum program initial mapping determination method and device and quantum computer
CN116011681A (en) Meteorological data prediction method and device, storage medium and electronic device
CN115438791A (en) Method and device for solving Bayesian network based on quantum line
CN114511094A (en) Quantum algorithm optimization method and device, storage medium and electronic device
CN115983392A (en) Method, device, medium and electronic device for determining quantum program mapping relation
CN114764619A (en) Convolution operation method and device based on quantum circuit
CN115409185A (en) Construction method and device of quantum line corresponding to linear function
CN115809707A (en) Quantum comparison operation method and device, electronic device and basic arithmetic assembly
CN115879559A (en) Method and device for judging equivalence relation among multiple quantum states and quantum computer
CN115374945A (en) System state judgment method and device based on quantum Bayesian network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 230088 6th floor, E2 building, phase II, innovation industrial park, 2800 innovation Avenue, Hefei high tech Zone, Hefei City, Anhui Province

Applicant after: Benyuan Quantum Computing Technology (Hefei) Co.,Ltd.

Address before: 230088 6th floor, E2 building, phase II, innovation industrial park, 2800 innovation Avenue, Hefei high tech Zone, Hefei City, Anhui Province

Applicant before: ORIGIN QUANTUM COMPUTING COMPANY, LIMITED, HEFEI