A quantum clustering method, device, electronic equipment and storage medium

By leveraging the parallel advantages and clustering algorithms of quantum computing, quantum logic gates are used to construct quantum circuits for similarity calculation and clustering of data points. This solves the problem of exponential growth in memory requirements in classical computing and achieves efficient quantum clustering.

CN116089675BActive Publication Date: 2025-11-18ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111270638.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-29
Publication Date
2025-11-18
Estimated Expiration
2041-10-29

AI Technical Summary

Technical Problem

In existing technologies, the memory requirements for classical computational simulation of quantum algorithms increase exponentially with the number of qubits, limiting the effective implementation of quantum clustering processes.

Method used

Leveraging the parallel advantages of quantum computing, the similarity of data points is obtained through quantum circuits and clustered according to a preset threshold. Quantum logic gates such as RX gate, RY gate, Hadamard gate, and CNOT gate are used to construct quantum circuits for data point clustering.

Benefits of technology

It effectively solves the clustering problem of high-dimensional data points, and uses the parallelism of quantum computing to divide data points with high similarity into the same cluster, reducing memory requirements and improving clustering efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116089675B_ABST
    Figure CN116089675B_ABST
Patent Text Reader

Abstract

A quantum clustering method and device, electronic equipment and storage medium are disclosed. The method comprises: obtaining a first data point in a first set, obtaining a first similarity between the first data point and other data points in the first set according to a first preset quantum circuit, comparing the first similarity with a first preset threshold according to a second preset quantum circuit, obtaining the number of other data points in a preset neighborhood of the first data point according to the size relationship between the first similarity and the first preset threshold, determining whether the number of other data points in the preset neighborhood of the first data point is greater than a second preset threshold, and if so, marking the first data point as a core point and classifying other data points in the preset neighborhood of the first data point into a first cluster with the first data point as the core. The parallel advantage of quantum computing is utilized, and irregularly distributed data points are clustered according to distance based on quantum computing and clustering algorithms.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of quantum computing, and particularly relates to a quantum clustering method and device, an electronic equipment and a storage medium. BACKGROUND

[0002] Two cores of quantum computing are physical quantum computers and quantum algorithms. Due to the development of quantum computer hardware, many quantum algorithms are in a theoretical derivation stage. The simulation of quantum algorithms by classical computing is also limited to low-qubit quantum circuits. Taking a full-amplitude algorithm as an example, when the number of qubits of a quantum circuit reaches 32, at least 64G memory is required if classical computing is used for simulation; 128G memory is required for simulating a 33-qubit quantum circuit. The exponential growth of memory requirement seriously limits the simulation effect of classical computing on quantum algorithms.

[0003] The core object of the current cluster is updated using a quantum algorithm, and data belonging to the same category is found out through a distance value to complete clustering of the data. At present, there is an urgent need to provide a corresponding quantum algorithm to implement the clustering process to fill the technical gap. SUMMARY

[0004] The application aims to provide a quantum clustering method, device, electronic equipment and storage medium to solve the deficiencies in the prior art. It takes advantage of the parallelism of quantum computing and clusters irregularly distributed data points according to distance based on quantum computing and clustering algorithms.

[0005] In a first aspect, the application provides a quantum clustering method, comprising:

[0006] obtaining a first data point in a first set, wherein the first set comprises a plurality of data points;

[0007] obtaining a first similarity between the first data point and other data points in the first set according to a first preset quantum circuit, wherein the similarity is determined by the distance between different data points;

[0008] comparing the first similarity with a first preset threshold according to a second preset quantum circuit, and obtaining the number of other data points in the preset neighborhood of the first data point according to the size relationship between the first similarity and the first preset threshold;

[0009] determining whether the number of other data points in the preset neighborhood of the first data point is greater than a second preset threshold;

[0010] if yes, marking the first data point as a core point, and classifying other data points in the preset neighborhood of the first data point into a first cluster with the first data point as the core.

[0011] Optionally, if the number of other data points within a preset neighborhood of the first data point is not greater than a preset threshold, the method further includes:

[0012] The first data point is marked as a non-core point, and the non-core point is not used as the core of any cluster.

[0013] Optionally, after classifying other data points within a preset neighborhood of the first data point into a first cluster centered on the first data point, the method further includes:

[0014] Obtain the second data point from the first set, wherein the second data point is located at a different position from the first data point;

[0015] Determine whether the number of other data points within the preset neighborhood of the second data point is greater than a preset threshold;

[0016] If it is greater than, then the second data point is set as the core point, and other data points in the preset neighborhood of the second data point are classified into the second cluster with the second data point as the core.

[0017] Determine whether any data point within the second cluster has been assigned to the first cluster with the first data point as its core.

[0018] If so, then the first cluster and the second cluster are merged with the first data point as the core.

[0019] Optionally, obtaining the first similarity between the first data point and other data points in the first set according to the first preset quantum circuit includes:

[0020] A first preset quantum circuit is constructed based on preset quantum logic gates, wherein the preset quantum logic gates include RX gate, RY gate, H gate and controlled SWAP gate;

[0021] The data points in the first set are each prepared into quantum states;

[0022] The quantum state of the first data point and the quantum states of other data points in the first set are prepared onto the quantum circuit, and the quantum circuit is run.

[0023] The target qubit of the quantum circuit is measured, and the similarity between the first data point and other data points in the first set is obtained based on the measurement results of the target qubit.

[0024] Optionally, determining whether the number of other data points within a preset neighborhood of the first data point is greater than a preset threshold includes:

[0025] Map a first similarity value that is greater than or equal to the first preset threshold to a first target value;

[0026] The number of first similarities corresponding to the first target value is searched according to the preset quantum search algorithm;

[0027] If the number of first similarities corresponding to the first target value is greater than a preset threshold, then the number of first similarities greater than or equal to the preset similarity is greater than the preset threshold.

[0028] If the number of first similarities corresponding to the first target value is not greater than the preset threshold, then the number of first similarities greater than or equal to the preset similarity is not greater than the preset threshold.

[0029] Secondly, this application provides a quantum clustering device, comprising:

[0030] An acquisition unit is used to acquire a first data point in a first set, wherein the first set includes multiple data points;

[0031] The computing unit is used to obtain a first similarity between the first data point and other data points in the first set according to a first preset quantum circuit, wherein the similarity is determined by the distance between different data points;

[0032] The comparison unit is used to compare the first similarity with the first preset threshold according to the second preset quantum circuit, and to obtain the number of other data points in the preset neighborhood of the first data point according to the relationship between the first similarity and the first preset threshold.

[0033] The judgment unit is used to determine whether the number of other data points in the preset neighborhood of the first data point is greater than the second preset threshold.

[0034] The first labeling unit is used to label the first data point as the core point if the judgment unit determines that it is true, and to classify other data points in the preset neighborhood of the first data point into the first cluster with the first data point as the core.

[0035] Optionally, the device further includes:

[0036] The second marking unit is used to mark the first data point as a non-core point if the judgment unit determines that it is not a core point, and the non-core point is not used as the core of any cluster.

[0037] Thirdly, embodiments of this application provide an electronic device, including a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for performing the steps of the method described in the first aspect of this application.

[0038] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program causes a computer to perform some or all of the steps described in the method described in the first aspect of embodiments of this application.

[0039] Fifthly, embodiments of this application provide a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program being operable to cause a computer to perform some or all of the steps described in the method described in the first aspect of embodiments of this application. The computer program product may be a software installation package.

[0040] In a sixth aspect, embodiments of this application provide a quantum computer operating system, wherein the quantum computer operating system implements quantum clustering processing according to some or all of the steps described in the method described in the first aspect of embodiments of this application.

[0041] As can be seen, compared with the prior art, the quantum clustering method provided in this application obtains a first data point in a first set, obtains a first similarity between the first data point and other data points in the first set according to a first preset quantum circuit, compares the first similarity with a first preset threshold according to a second preset quantum circuit, obtains the number of other data points in a preset neighborhood of the first data point according to the relationship between the first similarity and the first preset threshold, and determines whether the number of other data points in the preset neighborhood of the first data point is greater than a second preset threshold. If it is greater, the first data point is marked as a core point, and the other data points in the preset neighborhood of the first data point are assigned to the first cluster with the first data point as the core. Using the embodiments of this application can leverage the parallel advantages of quantum computing, and cluster irregularly distributed data points according to distance based on quantum computing and clustering algorithms. Attached Figure Description

[0042] Figure 1 This is a schematic diagram of the process of the quantum clustering method in an embodiment of this application;

[0043] Figure 2 This is another schematic diagram illustrating the process of the quantum clustering method in the embodiments of this application;

[0044] Figure 3 This is a schematic diagram of a quantum circuit modularization for clustering processing in an embodiment of this application;

[0045] Figure 4 A schematic diagram of a quantum circuit for preparing a quantum state according to an embodiment of this application;

[0046] Figure 5A schematic diagram of a quantum circuit for calculating similarity in an embodiment of this application;

[0047] Figure 6 A schematic diagram of the quantum circuit for quantum state comparison provided in this application;

[0048] Figure 7 This application provides a schematic diagram of a modular quantum circuit corresponding to the Grover algorithm.

[0049] Figure 8 An iterative diagram of the Grover algorithm provided in this application;

[0050] Figure 9 This is a schematic diagram of the structure of the quantum clustering device provided in the embodiments of this application;

[0051] Figure 10 This is a hardware structure block diagram of a computer terminal for a quantum clustering method provided in an embodiment of this application. Detailed Implementation

[0052] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0053] This application provides a quantum clustering method, apparatus, electronic device, and storage medium, which leverages the parallel advantages of quantum computing to group highly similar data into the same cluster based on quantum computing and clustering algorithms. It should be noted that the quantum program referred to in the embodiments of this application is a program written in a classical language that represents qubits and their evolution, wherein qubits, quantum logic gates, etc., related to quantum computing all have corresponding classical code representations.

[0054] Quantum circuits, also known as quantum logic circuits, are a common representation of quantum programming and the most widely used general-purpose quantum computing model. They represent the circuitry that operates on qubits under an abstract concept. A quantum circuit consists of qubits, a circuit (timeline), and various quantum logic gates. The result is often retrieved through quantum measurement operations. A quantum circuit can be represented as a sequence of quantum logic gates arranged in a specific execution order.

[0055] Unlike traditional circuits that use metal wires to transmit voltage or current signals, in quantum circuits, the circuits can be seen as being connected by time. That is, the state of a quantum bit evolves naturally over time, following the instructions of the Hamiltonian operator, until it encounters a quantum logic gate and is manipulated.

[0056] A quantum program corresponds to a single quantum circuit. The quantum program described in this application refers to this single quantum circuit, where the total number of qubits in the single quantum circuit is the same as the total number of qubits in the quantum program. This can be understood as follows: a quantum program can consist of a quantum circuit, measurement operations on the qubits within the quantum circuit, registers storing the measurement results, and control flow nodes (jump instructions). A single quantum circuit can contain dozens, hundreds, or even thousands of quantum logic gate operations. The execution of a quantum program is the process of executing all the quantum logic gates in a specific timing order. It should be noted that the timing order refers to the chronological sequence in which individual quantum logic gates are executed.

[0057] It's important to note that in classical computing, the most basic unit is the bit, and the most fundamental control mode is the logic gate. Circuit control can be achieved through combinations of logic gates. Similarly, the way to process qubits is through quantum logic gates. Quantum logic gates enable the evolution of quantum states and are the foundation of quantum circuits. Quantum logic gates include single-qubit quantum logic gates (or simply "single gate"), such as the Hadamard gate (H gate), Pauli-X gate (X gate), Pauli-Y gate (Y gate), Pauli-Z gate (Z gate), RX gate, RY gate, RZ gate, etc.; two-qubit quantum logic gates (or simply "dual gate"), such as the CNOT gate, CR gate, SWAP gate, ISWAP gate, etc.; and multi-qubit quantum logic gates (or simply "multi-gate"), such as the Tofoli gate, etc. Quantum logic gates are generally represented using unitary matrices, which are not only matrix forms but also operations and transformations. In general, the action of a quantum logic gate on a quantum state is calculated by left-multiplying a unitary matrix by the matrix corresponding to the right vector of the quantum state. For example, the vector corresponding to the right vector |0> of the quantum state is... The vector corresponding to the right vector of the quantum state |1> is

[0058] A quantum state is the logical state of a qubit. In quantum algorithms (or quantum programs), the quantum states of a group of qubits in a quantum circuit are represented in binary. For example, a group of qubits q0, q1, and q2, representing the 0th, 1st, and 2nd qubits, are represented in binary from most significant bit to least significant bit as q2q1q0. This group of qubits corresponds to a total of 2^(1 / 2) qubits, or 8 eigenstates (determined states): |000>, |001>, |010>, |011>, |100>, |101>, |110>, and |111>. Each bit in a quantum state corresponds to a qubit. For example, in the |001> state, 001 corresponds to q2q1q0 from most significant bit to least significant bit. |> represents the Dirac notation. For a group of N qubits q0, q1, ..., q2, ... n, ..., q N-1 In quantum circuits, the binary representation of quantum states is ordered as q. N-1 q N-2 …、q1q0.

[0059] Taking a single qubit as an example, the logical state ψ of a single qubit may be in a superposition of the states |0>, |1>, and |0> and |1> (an uncertain state), specifically represented as ψ = a|0> + b|1>, where a and b are complex numbers representing the amplitude (probability amplitude) of the quantum state, and the square of the modulus of the amplitude represents the probability, |a| 2 、|b| 2 Let |a| represent the probabilities that the logical state is |0> and |1>, respectively. 2 +|b| 2 =1. In short, a quantum state is a superposition of eigenstates. When the probability of other states is 0, it is in a uniquely determined eigenstate.

[0060] Clustering algorithms are a machine learning technique that involves grouping data points. Given a set of data points, we can use a clustering algorithm to divide each data point into a specific cluster. In some cases, data points in the same group should have similar attributes and / or features, while data points in different groups should have highly different attributes and / or features. Furthermore, when dividing a set of data points into clusters, densely distributed points can also be grouped into the same cluster.

[0061] The quantum clustering method of this application is further described below. Please refer to [link to relevant documentation] for details. Figure 1 A flowchart of the quantum clustering method provided in this application includes:

[0062] 101. Obtain the first data point in the first set, wherein the first set includes multiple data points;

[0063] In this embodiment, the first set includes multiple data points, each data point corresponding to a coordinate position. That is, the first set includes multiple data points representing coordinate positions. This application aims to divide data points with more concentrated distribution into the same region, i.e., cluster. The first set can be regarded as a plane, on which multiple points are irregularly distributed, and the points with more concentrated distribution are divided into the same cluster.

[0064] 102. Obtain the first similarity between the first data point and other data points in the first set according to the first preset quantum circuit, wherein the similarity is determined by the distance between different data points;

[0065] In this embodiment, clustering processing based on quantum computing is implemented according to a preset quantum clustering circuit, such as... Figure 3The schematic diagram of a quantum circuit for clustering processing in this application is shown. The circuit includes a quantum state preparation module, a similarity calculation module, a quantum state comparison module, a quantum state search module, and a measurement module.

[0066] Specifically, the circuit based on the quantum state preparation module can be as follows: Figure 4 As shown, quantum logic gates RX and RY are used to process two-dimensional data into quantum states. For example, the coordinates of two data points are respectively... These two data points can generally be selected as a data point to be clustered and a cluster center. The process for determining the rotation angle parameters of the logic gates RX and RY is as follows:

[0067]

[0068]

[0069]

[0070]

[0071] Where, θ 00 Based on representing x0 as an angle, θ is obtained. 01 Based on representing y0 as an angle, θ is obtained. 10 Based on representing x1 in terms of angles, θ is obtained. 11 This is obtained by representing y1 as an angle.

[0072] Furthermore, the similarity calculation module can be as follows: Figure 5 As shown:

[0073] In this embodiment, quantum state processing is performed based on quantum logic gates RX and RY, followed by similarity calculation using a controlled SWAP gate. The quantum circuit used for similarity calculation is as follows: Figure 5 , Figure 5 for Figure 4 Subsequent quantum logic gate operations, Figure 5 It includes the H gate, the controlled SWAP gate, and the measurement operation M, where the H gate is used to... Figure 4 The prepared quantum state is in a superposition state. The controlled SWAP gate is used to calculate the similarity between q-1 and q-2 and pass the similarity to q-0, and to measure the quantum state of q-0.

[0074] Specifically, taking the coordinate position of the cluster center as the origin, the coordinates of the data to be clustered are represented by a vector u pointing from the cluster center to the data to be clustered, and normalized according to Formula 5 for easy calculation. Entangled states are defined according to Formula 6. According to Formula 7, the entangled state |φ> is defined, and according to Formula 8, the normalized coefficient Z is defined, then the similarity D i Specifically, as shown in Formula 9, the details are as follows:

[0075]

[0076]

[0077]

[0078]

[0079]

[0080] Among them, u=(u0,u1,...,u n ), Let be the j-th vector of the c-th cluster, and m be the total number of data to be aggregated.

[0081] Furthermore, After a controlled SWAP gate operation, the entangled state D shown below can be obtained:

[0082]

[0083] The probability of obtaining |0> when measuring q-0 is:

[0084]

[0085] Therefore, according to formulas 11 and 9, we can conclude that:

[0086] D i =2P(|0>)-1 Formula 12

[0087] As can be seen from the derivation of Formula 12 above, the similarity can be obtained by measuring the quantum state of the q-0 qubit.

[0088] 103. Compare the first similarity with the first preset threshold according to the second preset quantum circuit, and obtain the number of other data points in the preset neighborhood of the first data point according to the relationship between the first similarity and the first preset threshold;

[0089] In this embodiment, the first similarity obtained according to the method of embodiment 102 is compared with the first preset threshold to obtain the number of first similarities greater than the preset minimum similarity. The number of first similarities that meet the condition is the other data points included in the preset neighborhood of the first data point.

[0090] The first preset threshold is the similarity corresponding to the distance from the first data point to the boundary of the preset neighborhood. For example, the third data point, the fourth data point and the fifth data point are data points in the first set. If the first similarity of the third data point is greater than the first preset threshold, then the third data point is located within the preset neighborhood. If the first similarity of the fourth data point is equal to the first preset threshold, then the fourth data point is located on the boundary of the preset neighborhood. If the fifth data point is less than the first preset threshold, then the fifth data point is located outside the preset neighborhood.

[0091] Specifically, taking the comparison of two quantum states as an example, these two quantum states can include: a first quantum state and a second quantum state. Taking the first quantum state as having a first similarity and the second quantum state as having a first preset threshold as an example: In order to use quantum computing to compare the greater than relationship between quantum states, this can be achieved by constructing a quantum circuit with corresponding functions. One construction method is as follows:

[0092] The quantum circuit for quantum state comparison provided in this application embodiment uses... Figure 6 For example, the quantum logic gates shown are, in order: virtual control CNOT gate, virtual control OR gate, real control Tooffoli gate, X gate, real control OR gate, virtual control Tooffoli gate, X gate, and CNOT gate. Real control means that the quantum bit in the diagram is controlled by the solid quantum bit, and virtual control means that the quantum bit in the diagram is controlled by the hollow quantum bit.

[0093] Figure 6 It is a quantum circuit corresponding to two quantum states satisfying the greater than relation. It can be understood that the data points in the preset neighborhood obtained by comparing according to the circuit do not include the data points at the boundary of the neighborhood. If the data points to be obtained include the points located at the boundary of the neighborhood, the greater than relation is changed to a greater than or equal to relation, that is, the first quantum state is greater than or equal to the second quantum state. In the quantum circuit corresponding to the greater than or equal to relation, the first quantum logic gate used is replaced by the virtual control CNOT gate with: the X gate which is virtually controlled by p[1] and acts on a[1] and the Tofoli gate which acts on p[1], q[1] and a[1], and the rest remain unchanged.

[0094] The X gate functions as follows: when |j1>=|0>, |i1> must be greater than or equal to |j1>, and the quantum state |a1> corresponding to a[1] is flipped from |0> to |1>, thus obtaining the carry information 1 for the first bit; the Toffoli gate functions as follows: when |j1>=|1>, the quantum state |a1> corresponding to a[1] is flipped from |0> to |1> only when |i1>=|1> (the two are equal), thus obtaining the carry information 1 for the first bit; when |i1>=|0> (|i1> is less than |j1>), it is not flipped, and the carry information for the first bit is still 0, indicating no carry. In practical applications, it is also reasonable and feasible to use quantum logic gates equivalent to the Toffoli gate, OR gate, CNOT gate or X gate.

[0095] Furthermore, if the desired point is located within the neighborhood but does not include points on the neighborhood boundary, then a first qubit for storing the first quantum state, a second qubit for storing the second quantum state, a third qubit for storing carry information, and a fourth qubit for storing the comparison result are obtained.

[0096] The first quantum bit has n bits: q[1], q[2], ..., q[n], which store the first quantum state: |i1>, |i2>, ..., |i n >; where n is a positive integer;

[0097] The second quantum bit has (n+m) bits: p[1], p[2], ..., p[n], ..., p[n+m], which store the second quantum state: |j1>, |j2>, ..., |j n >、…、|j n+m >; where m is a non-negative integer;

[0098] The third qubit is used to store the carry information after comparing each bit of the first quantum state with each bit of the second quantum state. It has n bits: a[1], a[2], ..., a[n], and the carry information is specifically stored in the corresponding quantum states: |a1>, |a2>, ..., |a... n Taking the greater than relationship as an example, starting from the least significant bit, if a bit of the first quantum state is greater than the corresponding bit of the second quantum state, the carry information is 1; otherwise, it is 0.

[0099] The fourth qubit is used to store the comparison result of whether the first quantum state and the second quantum state satisfy the greater than relationship. It can be set to 1 bit: q[cmp]. The comparison result is specifically stored in the corresponding quantum state |c>.

[0100] Based on the greater than relation, each bit of the first quantum state and the second quantum state, determine the corresponding first quantum logic gate for generating carry information and the second quantum logic gate for generating comparison results based on the carry information;

[0101] For the first bit of the first quantum state |i1> and the first bit of the second quantum state |j1>, the first quantum logic gate acting on the first qubit corresponding to |i1>, the second qubit corresponding to |j1>, and the first third qubit is determined to be a virtual control CNOT gate; wherein, the function of the virtual control CNOT gate is: to execute the CNOT gate when |j1>=|0>, that is: when |j1>=|0> and |i1>=|1> (it can be seen that |i1> is greater than |j1>), the quantum state |a1> of the first bit a[1] of the third qubit is flipped from |0> to |1>, thereby obtaining the carry information 1 of the first bit and storing it.

[0102] For the k-th bit |i of the first quantum state k >、The k-th position of the second quantum state|j k >, determine the effect on |i k >corresponding first qubit, |j k The first quantum logic gates for the corresponding second qubit, the (k-1)th, and the kth third qubit are virtual-controlled OR gates and real-controlled Tooffoli gates, respectively; where k is an integer and 1 < k < n; the function of the virtual-controlled OR gate is: in |j k When >=|0>, the OR gate is executed, that is: |j k >=|0>, in|i k >=|1> or|a k-1 When >=|1>(the (k-1)th bit has a carry information of 1), the quantum state |a of the kth bit a[k] will be... k The |0> is flipped to |1>, thus obtaining the carry information 1 in the k-th bit; the function of the real-controlled Toffoli gate is: in |j k When |j >=|1>, the Toffoli gate is executed, i.e.: |j k >=|1>, in |i k >=|1>and|a k-1 When >=|1>, the quantum state |a of the k-th bit a[k] will be... k The carry information 1 of the k-th bit is obtained by flipping |0> to |1>.

[0103] For the nth position |i of the first quantum state n >、The nth position of the second quantum state|j n >Up to the (n+m)th position|j n+m >, determine the effect on |j n >to|j n+m The first quantum logic gate corresponding to the second qubit is the X gate, and the gate acting on |i n >corresponding first qubit, |j n >to|jn+m The first quantum logic gates of the corresponding second qubit, the (n-1)th and the nth third qubit are real-controlled OR gates and virtual-controlled Tooffoli gates, respectively; among them, X gates are first added to the second qubits p[n] to p[n+m] to make the corresponding second quantum state |j n >to|j n+m >Reverse the operation and add an OR gate controlled by p[n] to p[n+m], that is: in |j n >to|j n+m When all are in the |1> state, an OR gate is executed on q[n], a[n-1], and a[n]. The OR gate works as follows: when |i n >=|1> or|a n-1 When >=|1>, the quantum state |a of the nth a[n] will be... n >Flipping |0> to |1> yields the carry information 1 for the nth bit; then, adding Tooffoli gates with virtual control p[n] and real control p[n+1] to p[n+m], i.e.: in |j n >=|0>、|j n+1 >to|j n+m When all are |1>, the Tooffoli gate is executed on q[n], a[n-1], and a[n]. The Tooffoli gate works as follows: when |i n >=|1>and|a n-1 When >=|1>, the quantum state |a of the nth a[n] will be... n > By flipping |0> to |1>, the carry information 1 of the nth bit is obtained; it can be seen that if the extra quantum state bit |j n+1 >to|j n+m If at least one bit is |1> (indicating that the second quantum state is definitely greater than the first quantum state), then after the X gate flips, at least one bit becomes |0>, thus the OR gate and Toffoli gate are not executed, and the carry information of the nth bit is still 0, indicating no carry; if |j n+1 >to|j n+m >All are |0>, in |j n When >=|0>, after being flipped by the X gate, they all become |1>, and the OR gate is executed; when |j n When >=|1>, after the X-gate flip, |j n > becomes |0>、|j n+1 >to|j n+mAll become |1>, at which point the Toffoli gate is executed. Further, after the OR gate or Toffoli gate is executed, X gates can be added again on p[n] to p[n+m] to restore the second quantum state. The second quantum logic gate used to generate the comparison result based on the carry information, acting on the nth third qubit and the fourth qubit, is determined to be a CNOT gate. Specifically, after the OR gate or Toffoli gate is executed, a CNOT gate acting on a[n] and q[cmp] is added to store the carry information of a[n] into q[cmp].

[0104] The quantum circuit is run, and the target qubits contained in the quantum circuit are measured. A first similarity is compared with a first preset threshold to determine whether the greater than relationship is satisfied. Specifically, the quantum state |c> of the fourth qubit can be measured as the comparison result; based on the comparison result, it is determined whether the first quantum state and the second quantum state satisfy the greater than relationship. In the field of computer science, the truth value true is usually represented by 1. For example, if the measured comparison result is a |1> state, it means that the first quantum state and the second quantum state satisfy the greater than relationship; if it is a |0> state, it means that the first quantum state and the second quantum state do not satisfy the greater than relationship. That is, if the measured comparison result is a |1> state, then the point is located within a preset neighborhood; if the measured comparison result is a |0> state, then the point is not located within the preset neighborhood.

[0105] 104. Determine whether the number of other data points within the preset neighborhood of the first data point is greater than the second preset threshold;

[0106] In this embodiment, the number of first similarities greater than or equal to the preset minimum similarity is searched, and the number of first similarities that meet the condition is the other data points included in the preset neighborhood of the first data point.

[0107] Specifically, if there are 8 points in the first set excluding the first data point, and they are numbered from 0 to 7 respectively, if the points corresponding to 4, 5, 6, and 7 satisfy the condition, since there are a total of eight points, the corresponding binary number is 111, and 3 qubits are needed to encode them into a quantum state. 3 bits can represent 2 to the power of 3 data (0 to 7, corresponding to the |000> to |111> states), so a total of 8 probability data are output.

[0108] Therefore, |000>: output |0>, |001>: output |0>, |010>: output |0>, |011>: output |0>, |100>: output |1>, |101>: output |1>, |110>: output |1>, |111>: output |1>; thus, the probability that each quantum state contained in the superposition state |φ> is greater than the target value is 0, 0, 0, 0, 1, 1, 1, 1. Since the maximum element is 7, which is 111 in binary, 3 qubits are needed to encode the quantum state. 3 bits can represent 2^3 data (0 to 7, corresponding to states |000> to |111>), so a total of 8 probability data are output. The first set corresponds to the first superposition state |φ>:

[0109]

[0110] The quantum states with amplitude 0, |000>, |001>, |010>, and |011>, correspond to 0, 1, 2, and 3, respectively. The quantum states with amplitude 1, |100>, |101>, |110>, and |111>, correspond to 4, 5, 6, and 7, respectively. The probabilities corresponding to these indices are 0, 0, 0, 0, 1, 1, 1, and 1, respectively. Based on these eight probability values, the index value corresponding to probability 1 is found, and then the element values ​​4, 5, 6, and 7 corresponding to these index values ​​are found. These are the data points included in the preset neighborhood.

[0111] Based on establishing a mapping relationship between elements and their probability values, taking the first set as an example again, if the output is a quantum state |000> to |111> and its probability within a preset neighborhood, then a probability of 0 indicates that the data point is not within the preset neighborhood, and a probability of 1 indicates that the data point is within the preset neighborhood. That is, for f(0) = 0, f(1) = 0, f(2) = 0, f(3) = 0, f(4) = 1, f(5) = 1, f(6) = 1, f(7) = 1, we only need to find the index x corresponding to f(x) = 1, and then we can find the corresponding element based on the index.

[0112] The first set corresponds to the first superposition state |φ>:

[0113]

[0114] The quantum states |000>, |001>, |010>, and |011> with amplitudes of 0 correspond to 1, 2, 3, and 4, respectively. Each element has an index from 0 to 7, and each index has a probability of 0, 0, 0, 0, 1, 1, 1, and 1. Based on these eight probability values, the index value corresponding to probability 1 is found, and then the element value corresponding to that index value (4, 5, 6, 7) is found. These are the data points included in the preset neighborhood.

[0115] Based on establishing a mapping relationship between elements and their probability values, taking the first set as an example again, if the output is a quantum state |000> to |111> and its probability within a preset neighborhood, then a probability of 0 indicates that the data point is not within the preset neighborhood, and a probability of 1 indicates that the data point is within the preset neighborhood. That is, for f(0) = 0, f(1) = 0, f(2) = 0, f(3) = 0, f(4) = 1, f(5) = 1, f(6) = 1, f(7) = 1, we only need to find the index x corresponding to f(x) = 1, and then we can find the corresponding element based on the index.

[0116] First, create the second superposition state |ψ>, as shown in Equation 13:

[0117]

[0118] Where N is the number of output probability values. Taking set A as an example, N = 8.

[0119] Let the first Oracle operator o be defined, which is used for the quantum state flip phase corresponding to f(x) = 1, as shown in Equation 14:

[0120]

[0121] Define a second operator G (Grover operator), which is used to amplify the amplitude of the quantum state with the flipped phase, as shown in Equation 15:

[0122] G=(2|ψ><ψ|-I)O Formula 15

[0123] Where O is

[0124] Without loss of generality, assume that all x values ​​for f(x) = 1 form quantum states as shown in Equation 16:

[0125]

[0126] Therefore, the quantum state consisting of all x values ​​for which f(x) = 0 is shown in Equation 17:

[0127]

[0128] Where M represents the number of solutions in the set, |α> represents the quantum superposition of all non-solutions, and |β> represents the quantum superposition of all solutions, which is the final quantum state.

[0129] Where N = 2 n Therefore, |ψ> can be represented by formula 18:

[0130]

[0131] Apply Grover's algorithm using Equation 19:

[0132] O(a|α>+b|β)=a|α>-b|β> Formula 19

[0133] For ease of calculation, let's assume...

[0134] The result after the second operator G is applied once is shown in Equation 20:

[0135]

[0136] Furthermore, the |ψ> after the second operator G is applied k times is obtained as shown in Equation 21:

[0137]

[0138] It can be represented by an image. Figure 8 As shown, repeatedly using G allows |ψ> to continuously approach |β>. Finally, measuring |ψ> yields a high probability of obtaining a ground state in |β>, which is the index of f(x) = 1. For example, a modular quantum circuit diagram of Grover's algorithm is shown below. Figure 7 As can be understood by those skilled in the art, This represents the quantum logic gate module (including the H gate) that creates a superposition state. The Oracle workspace corresponds to the first Oracle operator o, and G corresponds to the second Grover operator.

[0139] 105. If the value is greater than the first data point, then mark the first data point as the core point and classify other data points in the preset neighborhood of the first data point into the first cluster with the first data point as the core.

[0140] In this embodiment, if a certain number of data points are included in the preset neighborhood of a data point (i.e., the first data point), it is considered that the data points distributed in the preset neighborhood are relatively concentrated. Then, the preset neighborhood formed with the first data point as the center point and a preset distance as the radius is taken as a cluster. In the implementation process, it is determined whether the number of data points in the first set whose distance from the first data point is less than the preset distance is greater than a preset threshold. If the number is greater than the preset threshold, the first data point is marked as the core point, and other data points in the preset neighborhood of the first data point are assigned to the first cluster with the first data point as the core. If the number is not greater than the preset threshold, the first data point is marked as a non-core point, and the non-core point is not used as the core of any cluster.

[0141] based on Figure 1 This application provides further details on cluster merging in its embodiments; please refer to the specific examples.Figure 2 Another flowchart of the quantum clustering method provided in this application includes:

[0142] 201. Obtain the second data point in the first set, wherein the second data point is located at a different position from the first data point;

[0143] 202. Determine whether the number of other data points within the preset neighborhood of the second data point is greater than a preset threshold;

[0144] 203. If it is greater than the target value, then the second data point is set as the core point, and other data points in the preset neighborhood of the second data point are assigned to the second cluster with the second data point as the core.

[0145] 204. Determine whether any data point within the second cluster has been assigned to the first cluster with the first data point as its core;

[0146] 205. If so, then take the first data point as the core and merge the first cluster and the second cluster.

[0147] In this embodiment, since the number of data points contained in the preset neighborhood of a certain data point is limited, while the concentration of data points outside the preset neighborhood may still meet the requirement of being classified into the same cluster, the data points outside the preset neighborhood can be incorporated into the preset neighborhood to generate a new cluster.

[0148] Specifically, in this embodiment, the method described in embodiments 101-105 above is performed on all data points included in the first set until all points are marked as core points or non-core points. After the first data point is marked as a core point, a second data point is obtained in the first set. The second data point is located at a different position than the first data point and is not marked. It is determined whether the number of other data points in the preset neighborhood of the second data point is greater than a preset threshold. If it is not greater than the preset threshold, the second data point is marked as a non-core point, and the process continues to traverse other unmarked points. If it is greater than the preset threshold, a circular region with the second data point as the core and a preset distance as the radius is divided into a second cluster. If the data points included in the second cluster and the first cluster overlap, that is, if a point in the first set is located in the regions of both the first cluster and the second cluster, then the second cluster and the first cluster are merged, and the core point of the previously generated cluster is used as the new core point. Alternatively, the coordinates of all points included in the new cluster are calculated and weighted averaged to obtain a new coordinate position, and the data point closest to that coordinate position is used as the new core point. This application does not require this.

[0149] In this embodiment, a first data point in a first set is obtained. A first similarity score between the first data point and other data points in the first set is obtained according to a first preset quantum circuit. The first similarity score is compared with a first preset threshold according to a second preset quantum circuit. The number of other data points in a preset neighborhood of the first data point is obtained based on the relationship between the first similarity score and the first preset threshold. It is determined whether the number of other data points in the preset neighborhood of the first data point is greater than a second preset threshold. If it is greater, the first data point is marked as a core point, and the other data points in the preset neighborhood of the first data point are assigned to a first cluster centered on the first data point. Leveraging the parallel advantages of quantum computing, irregularly distributed data points are clustered based on distance using quantum computing and clustering algorithms.

[0150] The above description introduces the invention from a methodological perspective. The following description further introduces the invention from an apparatus perspective; please refer to the details below. Figure 9 ,include:

[0151] Acquisition unit 901 is used to acquire a first data point in a first set, wherein the first set includes multiple data points;

[0152] The computing unit 902 is used to obtain a first similarity between the first data point and other data points in the first set according to a first preset quantum circuit, wherein the similarity is determined by the distance between different data points;

[0153] The comparison unit 903 is used to compare the first similarity with the first preset threshold according to the second preset quantum circuit, and to obtain the number of other data points in the preset neighborhood of the first data point according to the relationship between the first similarity and the first preset threshold.

[0154] The judgment unit 904 is used to determine whether the number of other data points in the preset neighborhood of the first data point is greater than the second preset threshold.

[0155] The first labeling unit 905 is used to label the first data point as the core point if the judgment unit determines that it is true, and to classify other data points in the preset neighborhood of the first data point into the first cluster with the first data point as the core.

[0156] Optionally, the device further includes a second marking unit 906, configured to mark the first data point as a non-core point if the judgment unit determines that it is not a core point, wherein the non-core point is not used as the core of any cluster.

[0157] As can be seen, the acquisition unit 901 is used to acquire a first data point in a first set, which includes multiple data points; the calculation unit 902 is used to acquire a first similarity between the first data point and other data points in the first set according to a first preset quantum circuit, wherein the similarity is determined by the distance between different data points; the comparison unit 903 is used to compare the first similarity with a first preset threshold according to a second preset quantum circuit, and to acquire the number of other data points in a preset neighborhood of the first data point according to the relationship between the first similarity and the first preset threshold; the judgment unit 904 is used to determine whether the number of other data points in the preset neighborhood of the first data point is greater than a second preset threshold; and the first marking unit 905 is used to mark the first data point as a core point if the judgment unit determines that it is, and to classify the other data points in the preset neighborhood of the first data point into a first cluster with the first data point as the core. It leverages the parallel advantages of quantum computing, clustering irregularly distributed data points according to distance based on quantum computing and clustering algorithms.

[0158] The following detailed explanation uses a computer terminal as an example. Figure 10 This is a hardware structure block diagram of a computer terminal for a quantum clustering method provided in an embodiment of the present invention. Figure 10 As shown, a computer terminal may include one or more ( Figure 10 Only one is shown in the diagram. A processor 1001 (processor 1001 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 1002 for storing data are also shown. Optionally, the computer terminal may further include a transmission device 1003 for communication functions and an input / output device 1004. Those skilled in the art will understand that... Figure 10 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 10 The more or fewer components shown, or having the same Figure 10 The different configurations shown.

[0159] The memory 1002 can be used to store software programs and modules of application software, such as the program instructions / modules corresponding to the quantum clustering method in this embodiment. The processor 1001 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002, thereby implementing the above-described method. The memory 1002 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 instances, the memory 1002 may further include memory remotely located relative to the processor 1001, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0160] The transmission device 1003 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal. In one example, the transmission device 1003 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 1003 may be a Radio Frequency (RF) module, used for wireless communication with the Internet. Embodiments of this application also provide a computer-readable storage medium storing a computer program for electronic data interchange, which causes a computer to perform some or all of the steps of any of the methods described in the above method embodiments, wherein the computer includes an electronic device. Leveraging the parallel advantages of quantum computing, irregularly distributed data points are clustered based on distance using quantum computing and clustering algorithms.

[0161] This application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods described in the above method embodiments. The computer program product may be a software installation package, and the computer may include an electronic device.

[0162] This application also provides a quantum computer operating system that implements the quantum clustering process according to some or all of the steps of any of the methods described in the above method embodiments.

[0163] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0164] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0165] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical or other forms.

[0166] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0167] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0168] If the integrated units described above are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0169] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0170] The embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A quantum clustering method, characterized in that, The method includes: Obtain the first data point from the first set, where the first set includes multiple data points; The first similarity between the first data point and other data points in the first set is obtained according to the first preset quantum circuit, wherein the similarity is determined by the distance between different data points; The first similarity is compared with the first preset threshold according to the second preset quantum circuit, and the number of other data points in the preset neighborhood of the first data point is obtained according to the relationship between the first similarity and the first preset threshold. The second preset quantum circuit includes: a first quantum bit for storing the first quantum state, a second quantum bit for storing the second quantum state, a third quantum bit for storing carry information, and a fourth quantum bit for storing the comparison result. Determine whether the number of other data points within the preset neighborhood of the first data point is greater than the second preset threshold; If the value is greater than the first data point, then the first data point is marked as the core point, and other data points within the preset neighborhood of the first data point are assigned to the first cluster with the first data point as the core.

2. The method according to claim 1, characterized in that, If the number of other data points within the preset neighborhood of the first data point is not greater than a preset threshold, the method further includes: The first data point is marked as a non-core point, and the non-core point is not used as the core of any cluster.

3. The method according to claim 1, characterized in that, After classifying other data points within a preset neighborhood of the first data point into a first cluster centered on the first data point, the method further includes: Obtain the second data point from the first set, wherein the second data point is located at a different position from the first data point; Determine whether the number of other data points within the preset neighborhood of the second data point is greater than a preset threshold; If it is greater than, then the second data point is set as the core point, and other data points in the preset neighborhood of the second data point are assigned to the second cluster with the second data point as the core. Determine whether any data point within the second cluster has been assigned to the first cluster with the first data point as its core. If so, then the first cluster and the second cluster are merged with the first data point as the core.

4. The method according to claim 1, characterized in that, The step of obtaining the first similarity between the first data point and other data points in the first set according to the first preset quantum circuit includes: A first preset quantum circuit is constructed based on preset quantum logic gates, wherein the preset quantum logic gates include RX gate, RY gate, H gate and controlled SWAP gate; The data points in the first set are each prepared into quantum states; The quantum state of the first data point and the quantum states of other data points in the first set are prepared onto the quantum circuit, and the quantum circuit is run. The target qubit of the quantum circuit is measured, and the similarity between the first data point and other data points in the first set is obtained based on the measurement results of the target qubit.

5. The method according to claim 1, characterized in that, The step of determining whether the number of other data points within the preset neighborhood of the first data point is greater than a preset threshold includes: Map a first similarity value that is greater than or equal to the first preset threshold to a first target value; The number of first similarities corresponding to the first target value is searched according to the preset quantum search algorithm; If the number of first similarities corresponding to the first target value is greater than a preset threshold, then the number of first similarities greater than or equal to the preset similarity is greater than the preset threshold. If the number of first similarities corresponding to the first target value is not greater than the preset threshold, then the number of first similarities greater than or equal to the preset similarity is not greater than the preset threshold.

6. A quantum clustering device, characterized in that, The device includes: An acquisition unit is used to acquire a first data point in a first set, wherein the first set includes multiple data points; The computing unit is used to obtain a first similarity between the first data point and other data points in the first set according to a first preset quantum circuit, wherein the similarity is determined by the distance between different data points; The comparison unit is used to compare the first similarity with the first preset threshold according to the second preset quantum circuit, and to obtain the number of other data points in the preset neighborhood of the first data point according to the relationship between the first similarity and the first preset threshold. The second preset quantum circuit includes: a first quantum bit for storing the first quantum state, a second quantum bit for storing the second quantum state, a third quantum bit for storing carry information, and a fourth quantum bit for storing the comparison result. The judgment unit is used to determine whether the number of other data points in the preset neighborhood of the first data point is greater than the second preset threshold. The first labeling unit is used to label the first data point as the core point if the judgment unit determines that it is true, and to classify other data points in the preset neighborhood of the first data point into the first cluster with the first data point as the core.

7. The apparatus according to claim 6, characterized in that, The device further includes: The second marking unit is used to mark the first data point as a non-core point if the judgment unit determines that it is not a core point, and the non-core point is not used as the core of any cluster.

8. An electronic device, characterized in that, The method includes a processor, a memory, a communication interface, and one or more programs, said one or more programs being stored in the memory and configured to be executed by the processor, said programs including instructions for performing the steps of the method as described in any one of claims 1-5.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that is executed by a processor to implement the method of any one of claims 1-5.

10. A quantum computer operating system, characterized in that, The quantum computer operating system implements quantum clustering processing according to any one of claims 1-5.