WO2022247887A1 - 一种线性函数对应的量子线路的构建方法及装置 - Google Patents

一种线性函数对应的量子线路的构建方法及装置 Download PDF

Info

Publication number
WO2022247887A1
WO2022247887A1 PCT/CN2022/095134 CN2022095134W WO2022247887A1 WO 2022247887 A1 WO2022247887 A1 WO 2022247887A1 CN 2022095134 W CN2022095134 W CN 2022095134W WO 2022247887 A1 WO2022247887 A1 WO 2022247887A1
Authority
WO
WIPO (PCT)
Prior art keywords
linear function
qubit
sub
quantum circuit
quantum
Prior art date
Application number
PCT/CN2022/095134
Other languages
English (en)
French (fr)
Inventor
李叶
袁野为
窦猛汉
Original Assignee
合肥本源量子计算科技有限责任公司
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
Priority claimed from CN202110593126.4A external-priority patent/CN115409620A/zh
Priority claimed from CN202110595092.2A external-priority patent/CN115409185A/zh
Priority claimed from CN202110595106.0A external-priority patent/CN115409186A/zh
Application filed by 合肥本源量子计算科技有限责任公司 filed Critical 合肥本源量子计算科技有限责任公司
Priority to EP22810611.8A priority Critical patent/EP4328808A1/en
Publication of WO2022247887A1 publication Critical patent/WO2022247887A1/zh
Priority to US18/515,886 priority patent/US11966815B2/en

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/40Physical realisations or architectures of quantum processors or components for manipulating qubits, e.g. qubit coupling or qubit control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/20Models of quantum computing, e.g. quantum circuits or universal quantum computers
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03KPULSE TECHNIQUE
    • H03K17/00Electronic switching or gating, i.e. not by contact-making and –breaking
    • H03K17/51Electronic switching or gating, i.e. not by contact-making and –breaking characterised by the components used
    • H03K17/92Electronic switching or gating, i.e. not by contact-making and –breaking characterised by the components used by the use, as active elements, of superconductive devices

Definitions

  • the disclosure belongs to the technical field of quantum computing, in particular to a method and device for constructing a quantum circuit corresponding to a linear function.
  • Quantum computer is a kind of physical device that follows the laws of quantum mechanics to perform high-speed mathematical and logical operations, store and process quantum information. When a device processes and computes quantum information and runs quantum algorithms, it is a quantum computer. Quantum computer has become a key technology under research because of its ability to deal with mathematical problems more efficiently than ordinary computers, for example, it can speed up the time to crack RSA keys from hundreds of years to hours.
  • Option pricing is a common means of predicting the price of underlying assets in the financial field.
  • option pricing is generally estimated by the classic Monte Carlo method, but this method requires a large sample size for sample collection, which increases the calculation amount of option estimation and reduces the efficiency of option estimation.
  • An object of the present disclosure is to provide a method and device for constructing a quantum circuit corresponding to a linear function, so as to solve the technical problem of realizing a linear function in quantum computing.
  • An embodiment of the present application provides a method for constructing a quantum circuit corresponding to a linear function, the method comprising: preparing an argument of the target linear function on the first qubit; obtaining a quantum circuit used to output the target linear function For the second qubit, add a parametric sublogic gate acting on the second qubit, and control the parametric sublogic gate through the first qubit; determine the parametric sublogic gate according to the target linear function The parameter value of the quantum logic gate is used to obtain the quantum circuit corresponding to the target linear function.
  • Yet another embodiment of the present application provides a device for constructing a quantum circuit corresponding to a linear function, the device comprising: a preparation module for preparing the argument of the target linear function on the first qubit; an adding module for In obtaining the second qubit for outputting the target linear function, adding a parametric sublogic gate acting on the second qubit, and controlling the parametric sublogic gate through the first qubit; determining A module, configured to determine parameter values of the sub-logic gates containing parameters according to the target linear function, and obtain quantum circuits corresponding to the target linear function.
  • An embodiment of the present application provides a method for constructing a quantum circuit corresponding to a piecewise linear function, the method comprising: preparing the argument of the target piecewise linear function on the first qubit; based on the first quantum bit and the segmentation point of the piecewise linear function, constructing a first sub-quantum circuit for comparing the independent variable with the abscissa of the segmentation point; based on the first qubit and the first The comparison bits of the output comparison results contained in the sub-quantum circuit construct the segment sub-quantum circuit corresponding to each segment of the linear function in the segmented linear function; according to the first sub-quantum circuit and each of the segment sub-quantum circuits, construct the sub-quantum circuit The quantum circuit corresponding to the above piecewise linear function.
  • the preparing the independent variable of the target piecewise linear function on the first qubit includes: for the probability distribution of the independent variable of the target piecewise linear function, obtaining 2 N sampling points from the probability distribution , preparing the independent variable values and probabilities corresponding to the 2 N sampling points on the N first qubits.
  • constructing a first sub-quantum circuit for comparing the independent variable with the abscissa of the segment point based on the first qubit and the segment point of the piecewise linear function Including: obtaining the auxiliary bit corresponding to the first qubit, and the comparison bit used to output the comparison result; according to the abscissa of the segmentation point, determining the to-be-constructed The quantum logic gate of the first sub-quantum circuit for comparison with the abscissa of the segment point, and combining the first qubit, the auxiliary bit and the comparison bit to construct the first sub-quantum circuit.
  • constructing a segmented sub-quantum circuit corresponding to each segment of the linear function in the segmented linear function based on the first qubit and the comparison bit of the output comparison result included in the first sub-quantum circuit including : Obtain the second qubit used to output the piecewise linear function; according to each piece of linear function of the piecewise linear function, correspondingly add a sub-logic gate containing parameters acting on the second qubit, and determine the The parameter value of the sub-logic gate containing the parameter is described; the sub-quantum circuit corresponding to each segment of the linear function in the segmented linear function is obtained by controlling the sub-logic gate containing the parameter through the first qubit and the comparison bit.
  • the target piecewise linear function is the return function of the target option; the method further includes: running the quantum circuit, and calculating the return of the target option according to the operation result of the quantum circuit.
  • the running the quantum circuit, and calculating the return of the target option according to the operation result of the quantum circuit includes: running the current quantum circuit, measuring the second qubit of the quantum circuit, and obtaining the Amplitude of the second qubit: performing amplitude estimation on the amplitude of the second qubit to obtain the expected value of the income function as the income of the target option.
  • the method further includes: converting the income of the target option into a present value.
  • Another embodiment of the present application provides a device for constructing a quantum circuit corresponding to a piecewise linear function, the device comprising: a preparation module, configured to prepare an argument of a target piecewise linear function on the first qubit; A first building block, configured to construct a first sub-quantum circuit for comparing the independent variable with the abscissa of the piecewise point based on the first qubit and the piecewise point of the piecewise linear function ; The second building block is used to construct a segmented sub-quantum circuit corresponding to each segment of the linear function in the segmented linear function based on the first qubit and the comparison bit of the output comparison result contained in the first sub-quantum circuit ; A third construction module, configured to construct a quantum circuit corresponding to the piecewise linear function according to the first sub-quantum circuit and each of the segmented sub-quantum circuits.
  • An embodiment of the present application provides a quantum circuit-based option combination income calculation method, the method includes: preparing the value of the target object and its probability distribution on the first qubit; determining the option combination of the target object The first income function of each option in the option, and according to the first income function, determine the second income function corresponding to the option combination; based on the first qubit and the second income function, construct and run the expression The quantum circuit of the income function; according to the operation result of the quantum circuit, the income of the option combination is calculated.
  • the preparing the value of the target object and its probability distribution on the first qubit includes: for the probability distribution of the value of the target object, obtaining 2N sampling points from the probability distribution, and converting the 2N The values and probabilities corresponding to the sampling points are prepared on the N first qubits.
  • determining the first income function of each option in the option combination of the target object, and determining the second income function corresponding to the option combination according to the first income function includes: for the option combination For each option in , substitute the value of the target object, strike price and option cost into the income function corresponding to the option to obtain the first income function; combine the first income functions corresponding to each option , to obtain the second income function corresponding to the option combination.
  • the constructing and running a quantum circuit representing a revenue function based on the first qubit and the second revenue function includes: constructing a quantum circuit including the first qubit and representing a revenue function; Inputting the preset parameters of the second revenue function into the quantum circuit; running the current quantum circuit to obtain the operation result of the current quantum circuit.
  • the running the current quantum circuit to obtain the running result of the current quantum circuit includes: running the current quantum circuit to measure the second qubit of the current quantum circuit to obtain the amplitude of the second qubit.
  • the calculation of the return of the option combination according to the operation result of the quantum circuit includes: performing amplitude estimation on the amplitude of the second qubit to obtain the expected value of the second return function as the The return on the option portfolio.
  • the method further includes: converting the income of the option combination into a present value.
  • a quantum circuit-based option combination income calculation device which includes: a preparation module for preparing the value of the target object and its probability distribution on the first qubit; a determination module , used to determine the first income function of each option in the option combination of the target object, and according to the first income function, determine the second income function corresponding to the option combination; the operation module is used for based on the The first qubit and the second income function construct and operate a quantum circuit representing the income function; the calculation module is used to calculate the income of the option combination according to the operation result of the quantum circuit.
  • Yet another embodiment of the present application provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the method described in any one of the above when running.
  • Yet another embodiment of the present application provides an electronic device, including a memory and a processor, a computer program is stored in the memory, and the processor is configured to run the computer program to perform any of the above-mentioned Methods.
  • a method for constructing a quantum circuit corresponding to a linear function can realize the representation of a linear function in the field of quantum computing, and fill in a gap in related technologies.
  • the method for constructing a quantum circuit corresponding to a piecewise linear function can realize the representation of a piecewise linear function in the field of quantum computing, and fill in a gap in related technologies.
  • a quantum circuit-based calculation method for option portfolio returns is provided herein.
  • the calculation of option income can be realized based on the quantum circuit when the sample size is large, the calculation can be accelerated in parallel, the efficiency and accuracy of option calculation can be improved, and the income calculation of multiple option combinations can be realized, which has better versatility.
  • Fig. 1 is a hardware structural block diagram of a computer terminal of a method for constructing a quantum circuit corresponding to a linear function provided in an embodiment.
  • FIG. 2 is a schematic flowchart of a method for constructing a quantum circuit corresponding to a linear function provided in an embodiment.
  • Fig. 3 is a schematic diagram of a quantum circuit corresponding to a linear function provided in the embodiment.
  • Fig. 4 is a schematic structural diagram of a quantum circuit construction device corresponding to a linear function provided in an embodiment.
  • FIG. 5 is a schematic flowchart of a method for constructing a quantum circuit corresponding to a piecewise linear function provided in an embodiment.
  • Figure 6 is a schematic circuit diagram of a quantum circuit comparator provided by the embodiment.
  • Fig. 7 is a schematic diagram of a logical OR gate provided by the embodiment.
  • Fig. 8 is a schematic diagram of a segmented sub-quantum circuit provided by the embodiment.
  • FIG. 9 is a schematic structural diagram of a quantum circuit construction device corresponding to a piecewise linear function provided in an embodiment.
  • Fig. 10 is a schematic flow chart of a quantum circuit-based option combination income calculation method provided by the embodiment.
  • Fig. 11 is a schematic diagram of a first sub-quantum circuit provided by the embodiment.
  • Fig. 12 is a schematic structural diagram of a quantum circuit-based option combination income calculation device provided by the embodiment.
  • the embodiments herein firstly provide a method for constructing a quantum circuit corresponding to a linear function, and the method can be applied to electronic equipment, such as a computer terminal, specifically, an ordinary computer, a quantum computer, and the like.
  • Fig. 1 is a hardware structural block diagram of a computer terminal of a method for constructing a quantum circuit corresponding to a linear function provided in an embodiment.
  • the computer terminal may include one or more (only one is shown in Figure 1) processors 102 (processors 102 may include but not limited to processing devices such as microprocessor MCU or programmable logic device FPGA, etc.) and a memory 104 for storing the quantum circuit-based option estimation method.
  • the above-mentioned computer terminal may further include a transmission device 106 and an input and output device 108 for communication functions.
  • the structure shown in FIG. 1 is only for illustration, and it does not limit the structure of the above computer terminal.
  • the computer terminal may also include more or fewer components than shown in FIG. 1 , or have a different configuration than that shown in FIG. 1 .
  • the memory 104 can be used to store software programs and modules of application software, such as the program instructions/modules corresponding to the construction method of the quantum circuit corresponding to the linear function in the embodiment of the present application, and the processor 102 runs the software program stored in the memory 104 and module, so as to execute various functional applications and data processing, that is, to realize the above-mentioned method.
  • 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.
  • the memory 104 may further include a memory that is remotely located relative to the processor 102, and these remote memories may be connected to a computer terminal through a network. Examples of the aforementioned 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 to receive or transmit data via a network.
  • the specific example of the above-mentioned network may include a wireless network provided by the communication provider of the computer terminal.
  • the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet.
  • the transmission device 106 may be a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet in a wireless manner.
  • RF Radio Frequency
  • a real quantum computer has a hybrid structure, which consists of two parts: one is a classical computer, which is responsible for performing classical calculation and control; the other is a quantum device, which is responsible for running quantum programs and realizing quantum computing.
  • the quantum program is a series of instruction sequences written in a quantum language such as QRunes that can be run on a quantum computer, which supports the operation of quantum logic gates and finally realizes quantum computing.
  • a quantum program is a series of instruction sequences that operate quantum logic gates in a certain sequence.
  • Quantum computing simulation is the process of simulating the quantum program corresponding to a specific problem using a virtual architecture built with the resources of an ordinary computer (that is, a quantum virtual machine). Often, quantum programs corresponding to specific problems need to be constructed.
  • the quantum program referred to in the embodiments here refers to a program written in a classical language that characterizes qubits and their evolution, in which qubits, quantum logic gates, etc. related to quantum computing are represented by corresponding classical codes.
  • quantum circuits are also called quantum logic circuits. They are the most commonly used general-purpose quantum computing models. They represent circuits that operate on qubits under an abstract concept. The components include qubits, circuits (timelines) , and various quantum logic gates, the results often need to be read out through quantum measurement operations.
  • the circuits can be regarded as connected by time, that is, the state of qubits evolves naturally with time, in the process according to The instruction of the Hamiltonian operator is operated until it encounters a logic gate.
  • a quantum program as a whole corresponds to a total quantum circuit, and the quantum program refers to the total quantum circuit, wherein the total number of qubits in the total quantum circuit is the same as the total number of qubits in the quantum program.
  • a quantum program can be composed of quantum circuits, measurement operations for qubits in quantum circuits, registers for saving measurement results, and control flow nodes (jump instructions).
  • a quantum circuit can contain tens, hundreds or even thousands of Tens of thousands of quantum logic gate operations.
  • the execution process of a quantum program is the process of executing all quantum logic gates according to a certain time sequence. It should be noted that timing refers to the time sequence in which a single quantum logic gate is executed.
  • Quantum logic gates are the basis of quantum circuits. Quantum logic gates include single-bit quantum logic gates, such as Hadamard gates (H gates, Hadamard gates), Pauli-X gates ( X gate), Pauli-Y gate (Y gate), Pauli-Z gate (Z gate), RX gate, RY gate, RZ gate, etc.; multi-bit quantum logic gates, such as CNOT gate, CR gate, iSWAP gate , Toffoli doors and more.
  • Quantum logic gates are generally represented by unitary matrices, and unitary matrices are not only in the form of matrices, but also a kind of operation and transformation.
  • the function of a quantum logic gate on a quantum state is calculated by multiplying the left side of the unitary matrix by the matrix corresponding to the right vector of the quantum state.
  • FIG. 2 is a schematic flowchart of a method for constructing a quantum circuit corresponding to a linear function provided in an embodiment, which may include the following steps.
  • the values of the independent variables may correspond to different probabilities.
  • 2 N sampling points can be obtained from the probability distribution, and the independent variable values and probabilities corresponding to the 2 N sampling points can be prepared to N first qubits (or sampling bits) superior.
  • the target piecewise linear function can be the return function of the option of the target object, and the independent variable is the value of the target object.
  • Target objects include but are not limited to: financial products, financial derivatives, underlying assets, etc.
  • Obtaining the value probability distribution data of the target object in advance can determine the value of the target object (such as a stock) after time t based on an option pricing model (such as Black-Scholes-MertonModel, Lake-Scholes model).
  • option pricing model such as Black-Scholes-MertonModel, Lake-Scholes model.
  • t is the expiration time
  • S t is the value of the target object at t
  • S 0 is the initial value
  • is the volatility parameter
  • W t is the asset value of the target object at t conforms to the geometric Brownian motion (GBM)
  • r is The yield parameter (i.e. the risk-free rate).
  • the distribution of Brownian motion W t is a normal distribution
  • the distribution of S t is a lognormal distribution
  • the value S t of the target object after the expiration time t is not a single point value, but conforms to the continuous probability
  • the continuous points of the distribution that is, for each point, there is value and corresponding distribution probability (also called value probability), so obtaining the value probability distribution data corresponding to S t is obtained
  • t i is each time point, is the value corresponding to each time point, is the corresponding probability distribution.
  • the normalization operation can be performed on the 2 N discrete probability density distribution points, that is, each Corresponding probabilities with 2 N The ratio of the square root of the corresponding probability sum of squares, as each The probability after normalization, and thus get 2 N discrete sampling points, each sampling point includes the value and the value probability corresponding to the value, that is
  • the discrete sampling point distribution can be used to represent the original continuous distribution, and the more sampling points, the larger the sampling interval, the better it can represent the original distribution pattern.
  • each eigenstate corresponding to the N first qubits can be determined according to the values corresponding to the 2 N sampling points, and the amplitude value of each eigenstate can be determined according to the value probability corresponding to the 2 N sampling points, to complete the preparation of each qubit in the N first qubits.
  • each eigenstate corresponds to 1 value, such as
  • the value probability of each value the amplitude of the corresponding eigenstate is determined, and the quantum amplitude encoding (ie preparation) is realized.
  • the encoded quantum state of 3 sampling bits represents the distribution information of the underlying asset when it expires.
  • the second qubit can be a preset one qubit, which can be called the result bit, and the sub-logic gate containing the parameter can be a rotary logic gate, such as an RY gate or the like.
  • a first parametric sublogic gate corresponding to the intercept of the target linear function can be added, and the first parametric sublogic gate acts on the second qubit;
  • the first parametric sub-logic gate can be set to one, which is not controlled; the second parametric sub-logic gate can be the same as the number of sampling bits, that is, N, which is sampled bit control.
  • N the number of sampling bits
  • Quantum logic gates need to be associated with sampled bits.
  • the parameter value of the first parametric sub-logic gate may be determined according to the intercept of the target linear function; and the parameter value of the second parametric sub-logic gate may be determined according to the slope of the target linear function.
  • its parameter value is the rotation angle value in the unitary matrix of the rotating logic gate.
  • the result bit in after preparing the independent variable distribution, the result bit res, and also includes the first parametric sub-logic gate RY(a 0 ) gate, and the second parametric sub-logic gate: receiving i 1 Real-controlled RY(a 1 ) gate...
  • the real-controlled RY(a n ) gate of i n the real control (solid dot) means that the quantum state of the control bit before execution is
  • the parameter a 0 in the RY(a 0 ) gate maps the intercept of the first linear function (the left endpoint function value of the domain), and the RY(a 1 ) gate to RY(a n )
  • the parameters a 1 to a n in the gate map the slope of the linear function of the first segment.
  • the linear function value f(x) can be obtained by measuring the amplitude of the resulting bit
  • the function of the linear function is realized, and for the specific independent variable value, the specific function value can be correspondingly output.
  • FIG. 4 is a schematic structural diagram of a quantum circuit-based option combination income calculation device provided by the embodiment, which corresponds to the process shown in FIG. 2.
  • the device includes: a preparation module 401 for linearizing the target The argument of the function is prepared on the first qubit; adding module 402, used to obtain the second qubit for outputting the target linear function, adding a parametric sublogic gate acting on the second qubit, and The parameter-containing sub-logic gate is controlled by the first qubit; the determination module 403 is configured to determine the parameter value of the parameter-containing sub-logic gate according to the target linear function, and obtain the quantum corresponding to the target linear function line.
  • the preparation module is configured to: for the probability distribution of the independent variable of the target linear function, obtain 2 N sampling points from the probability distribution, and obtain the independent variable values and probability values corresponding to the 2 N sampling points Prepared on N first qubits.
  • the adding module is used to: add the first parametric sub-logic gate corresponding to the intercept of the target linear function, and the first parametric sub-logic gate acts on the second qubit; respectively add The second parametric sub-logic gate corresponding to the slope of the target linear function, wherein a first qubit corresponds to a second parametric sub-logic gate, and the second parametric sub-logic gate acts on the second quantum bit and is controlled by the corresponding first qubit.
  • the determining module is configured to: determine the parameter value of the first parametric sub-logic gate according to the intercept of the target linear function; determine the second parametric logic gate according to the slope of the target linear function. Parameter values for parametric sub-logic gates.
  • the parametric sub-logic gate is an RY gate.
  • the embodiments here can realize the representation of linear functions in the field of quantum computing, and fill in the gaps in related technologies.
  • Yet another embodiment provides a storage medium, where a computer program is stored, wherein the computer program is configured to execute the steps in any one of the above method embodiments when running.
  • the above-mentioned storage medium may be configured to store a computer program for performing the following steps: S1, preparing the argument of the target linear function to the first qubit; S2, obtaining The second qubit of the target linear function, adding a parametric sublogic gate acting on the second qubit, and controlling the parametric sublogic gate through the first qubit; S3, according to the target The linear function determines the parameter value of the sub-logic gate containing the parameter, and obtains the quantum circuit corresponding to the target linear function.
  • the above-mentioned storage medium may include but not limited to: U disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), Various media that can store computer programs, such as removable hard disks, magnetic disks, or optical disks.
  • ROM read-only memory
  • RAM random access memory
  • Various media that can store computer programs such as removable hard disks, magnetic disks, or optical disks.
  • Yet another embodiment also provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform any one of the above method embodiments A step of.
  • the above-mentioned electronic device may further include a transmission device and an input-output device, wherein the transmission device is connected to the above-mentioned processor, and the input-output device is connected to the above-mentioned processor.
  • the above-mentioned processor may be configured to execute the following steps through a computer program: S1, prepare the argument of the target linear function on the first qubit; S2, acquire The second qubit of the linear function, adding a parametric sublogic gate acting on the second qubit, and controlling the parametric sublogic gate through the first qubit; S3, according to the target linear function, The parameter value of the sub-logic gate containing the parameter is determined to obtain the quantum circuit corresponding to the target linear function.
  • FIG. 5 is a schematic flowchart of a method for constructing a quantum circuit corresponding to a piecewise linear function provided in an embodiment, which may include the following steps.
  • the auxiliary bit corresponding to the first qubit and the comparison bit used to output the comparison result can be obtained; for example, the number of auxiliary bits is the same as that of the first qubit, both are N, and the comparison bit is set to 1 ;
  • the segmentation point determine the quantum logic gate of the first sub-quantum circuit to be constructed for comparing the argument with the abscissa of the segmentation point, and combine the first qubit , the auxiliary bit and the comparison bit, constructing the first sub-quantum circuit.
  • the segmentation point of the piecewise linear function refers to the intersection point between each piece of linear functions.
  • FIG. 6 is a schematic circuit diagram of a quantum comparator provided by the embodiment.
  • the sampling bit to be acted on each corresponding bit after preparation and the quantum logic gate on the corresponding auxiliary bit can be sequentially determined according to each bit coding value of the two's complement code of the abscissa of the segmentation point.
  • the corresponding quantum logic gate is a Toffoli gate
  • the corresponding quantum logic gate is a logical OR gate.
  • a logical OR gate can be constructed from a Toffoli gate and an X gate, and other quantum logic gates equivalent to Toffoli gates and logical OR gates are also reasonable and feasible. As shown in the circuit on the left side of FIG. 7 , a construction method of a logical OR gate may sequentially include three NOT gates, one Toffoli gate and two NOT gates.
  • the second qubit for outputting the piecewise linear function may be obtained.
  • the second qubit can be a preset qubit, which can be called the result bit.
  • each segment of the linear function of the piecewise linear function correspondingly add a sub-logic gate containing a parameter acting on the second qubit, and determine a parameter value of the sub-logic gate containing a parameter.
  • Each segment of linear function corresponds to a group of sub-logic gates containing parameters, such as rotary logic gates.
  • the parameter value (rotation angle) of the sublogic gate containing the parameter can be determined according to the intercept and the slope of each segment of the linear function.
  • the sub-parameter logic gate is controlled by the first qubit and the comparison bit to obtain a segmented sub-quantum circuit corresponding to each segment of the linear function in the segmented linear function.
  • the logic gates related to the intercept are not controlled by the first qubit, and the logic gates related to the slope are controlled by the first qubit, and are selectively controlled by the comparison bits according to the specific conditions of each segment of the linear function. control.
  • the target piecewise linear function is composed of two pieces of linear functions.
  • Figure 8 is a schematic structural diagram of a corresponding segmented sub-quantum circuit, including: prepared sampling bits i 1 ... in , comparison bit c, result bit res, and two sets of quantum logic gates RY gate, wherein, the first group includes: RY(a 0 ) gate, RY(a 1 ) gate actually controlled by i 1 ...
  • RY(a n ) gate actually controlled by i n real control (solid dot ) indicates that the quantum state of the control bit before execution is
  • the second group includes : RY(b 0 ) gate, RY(b 1 ) gate controlled by i 1 and c... RY(b n ) gate controlled by i n and c, corresponding to the second segment linear function of the piecewise linear function , that is, the second segmented sub-quantum circuit.
  • the independent variable is first smaller than the abscissa of the segmentation point, so the first group of logic gates corresponding to the first segment of the linear function has nothing to do with the comparison bit; the second group of logic is executed only after the independent variable is greater than the abscissa of the segmentation point
  • the second group of logic gates needs to be associated with the comparison bits.
  • the parameter a 0 in the RY(a 0 ) gate maps the intercept of the first linear function (the function value of the left endpoint of the domain), and the RY(a 1 ) gate to the RY(a n ) gate
  • the parameters of the second group of logic gates are determined in the same way. It should be noted that b 0 is mapped to: the value of the segment point function between the second segment function and the first segment function minus the left endpoint function value of the previous segment function Function value, the mapping from b 1 to b n is: the slope value after subtracting the slope of the previous function from the slope of the second function.
  • the target piecewise linear function may be the payoff function f(S T ) of the target option.
  • the quantum circuit can also be operated, and the return of the target option can be calculated according to the operation result of the quantum circuit.
  • S t is the option value
  • K is the strike price
  • C is the option cost. It can be seen that an option corresponds to a revenue function, which is a piecewise linear function.
  • the payoff function for buying a call option is:
  • the strike price K 0 1
  • the option cost C 0 1
  • the left endpoint is 0,
  • the function value of the left endpoint is -1
  • the abscissa of the segmentation point is the strike price 1;
  • the payoff function for a short call option is:
  • strike price K 1 2
  • option cost C 1 2
  • the left endpoint is 0, the function value of the left endpoint is 2, and the abscissa of the segmentation point is the strike price 2.
  • the current quantum circuit can be run, and the second qubit of the quantum circuit can be measured to obtain the amplitude of the second qubit; the amplitude of the second qubit can be estimated to obtain the income function
  • the expected value E[f(S T )] is used as the return of the target option.
  • Amplitude estimation can be realized by the quantum amplitude estimation algorithm QAE and its improved or modified version.
  • One preferred method is: obtain the upper limit value of the current argument corresponding to the amplitude value of the result bit and the lower limit value of the current argument, and calculate the current argument
  • the first difference between the upper bound value and the lower bound value of the current argument is used as the target difference; when the target difference is greater than the preset accuracy threshold, according to the preset intermediate variable parameter, the upper bound value of the current argument and the lower bound value of the current argument , determine the next angle magnification factor and the next marking parameter corresponding to the next iterative step; control the preset magnification quantum circuit to amplify the quantum circuit where the result bit is located, and according to the total number of preset observations, Measure the quantum state of the result bit in the quantum circuit where the amplified result bit is located; according to the current argument upper limit value, the current argument lower limit value, the next angle amplification factor, the next mark parameter and the quantum state of the result bit State measurement results,
  • an amplitude value of the resulting bit is determined.
  • the method for estimating the amplitude value of the qubit (i.e. the result bit) used in the above steps by determining the amplification parameters of the amplified quantum circuit in each iterative step, continuously iterates so that the difference between the upper limit value and the lower limit value of the argument angle is within the accuracy threshold
  • the amplitude value cannot converge and improve the accuracy of the amplitude value.
  • the income of the target option may also be converted into a present value.
  • a conversion formula may be: E[f(S T )]*e -rt .
  • the representation of linear functions can be realized in the field of quantum computing and fill in the gaps in related technologies.
  • Fig. 9 is a schematic structural diagram of a quantum circuit-based option combination income calculation device provided by the embodiment, which corresponds to the process shown in Fig. 5, and the device includes: a preparation module 601 for dividing the target The independent variable of the piecewise linear function is prepared on the first qubit; the first construction module 602 is used to construct the independent variable and the piecewise point of the piecewise linear function based on the first qubit and the The first sub-quantum circuit for comparing the abscissa of the segmentation point; the second construction module 603, configured to construct the first sub-quantum circuit based on the first qubit and the comparison bit of the output comparison result included in the first sub-quantum circuit A piecewise sub-quantum circuit corresponding to each piece of linear function in the piecewise linear function; a third construction module 604, configured to construct the piecewise linear function corresponding to the first sub-quantum circuit and each of the piecewise sub-quantum circuits quantum circuits.
  • the preparation module is configured to: for the probability distribution of the independent variable of the target linear function, obtain 2 N sampling points from the probability distribution, and obtain the independent variable values and probability values corresponding to the 2 N sampling points Prepared on N first qubits.
  • the first building module is configured to: acquire auxiliary bits corresponding to the first qubit, and comparison bits used to output comparison results; determine the to-be-constructed, A quantum logic gate of the first sub-quantum circuit for comparing the independent variable with the abscissa of the segmentation point, and combining the first qubit, the auxiliary bit and the comparison bit, constructing the The first sub-quantum circuit.
  • the second building block is configured to: obtain a second qubit for outputting the piecewise linear function; according to each piece of linear function of the piecewise linear function, correspondingly add and act on the second A qubit-containing sub-logic gate containing parameters, and determining the parameter value of the sub-logic gate containing parameters; controlling the sub-logic gate containing parameters through the first qubit and the comparison bit to obtain the piecewise linear function
  • the sub-quantum circuits corresponding to each segment of the linear function in is configured to: obtain a second qubit for outputting the piecewise linear function; according to each piece of linear function of the piecewise linear function, correspondingly add and act on the second A qubit-containing sub-logic gate containing parameters, and determining the parameter value of the sub-logic gate containing parameters; controlling the sub-logic gate containing parameters through the first qubit and the comparison bit to obtain the piecewise linear function
  • the sub-quantum circuits corresponding to each segment of the linear function in is configured to: obtain a second qubit for outputting the piecewise linear function; according
  • the target piecewise linear function is the profit function of the target option; the device further includes: a calculation module, configured to run the quantum circuit, and calculate the target option’s profit function according to the operation result of the quantum circuit. income.
  • the calculation module is configured to: run the current quantum circuit, measure the second qubit of the quantum circuit, and obtain the amplitude of the second qubit; perform amplitude estimation on the amplitude of the second qubit, The expected value of the income function is obtained as the income of the target option.
  • the device further includes: a conversion module, configured to convert the income of the target option into a present value.
  • a conversion module configured to convert the income of the target option into a present value.
  • the representation of linear functions can be realized in the field of quantum computing and fill in the gaps in related technologies.
  • Yet another embodiment provides a storage medium, where a computer program is stored, wherein the computer program is configured to execute the steps in any one of the above method embodiments when running.
  • the above-mentioned storage medium may be configured to store a computer program for performing the following steps: S11, prepare the argument of the target piecewise linear function on the first qubit; S12, based on the The first qubit and the segment point of the piecewise linear function, constructing a first sub-quantum circuit for comparing the argument with the abscissa of the segment point; S13, based on the first quantum Bits and the comparison bits of the output comparison results included in the first sub-quantum circuit, construct a segmented sub-quantum circuit corresponding to each segment of the linear function in the piecewise linear function; S14, according to the first sub-quantum circuit and each The segmented sub-quantum circuit is used to construct the quantum circuit corresponding to the segmented linear function.
  • Yet another embodiment also provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform any one of the above method embodiments A step of.
  • the above-mentioned electronic device may further include a transmission device and an input-output device, wherein the transmission device is connected to the above-mentioned processor, and the input-output device is connected to the above-mentioned processor.
  • the above-mentioned processor may be configured to execute the following steps through a computer program: S11, prepare the argument of the target piecewise linear function on the first qubit; S12, based on the first The qubit and the segment point of the piecewise linear function, constructing a first sub-quantum circuit for comparing the independent variable with the abscissa of the segment point; S13, based on the first qubit and the The comparison bits of the output comparison results included in the first sub-quantum circuit, construct the segment sub-quantum circuit corresponding to each segment of the linear function in the segmented linear function; S14, according to the first sub-quantum circuit and each of the segment sub-quantum circuits A quantum circuit, constructing a quantum circuit corresponding to the piecewise linear function.
  • FIG. 10 is a schematic flow chart of a quantum circuit-based option combination income calculation method provided by an embodiment, which may include the following steps.
  • 2 N sampling points can be obtained from the probability distribution, and the values and probabilities corresponding to the 2 N sampling points can be prepared on the N first qubits.
  • a preferred way to determine the sampling interval is: obtain the value mean and value standard deviation corresponding to the value in the value probability distribution data; determine the left endpoint according to the difference between the value mean and three times the value standard deviation, and according to The left endpoint and six times the value standard deviation determine the right endpoint; according to the left endpoint and the right endpoint, determine the sampling interval for 2 N sampling points.
  • the sampling interval can be adjusted accordingly. First calculate the value mean and value standard deviation of the value in the value probability distribution data, and then determine the left endpoint based on the difference between the value mean and three times the value standard deviation, that is, subtract three times the value standard deviation from the value mean value as the left endpoint of the sampling interval ; Then add about 6 times the value standard deviation to the right based on the left endpoint, as the right endpoint of the sampling interval.
  • the determined left end point can be corrected based on whether the determined left end point falls within the distribution range of the sampled data, and the right end point can be determined based on the corrected left end point to ensure the accuracy of the sampling interval. Integrity, to avoid narrowing the sampling interval due to the constraints of actual sampling points.
  • each eigenstate corresponding to the N qubits (first qubits, or sampling bits) can be determined according to the values corresponding to the 2 N sampling points, and according to the value probability corresponding to the 2 N sampling points
  • the amplitude value of each eigenstate is determined to complete the preparation of each qubit in the N qubits.
  • S2202. Determine the first income function of each option in the option combination of the target object, and determine the second income function corresponding to the option combination according to the first income function;
  • the value of the target object, the strike price and the option cost can be substituted into the income function corresponding to the option to obtain the first income function;
  • the corresponding first income functions are combined to obtain the second income function corresponding to the option combination.
  • each first income function can be linearly combined to obtain a second income function corresponding to the option combination.
  • it can include: processing the first income function corresponding to each option, so that The option cost corresponding to the processed function is returned to 0; according to the size of the strike price, determine the processed first income function of the combined option and the processed first income function of the option to be combined, and determine the first income function of the combined option
  • the segment point array, segment slope array and segment point function value array correspond to the second income function of the cost-free option combination; according to the cost price of each option, the second income function of the cost-free option combination is processed to obtain A second payoff function corresponding to the option portfolio that includes costs.
  • the user buys two options, one is a call option, and the first income function is:
  • the other is selling a call option
  • the first income function is:
  • segment point, segment slope, and function value of the segment point can be used as parameters to represent a segmented linear function.
  • a specific combination of the first income function is:
  • the processed income function of each option is traversed in ascending order of strike price, and f′ 0 (S t ) with the smallest strike price is taken as the first income function (f′ 0 (S t )
  • f′ 1 (S t ) is used as the first income function of the current option to be combined after processing;
  • the segment point array (referring to the abscissa), the segment slope array, and the segment point function value array are the parameters of f′ 0 (S t ), which are respectively: ⁇ 0, 1 ⁇ , ⁇ 0, 1 ⁇ , ⁇ 0, 0 ⁇ ; it can be seen that the intersection point of the function and the abscissa axis is the exercise price point;
  • the current option to be combined is bearish, then add the segmented slope of the part whose slope is not 0 in the combined option to the segmented slope array, and subtract 1 from all segmented slopes before adding the segmented slope array (if the current option to be combined is a buy) or add 1 (if the current option to be combined is a sell), and update other values in the function value array according to the value in the function value array added to the segmentation point and the new slope.
  • the second income function corresponds to the segment point array ⁇ 0, 1, 2 ⁇ , the segment slope array ⁇ 0, 1, 0 ⁇ and the segment point function value array ⁇ 1, 1, 2 ⁇ .
  • the preset parameters may include: the above-mentioned segment point array, segment slope array, and segment point function value array parameters used to represent the second income function, as well as the definition domain and value range of the second income function, and so on.
  • the amplitude of the second qubit can be obtained by running the current quantum circuit and measuring the second qubit of the current quantum circuit.
  • the second qubit may be a preset one qubit, called the result bit. More specifically, the amplitude of the second qubit may be the amplitude of the
  • the revenue function is a piecewise linear function
  • the first sub-quantum circuit representing the linear function of each segment, and the second sub-quantum circuit ( Quantum Comparator) to form a quantum circuit representing a piecewise linear function.
  • the abscissa of the segment points in the second revenue function is the strike price.
  • FIG. 6 is a schematic circuit diagram of a quantum comparator provided by the embodiment. Since the value S t is prepared on N sampling bits, it is necessary to set N auxiliary bits corresponding to the N sampling bits one-to-one, as the carry qubit in the comparison process, and the carry qubit is used to store the quantum state corresponding to the encoding benefit Each digit of and each digit of the complement of the strike price.
  • the sampling bit to be applied to each corresponding bit after preparation and the quantum logic gate corresponding to the auxiliary bit can be sequentially determined according to each bit coding value of the two's complement code corresponding to the strike price.
  • the corresponding quantum logic gate is a Toffoli gate
  • the corresponding quantum logic gate is a logical OR gate. It should be noted that only when the coded value of the first bit of the two's complement code is 0, it corresponds to the non-quantum logic gate operation; when the coded value of the first bit of the two's complement code is 1, it corresponds to the CNOT gate operation.
  • the comparison result between the independent variable ST and the strike price K is obtained, and then the first sub-quantum circuit is operated to obtain the amplitude of the second qubit of the first sub-quantum circuit.
  • Two quantum comparator circuits are required, corresponding to the exercise price K1 and K2 respectively, and the corresponding comparison bits are c 1 and c 2 . Run the two quantum comparator circuits to obtain comparison results between the independent variable ST and the strike price K1, and between the independent variable ST and the strike price K2 on c 1 and c 2 , and then run the first sub-quantum circuit.
  • the first sub-quantum circuit includes: prepared sampling bits i 1 ... in , comparison bits c 1 and c 2 , result bit res, and three groups of quantum logic gates, wherein the first group Including: RY( ⁇ 0 ) gate, RY( ⁇ 1 ) gate controlled by i 1 ...
  • the actual control indicates that the control bit is executed before
  • the quantum logic gate is executed, which corresponds to the first segment function of the piecewise linear function (the second income function);
  • the second group includes: RY(a 0 ) gate, receiving i 1 and The RY(a 1 ) gate actually controlled by c 1 ...the RY(a n ) gate actually controlled by i n and c 1 corresponds to the second segment function of the piecewise linear function;
  • the third group includes: RY(b 0 ) The gate, the RY(b 1 ) gate controlled by i 1 and c 2 ... the RY(b n ) gate controlled by i n and c 2 corresponds to the third segment function of the piecewise linear function.
  • the parameter ⁇ 0 in the RY( ⁇ 0 ) gate maps the left-end segmental point function value of the first segment function
  • the parameters ⁇ 1 in the RY( ⁇ 1 ) gate to RY( ⁇ n ) gate ⁇ n maps the slope of the first segment function.
  • the parameters of the second group and the third group of logic gates are determined in the same way. It should be noted that a 0 is mapped to: the value of the left segment point function value of the second segment function minus the left segment point function value of the previous segment function
  • the function value of a 1 to a n is mapped to: the slope value of the slope of the second function minus the slope of the previous function, and so on for the third group.
  • the value after mapping can pay attention to the nature of the trigonometric function itself, which can usually be monotonous in the range of ⁇ /4 Constructs a one-to-one mapping on an interval.
  • the amplitude of the second qubit can be estimated to obtain the expected value E[f(S T )] of the second income function as the income of the option combination.
  • Amplitude estimation can be realized by the quantum amplitude estimation algorithm QAE and its improved or modified version.
  • One preferred method is: obtain the upper limit value of the current argument corresponding to the amplitude value of the result bit and the lower limit value of the current argument, and calculate the current argument
  • the first difference between the upper bound value and the lower bound value of the current argument is used as the target difference; when the target difference is greater than the preset accuracy threshold, according to the preset intermediate variable parameter, the upper bound value of the current argument and the lower bound value of the current argument , determine the next angle magnification factor and the next marking parameter corresponding to the next iterative step; control the preset magnification quantum circuit to amplify the quantum circuit where the result bit is located, and according to the total number of preset observations, Measure the quantum state of the result bit in the quantum circuit where the amplified result bit is located; according to the current argument upper limit value, the current argument lower limit value, the next angle amplification factor, the next mark parameter and the quantum state of the result bit State measurement results,
  • the method for estimating the amplitude value of the qubit (i.e. the result bit) used in the above steps by determining the amplification parameters of the amplified quantum circuit in each iterative step, continuously iterates so that the difference between the upper limit value and the lower limit value of the argument angle is within the accuracy threshold
  • the amplitude value cannot converge and improve the accuracy of the amplitude value.
  • its basis principle and more detailed implementation process can be found in Chinese patent literature, application number 202011591351.6, application date December 29, 2020, application name "quantum circuit amplitude estimation method, device, storage medium and electronic device", here No longer.
  • the amplitude of the second qubit can be a linear function of S T
  • the expected value E[f(S T )] of the second revenue function can be inversely solved.
  • the return of the option portfolio can also be converted into a present value.
  • a conversion formula may be: E[f(S T )]*e -rt .
  • the calculation of option income can be realized based on the quantum circuit when the sample size is large, the calculation can be accelerated in parallel, the efficiency and accuracy of option calculation can be improved, and the income calculation of multiple option combinations can be realized, which has good versatility.
  • Figure 12 is a quantum circuit-based option combination income calculation device provided by the embodiment, the device includes: a preparation module 2601, which is used to prepare the value of the target object and its probability distribution on the first qubit
  • the determination module 2602 is used to determine the first income function of each option in the option combination of the target object, and according to the first income function, determine the second income function corresponding to the option combination;
  • the operation module 2603 Constructing and operating a quantum circuit representing a revenue function based on the first qubit and the second revenue function;
  • a calculation module 2604 configured to calculate the revenue of the option combination according to the operation result of the quantum circuit.
  • the preparation module is used to: for the probability distribution of the value of the target object, obtain 2 N sampling points from the probability distribution, and prepare the values and probabilities corresponding to the 2 N sampling points to N on the first qubit.
  • the determination module is configured to: for each option in the option combination, substitute the value of the target object, the strike price and the option cost into the income function corresponding to the option to obtain the first income function ; Combine the first income functions corresponding to each option to obtain the second income function corresponding to the option combination.
  • the running module includes: a construction unit, configured to construct a quantum circuit containing the first qubit and representing a revenue function; an input unit, configured to set the preset parameters of the second revenue function, input into the quantum circuit; an operating unit configured to operate the current quantum circuit to obtain an operation result of the current quantum circuit.
  • the running unit is configured to: run the current quantum circuit, measure the second qubit of the current quantum circuit, and obtain the amplitude of the second qubit.
  • the calculation module is configured to: perform amplitude estimation on the amplitude of the second qubit to obtain the expected value of the second income function as the income of the option combination.
  • the device further includes: a conversion module, configured to convert the income of the option combination into a present value.
  • a conversion module configured to convert the income of the option combination into a present value.
  • the calculation of option income can be realized based on the quantum circuit when the sample size is large, the calculation can be accelerated in parallel, the efficiency and accuracy of option calculation can be improved, and the income calculation of multiple option combinations can be realized, which has good versatility.
  • Yet another embodiment provides a storage medium, where a computer program is stored, wherein the computer program is configured to execute the steps in any one of the above method embodiments when running.
  • the above-mentioned storage medium may be configured to store a computer program for performing the following steps: S21, prepare the value of the target object and its probability distribution on the first qubit; S22, determine the The first income function of each option in the option combination of the target object, and according to the first income function, determine the second income function corresponding to the option combination; S23, based on the first qubit and the second qubit 2. Revenue function, constructing and running a quantum circuit representing the revenue function; S24, calculating the revenue of the option combination according to the operation result of the quantum circuit.
  • Yet another embodiment also provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform any one of the above method embodiments A step of.
  • the above-mentioned electronic device may further include a transmission device and an input-output device, wherein the transmission device is connected to the above-mentioned processor, and the input-output device is connected to the above-mentioned processor.
  • the above-mentioned processor may be configured to execute the following steps through a computer program: S21, prepare the value of the target object and its probability distribution on the first qubit; S222, determine the target object The first income function of each option in the option combination, and according to the first income function, determine the second income function corresponding to the option combination; S3, based on the first qubit and the second income function Constructing and running a quantum circuit representing a revenue function; S24, calculating the revenue of the option combination according to the operation result of the quantum circuit.

Abstract

公开了一种线性函数对应的量子线路的构建方法及装置,方法包括:将目标线性函数的自变量制备到第一量子比特上;获取用于输出目标线性函数的第二量子比特,添加作用于第二量子比特的含参量子逻辑门,并通过第一量子比特控制含参量子逻辑门;根据目标线性函数,确定含参量子逻辑门的参数值,得到目标线性函数对应的量子线路。利用本发明实施例,能够实现线性函数在量子计算领域中的表示,并填补相关技术的空白。。 (图2)

Description

一种线性函数对应的量子线路的构建方法及装置
相关申请的交叉引用
本专利申请要求于2021年05月28日提交的、发明名称为“一种基于量子线路的期权组合收益计算方法及装置”、申请号为202110593126.4的中国专利申请;于2021年05月28日提交的、发明名称为“一种线性函数对应的量子线路的构建方法及装置”、申请号为202110595092.2的中国专利申请;以及于2021年05月28日提交的、发明名称为“一种分段线性函数对应的量子线路的构建方法及装置”、申请号为202110595106.0的中国专利申请的优先权,该专利申请在此全部引入作为参考。
技术领域
本公开属于量子计算技术领域,特别是一种线性函数对应的量子线路的构建方法及装置。
背景技术
量子计算机是一类遵循量子力学规律进行高速数学和逻辑运算、存储及处理量子信息的物理装置。当某个装置处理和计算的是量子信息,运行的是量子算法时,它就是量子计算机。量子计算机因其具有相对普通计算机更高效的处理数学问题的能力,例如,能将破解RSA密钥的时间从数百年加速到数小时,故成为一种正在研究中的关键技术。
期权定价是金融领域中常见的一种价格标的资产的价格预测手段。目前期权定价一般通过经典蒙特卡罗法进行期权估计,但是该方法需要较大样本量进行样本采集,从而增加了期权估计的计算量,降低了期权估算效率。
目前,经典领域的线性函数在各种场景中应用广泛,但量子计算中关于线性函数的实现还是一个亟待解决的问题。
发明内容
本公开的一个目的是提供一种线性函数对应的量子线路的构建方法及装置,以解决在量子计算中实现线性函数的技术问题。
本申请的一个实施例提供了一种线性函数对应的量子线路的构建方法,所述方法包括:将目标线性函数的自变量制备到第一量子比特上;获取用于输出所述目标线性函数的第二量子比特,添加作用于所述第二量子比特的含参量子逻辑门,并通过所述第一量子比特控制所述含参量子逻辑门;根据所述目标线性函数,确定所述含参量子逻辑门的参数值,得到所述目 标线性函数对应的量子线路。
本申请的又一实施例提供了一种线性函数对应的量子线路的构建装置,所述装置包括:制备模块,用于将目标线性函数的自变量制备到第一量子比特上;添加模块,用于获取用于输出所述目标线性函数的第二量子比特,添加作用于所述第二量子比特的含参量子逻辑门,并通过所述第一量子比特控制所述含参量子逻辑门;确定模块,用于根据所述目标线性函数,确定所述含参量子逻辑门的参数值,得到所述目标线性函数对应的量子线路。
本申请的一个实施例提供了一种分段线性函数对应的量子线路的构建方法,所述方法包括:将目标分段线性函数的自变量制备到第一量子比特上;基于所述第一量子比特和所述分段线性函数的分段点,构建用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路;基于所述第一量子比特和所述第一子量子线路包含的输出比较结果的比较比特,构建所述分段线性函数中每一段线性函数对应的分段子量子线路;根据所述第一子量子线路和各所述分段子量子线路,构建所述分段线性函数对应的量子线路。
可选的,所述将目标分段线性函数的自变量制备到第一量子比特上,包括:针对目标分段线性函数的自变量的概率分布,从所述概率分布中获取2 N个采样点,将所述2 N个采样点对应的自变量值以及概率制备至N个第一量子比特上。
可选的,所述基于所述第一量子比特和所述分段线性函数的分段点,构建用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路,包括:获取与所述第一量子比特对应的辅助比特,以及用于输出比较结果的比较比特;根据所述分段点横坐标,确定待构建的、用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路的量子逻辑门,并结合所述第一量子比特、所述辅助比特和所述比较比特,构建所述第一子量子线路。
可选的,所述基于所述第一量子比特和所述第一子量子线路包含的输出比较结果的比较比特,构建所述分段线性函数中每一段线性函数对应的分段子量子线路,包括:获取用于输出所述分段线性函数的第二量子比特;根据所述分段线性函数的每一段线性函数,对应添加作用于所述第二量子比特的含参量子逻辑门,并确定所述含参量子逻辑门的参数值;通过所述第一量子比特和所述比较比特控制所述含参量子逻辑门,得到所述分段线性函数中每一段线性函数对应的分段子量子线路。
可选的,所述目标分段线性函数为目标期权的收益函数;所述方法还包括:运行所述量子线路,根据所述量子线路的运行结果,计算所述目标期权的收益。
可选的,所述运行所述量子线路,根据所述量子线路的运行结果,计算所述目标期权的收益,包括:运行当前量子线路,测量所述量子线路的第二量子比特,得到所述第二量子比特的振幅;对所述第二量子比特的振幅进行振幅估计,得到所述收益函数的期望值,作为所述目标期权的收益。
可选的,所述方法还包括:将所述目标期权的收益折算为现值。
本申请的又一实施例提供了一种分段线性函数对应的量子线路的构建装 置,所述装置包括:制备模块,用于将目标分段线性函数的自变量制备到第一量子比特上;第一构建模块,用于基于所述第一量子比特和所述分段线性函数的分段点,构建用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路;第二构建模块,用于基于所述第一量子比特和所述第一子量子线路包含的输出比较结果的比较比特,构建所述分段线性函数中每一段线性函数对应的分段子量子线路;第三构建模块,用于根据所述第一子量子线路和各所述分段子量子线路,构建所述分段线性函数对应的量子线路。
本申请的一个实施例提供了一种基于量子线路的期权组合收益计算方法,所述方法包括:将目标对象的价值及其概率分布制备到第一量子比特上;确定所述目标对象的期权组合中每支期权的第一收益函数,并根据所述第一收益函数,确定所述期权组合对应的第二收益函数;基于所述第一量子比特和所述第二收益函数,构建和运行表示收益函数的量子线路;根据所述量子线路的运行结果,计算所述期权组合的收益。
可选的,所述将目标对象的价值及其概率分布制备到第一量子比特上,包括:针对目标对象的价值的概率分布,从所述概率分布中获取2N个采样点,将所述2N个采样点对应的价值以及概率制备至N个第一量子比特上。
可选的,所述确定所述目标对象的期权组合中每支期权的第一收益函数,并根据所述第一收益函数,确定所述期权组合对应的第二收益函数,包括:针对期权组合中的每支期权,将所述目标对象的价值、行权价和期权成本,代入该支期权对应的收益函数中,得到第一收益函数;将每支期权分别对应的第一收益函数进行组合,得到所述期权组合对应的第二收益函数。
可选的,所述基于所述第一量子比特和所述第二收益函数,构建和运行表示收益函数的量子线路,包括:构建包含所述第一量子比特的、表示收益函数的量子线路;将所述第二收益函数的预设参数,输入所述量子线路中;运行当前量子线路,得到所述当前量子线路的运行结果。
可选的,所述运行当前量子线路,得到所述当前量子线路的运行结果,包括:运行当前量子线路,测量所述当前量子线路的第二量子比特,得到所述第二量子比特的振幅。
可选的,所述根据所述量子线路的运行结果,计算所述期权组合的收益,包括:对所述第二量子比特的振幅进行振幅估计,得到所述第二收益函数的期望值,作为所述期权组合的收益。
可选的,所述方法还包括:将所述期权组合的收益折算为现值。
本申请的又一实施例提供了一种基于量子线路的期权组合收益计算装置,所述装置包括:制备模块,用于将目标对象的价值及其概率分布制备到第一量子比特上;确定模块,用于确定所述目标对象的期权组合中每支期权的第一收益函数,并根据所述第一收益函数,确定所述期权组合对应的第二收益函数;运行模块,用于基于所述第一量子比特和所述第二收益函数,构建和运行表示收益函数的量子线路;计算模块,用于根据所述量 子线路的运行结果,计算所述期权组合的收益。
本申请的又一实施例提供了一种存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行上述任一项中所述的方法。
本申请的又一实施例提供了一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一项中所述的方法。
可选地或另选地,这里提供的一种线性函数对应的量子线路的构建方法,可以实现线性函数在量子计算领域中的表示,并填补相关技术的空白。
可选地或另选地,这里提供的一种分段线性函数对应的量子线路的构建方法,可以在量子计算领域中实现分段线性函数的表示,并填补相关技术的空白。
可选地或另选地,这里提供的一种基于量子线路的期权组合收益计算方法。在一个实施例中,可在样本量较大时基于量子线路实现期权收益计算,对计算进行并行加速,提高了期权计算效率和准确率,并且实现对多支期权组合进行收益计算,具备较好的通用性。
附图说明
图1为实施例提供的一种线性函数对应的量子线路的构建方法的计算机终端的硬件结构框图。
图2为实施例提供的一种线性函数对应的量子线路的构建方法的流程示意图。
图3为实施例提供的一种线性函数对应的量子线路示意图。
图4为实施例提供的一种线性函数对应的量子线路的构建装置的结构示意图。
图5为实施例提供的一种分段线性函数对应的量子线路的构建方法的流程示意图。
图6为实施例提供的一种量子线路比较器线路示意图;
图7为实施例提供的一种逻辑或门示意图;
图8为实施例提供的一种分段子量子线路示意图;
图9为实施例提供的一种分段线性函数对应的量子线路的构建装置的结构示意图。
图10为实施例提供的一种基于量子线路的期权组合收益计算方法的流程示意图;
图11为实施例提供的一种第一子量子线路示意图;
图12为实施例提供的一种基于量子线路的期权组合收益计算装置的结构示意图。
具体实施方式
下面通过参考附图描述的实施例是示例性的,仅用于解释本发明,而不能解释为对本发明的限制。
这里的实施例首先提供了一种线性函数对应的量子线路的构建方法,该方法可以应用于电子设备,如计算机终端,具体如普通电脑、量子计算机等。
下面以运行在计算机终端上为例对其进行详细说明。图1为实施例提供的一种线性函数对应的量子线路的构建方法的计算机终端的硬件结构框图。如图1所示,计算机终端可以包括一个或多个(图1中仅示出一个)处理器102(处理器102可以包括但不限于微处理器MCU或可编程逻辑器件FPGA等的处理装置)和用于存储基于量子线路的期权估计方法的存储器104,可选地,上述计算机终端还可以包括用于通信功能的传输装置106以及输入输出设备108。本领域普通技术人员可以理解,图1所示的结构仅为示意,其并不对上述计算机终端的结构造成限定。例如,计算机终端还可包括比图1中所示更多或者更少的组件,或者具有与图1所示不同的配置。
存储器104可用于存储应用软件的软件程序以及模块,如本申请实施例中的线性函数对应的量子线路的构建方法对应的程序指令/模块,处理器102通过运行存储在存储器104内的软件程序以及模块,从而执行各种功能应用以及数据处理,即实现上述的方法。存储器104可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器104可进一步包括相对于处理器102远程设置的存储器,这些远程存储器可以通过网络连接至计算机终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。
传输装置106用于经由一个网络接收或者发送数据。上述的网络具体实例可包括计算机终端的通信供应商提供的无线网络。在一个实例中,传输装置106包括一个网络适配器(Network Interface Controller,NIC),其可通过基站与其他网络设备相连从而可与互联网进行通讯。在一个实例中,传输装置106可以为射频(Radio Frequency,RF)模块,其用于通过无线方式与互联网进行通讯。
需要说明的是,真正的量子计算机是混合结构的,它包含两大部分:一部分是经典计算机,负责执行经典计算与控制;另一部分是量子设备,负责运行量子程序进而实现量子计算。而量子程序是由量子语言如QRunes语言编写的一串能够在量子计算机上运行的指令序列,实现了对量子逻辑门操作的支持,并最终实现量子计算。具体的说,量子程序就是一系列按照一定时序操作量子逻辑门的指令序列。
在实际应用中,因受限于量子设备硬件的发展,通常需要进行量子计算模拟以验证量子算法、量子应用等等。量子计算模拟即借助普通计算机的资源搭建的虚拟架构(即量子虚拟机)实现特定问题对应的量子程序的模拟运行的过程。通常,需要构建特定问题对应的量子程序。这里的实施例所指量子程序,即是经典语言编写的表征量子比特及其演化的程序,其中与量子计算相关的量子比特、量子逻辑门等等均有相应的经典代码表示。
量子线路作为量子程序的一种体现方式,也称量子逻辑电路,是最常用的通用量子计算模型,表示在抽象概念下对于量子比特进行操作的线路,其组成包括量子比特、线路(时间线)、以及各种量子逻辑门,最后常需要通过量子测量操作将结果读取出来。
不同于传统电路是用金属线所连接以传递电压信号或电流信号,在量子线路中,线路可看成是由时间所连接,亦即量子比特的状态随着时间自然演化,在这过程中按照哈密顿运算符的指示,一直到遇上逻辑门而被操作。
一个量子程序整体上对应有一条总的量子线路,所述量子程序即指该条总的量子线路,其中,该总的量子线路中的量子比特总数与量子程序的量子比特总数相同。可以理解为:一个量子程序可以由量子线路、针对量子线路中量子比特的测量操作、保存测量结果的寄存器及控制流节点(跳转指令)组成,一条量子线路可以包含几十上百个甚至千上万个量子逻辑门操作。量子程序的执行过程,就是对所有的量子逻辑门按照一定时序执行的过程。需要说明的是,时序即单个量子逻辑门被执行的时间顺序。
需要说明的是,经典计算中,最基本的单元是比特,而最基本的控制模式是逻辑门,可以通过逻辑门的组合来达到控制电路的目的。类似地,处理量子比特的方式就是量子逻辑门。使用量子逻辑门,能够使量子态发生演化,量子逻辑门是构成量子线路的基础,量子逻辑门包括单比特量子逻辑门,如Hadamard门(H门,阿达马门)、泡利-X门(X门)、泡利-Y门(Y门)、泡利-Z门(Z门)、RX门、RY门、RZ门等等;多比特量子逻辑门,如CNOT门、CR门、iSWAP门、Toffoli门等等。量子逻辑门一般使用酉矩阵表示,而酉矩阵不仅是矩阵形式,也是一种操作和变换。一般量子逻辑门在量子态上的作用是通过酉矩阵左乘以量子态右矢对应的矩阵进行计算。
参见图2,图2为实施例提供的一种线性函数对应的量子线路的构建方法的流程示意图,可以包括如下步骤。
S201,将目标线性函数的自变量制备到第一量子比特上。
可选地,自变量取值可以对应有不同概率。可以针对目标线性函数的自变量的概率分布,从概率分布中获取2 N个采样点,将2 N个采样点对应的自变量值以及概率制备至N个第一量子比特(或称采样比特)上。
以金融场景为例,目标分段线性函数可以为目标对象的期权的收益函数,自变量为目标对象的价值。
目标对象包括但不限于:金融产品、金融衍生品、标的资产等等。预先获取目标对象的价值概率分布数据,可以基于期权定价模型(例如Black-Scholes-MertonModel,莱克-舒尔斯模型),确定目标对象(例如股票)时间t后的价值。具体计算公式为:
Figure PCTCN2022095134-appb-000001
其中,t为到期时间,S t为t时目标对象的价值,S 0为初始价值,σ为波动率参数,W t为t时目标对象的资产价值符合几何布朗运动(GBM),r为收益率参数(即无风险利率)。
由于布朗运动W t的分布为正态分布,因此,S t的分布为对数正态分布,所述目标对象在到期时间t后的价值S t不是一个单点值,而是符合连续概率分布的连续点,即对每一个点,都有价值及对应的分布概率(又叫价值概率),所以获取S t对应的价值概率分布数据即获得
Figure PCTCN2022095134-appb-000002
其中,t i为各个时间点,
Figure PCTCN2022095134-appb-000003
为各个时间点对应的价值,
Figure PCTCN2022095134-appb-000004
为对应的分布概率。在呈对数正态分布S t的连续点中进行均匀采样,获得2 N个离散型概率密度分布点,如
Figure PCTCN2022095134-appb-000005
其中,i为0,1……2 N-1
考虑到2 N个分布概率之和不确定为1,可对2 N个离散型概率密度分布点进行归一化操作,即用各个
Figure PCTCN2022095134-appb-000006
对应的概率与2 N
Figure PCTCN2022095134-appb-000007
对应的概率平方和的开方的比值,作为各个
Figure PCTCN2022095134-appb-000008
归一化之后的概率,并由此得到2 N个离散型采样点,每个采样点包括价值以及价值对应的价值概率,即
Figure PCTCN2022095134-appb-000009
通过上述将对数正态分布S t的概率分布均匀采样到2 N个点,得到各采样点的概率密度函数的值后进行归一化。这样,离散的采样点分布可用来代表原来的连续分布,采样点越多采样区间越大越能代表原分布图案。
然后,可以根据所述2 N个采样点对应的价值确定所述N个第一量子比特对应的各个本征态,并根据2 N个采样点对应的价值概率确定各个本征态的振幅值,以完成N个第一量子比特中每个量子比特的制备。
示例性的,首先根据8个采样点对应的8个价值,确定3个采样比特对应的8个本征态,分别为|000>、|001>、|010>、|011>、|100>、|101>、|110>、|111>,每个本征态对应1个价值,如|000>对应价值1、|001>对应价值2……、|111>对应价值8。然后根据各个价值的价值概率确定对应本征态的振幅,实现量子振幅编码(即制备),编码后的3采样比特的量子态即表示标的资产到期时的分布信息。
S202,获取用于输出所述目标线性函数的第二量子比特,添加作用于所述第二量子比特的含参量子逻辑门,并通过所述第一量子比特控制所述含参量子逻辑门。
第二量子比特可以为预设的一位量子比特,可称结果比特,含参量子逻辑门可以为旋转逻辑门,例如RY门等等。
可选地,可以添加目标线性函数的截距对应的第一含参量子逻辑门,第一含参量子逻辑门作用于第二量子比特;
分别添加目标线性函数的斜率对应的第二含参量子逻辑门,其中,一第一量子比特对应一第二含参量子逻辑门,第二含参量子逻辑门作用于第二量子比特且受对应的第一量子比特控制。
以含参量子逻辑门为RY门为例,第一含参量子逻辑门可设为1个,不受控;第二含参量子逻辑门的数量可与采样比特相同,即为N,受采样比特控制。这是因为,截距对应的函数值与自变量无关,对应第一含参量子逻辑门也就与采样比特无关;而斜率需要结合自变量,才能计算出相应函数值,故对应第二含参量子逻辑门需与采样比特相关联。
S203,根据所述目标线性函数,确定所述含参量子逻辑门的参数值,得到所述目标线性函数对应的量子线路。
可选地,可以根据目标线性函数的截距,确定第一含参量子逻辑门的参数值;根据所述目标线性函数的斜率,确定第二含参量子逻辑门的参数值。例如,对于旋转逻辑门,其参数值为旋转逻辑门的酉矩阵中的旋转角度值。
示例性的,如图3所示,图3为一种目标线性函数对应的量子线路示意图,用于实现线性函数f(x)=offset+slope*x,其中,x为自变量,offset为截距,slope为斜率。具体包括:制备自变量分布后的采样比特i 1……i n、结果比特res,还包括第一含参量子逻辑门RY(a 0)门,以及第二含参量子逻辑门:受i 1实控的RY(a 1)门……受i n实控的RY(a n)门,实控(实心圆点)表示控制比特的在执行前的量子态为|1>态时,才执行该量子逻辑门。
对于第一含参量子逻辑门,RY(a 0)门中的参数a 0映射第一段线性函数的截距(定义域的左端点函数值),RY(a 1)门至RY(a n)门中的参数a 1至a n映射第一段线性函数的斜率。本领域技术人员能够理解的是,在实际应用中,由于RY门的参数即旋转角度取值范围为0至2π,映射后的取值可以注意三角函数本身性质,通常可以在π/4的单调区间上构造一对一映射。
最后,运行该量子线路,可以得到结果比特res的量子态为:
cos[f(x)]|0>+sin[f(x)]|1>
可以通过测量结果比特|0>态和/或|1>态的振幅,以得到线性函数值f(x)。通过量子计算领域中的量子线路,从而实现线性函数的功能,对于具体的自变量值,能够对应输出具体的函数值。
可见,通过将目标线性函数的自变量制备到第一量子比特上;获取用于输出目标线性函数的第二量子比特,添加作用于第二量子比特的含参量子逻辑门,并通过第一量子比特控制含参量子逻辑门;根据目标线性函数,确定含参量子逻辑门的参数值,得到目标线性函数对应的量子线路,从而实现线性函数在量子计算领域中的表示,并填补相关技术的空白。
参见图4,图4为实施例提供的一种基于量子线路的期权组合收益计算装置的结构示意图,与图2所示的流程相对应,所述装置包括:制备模块401,用于将目标线性函数的自变量制备到第一量子比特上;添加模块402,用于获取用于输出所述目标线性函数的第二量子比特,添加作用于所述第二量子比特的含参量子逻辑门,并通过所述第一量子比特控制所述含参量子逻辑门;确定模块403,用于根据所述目标线性函数,确定所述含参量子逻辑门的参数值,得到所述目标线性函数对应的量子线路。
可选地,所述制备模块用于:针对目标线性函数的自变量的概率分布,从所述概率分布中获取2 N个采样点,将所述2 N个采样点对应的自变量值以及概率制备至N个第一量子比特上。
可选地,所述添加模块用于:添加所述目标线性函数的截距对应的第一含参量子逻辑门,所述第一含参量子逻辑门作用于所述第二量子比特;分别添加 所述目标线性函数的斜率对应的第二含参量子逻辑门,其中,一第一量子比特对应一第二含参量子逻辑门,所述第二含参量子逻辑门作用于所述第二量子比特且受对应的第一量子比特控制。
可选地,所述确定模块用于:根据所述目标线性函数的截距,确定所述第一含参量子逻辑门的参数值;根据所述目标线性函数的斜率,确定所述第二含参量子逻辑门的参数值。
可选地,所述含参量子逻辑门为RY门。
例如,这里的实施例可以实现线性函数在量子计算领域中的表示,并填补相关技术的空白。
再一实施例提供了一种存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行上述任一项中方法实施例中的步骤。
可选地,在本实施例中,上述存储介质可以被设置为存储用于执行以下步骤的计算机程序:S1,将目标线性函数的自变量制备到第一量子比特上;S2,获取用于输出所述目标线性函数的第二量子比特,添加作用于所述第二量子比特的含参量子逻辑门,并通过所述第一量子比特控制所述含参量子逻辑门;S3,根据所述目标线性函数,确定所述含参量子逻辑门的参数值,得到所述目标线性函数对应的量子线路。
可选地,在本实施例中,上述存储介质可以包括但不限于:U盘、只读存储器(Read-Only Memory,简称为ROM)、随机存取存储器(Random Access Memory,简称为RAM)、移动硬盘、磁碟或者光盘等各种可以存储计算机程序的介质。
再一实施例还提供了一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一项中方法实施例中的步骤。
可选地,上述电子装置还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。
可选地,在本实施例中,上述处理器可以被设置为通过计算机程序执行以下步骤:S1,将目标线性函数的自变量制备到第一量子比特上;S2,获取用于输出所述目标线性函数的第二量子比特,添加作用于所述第二量子比特的含参量子逻辑门,并通过所述第一量子比特控制所述含参量子逻辑门;S3,根据所述目标线性函数,确定所述含参量子逻辑门的参数值,得到所述目标线性函数对应的量子线路。
为了简洁起见,在下面的实施例中,对于与上面实施例中的相同或类似特征的重复描述可以被省略。
参见图5,图5为实施例提供的一种分段线性函数对应的量子线路的构建方法的流程示意图,可以包括如下步骤。
S1201,将目标分段线性函数的自变量制备到第一量子比特上。
S1202,基于所述第一量子比特和所述分段线性函数的分段点,构建用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路。
可选地,可以获取与所述第一量子比特对应的辅助比特,以及用于输出比 较结果的比较比特;例如,辅助比特的数量与第一量子比特相同,均为N,比较比特设1位;
根据所述分段点横坐标,确定待构建的、用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路的量子逻辑门,并结合所述第一量子比特、所述辅助比特和所述比较比特,构建所述第一子量子线路。其中,分段线性函数的分段点是指每一段线性函数之间的交点。
示例性的,如图6所示,图6为实施例提供的一种量子比较器线路示意图。可以根据分段点横坐标的二进制补码的每一位编码值,依次确定待作用在制备后的每个对应位上的采样比特及对应辅助比特上的量子逻辑门。其中,该二进制补码的一位的编码值为0时,对应的量子逻辑门为Toffoli门,该二进制补码的一位的编码值为1时,对应的量子逻辑门为逻辑或门。需要说明的是,仅在二进制补码的第一位编码值为0时,对应无量子逻辑门操作;在二进制补码的第一位编码值为1时,对应CNOT门操作。
在具体实现中,逻辑或门(OR门)可由Toffoli门与X门构造,其他与Toffoli门、逻辑或门等价的量子逻辑门也是合理可行的。如图7左侧线路所示,逻辑或门的一种构造方式可依次包括三个NOT门、一个Toffoli门以及两个NOT门。
如图6所示,|i 1>、|i 2>……|i n>为N个采样比特,|i 1>为最低位,|i n>为最高位,|a 1>、|a 2>……|a n>为辅助比特,|a 1>为最低位,|a n>为最高位,C为比较比特。通过t[1,...,n]表示分段点横坐标的一组n位二进制补码,t[1]为最低位,t[n]为最高位。其中,分段点横坐标的二进制补码位数、辅助比特的比特数与采样比特的比特数相同且一一对应,均为N。
示例性的,如图6所示,t[1]=1时,确定待作用在第一位采样比特|i 1>和第一位辅助比特|a 1>的量子逻辑门为CNOT门;t[1]=0时,则无需对第一位辅助比特进行任何操作。
而针对t[2]、t[3]...t[n]确定量子逻辑门的思路相同。示例性的,如图6中的虚框所示,在t[2]=1时,确定待作用在第二位采样比特、第一位辅助比特及第二位辅助比特的量子逻辑门为逻辑或门;在t[2]=0时,确定待作用在第二位采样比特、第一位辅助比特及第二位辅助比特的量子逻辑门为Toffoli门。
依次类推,直至确定第n位辅助比特|a n>上的待作用量子逻辑门后,然后通过最后一个CNOT门将|a n>制备至比较比特上,即将自变量与分段点横坐标的大小比较结果制备至比较比特c上。例如,经过测量比较比特c,得到|0>态,说明自变量小于分段点横坐标,否则得到|1>态,说明自变量大于等于分段点横坐标。
S1203,基于所述第一量子比特和所述第一子量子线路包含的输出比较结果的比较比特,构建所述分段线性函数中每一段线性函数对应的分段子量子线路;
可选地,可以获取用于输出所述分段线性函数的第二量子比特。第二量子 比特可以为预设的一位量子比特,可称结果比特。
根据所述分段线性函数的每一段线性函数,对应添加作用于所述第二量子比特的含参量子逻辑门,并确定所述含参量子逻辑门的参数值。
每一段线性函数对应一组含参量子逻辑门,例如旋转逻辑门。可以根据每一段线性函数的截距和斜率,确定含参量子逻辑门的参数值(旋转角度)。
通过所述第一量子比特和所述比较比特控制所述含参量子逻辑门,得到所述分段线性函数中每一段线性函数对应的分段子量子线路。
每组含参量子逻辑门中与截距相关的逻辑门不受第一量子比特控制,与斜率相关的逻辑门受第一量子比特控制,并根据各段线性函数具体情况,选择性受比较比特控制。
示例性的,目标分段线性函数由两段线性函数组成。如图8所示,图8为一种对应的分段子量子线路的结构示意图,包括:制备后的采样比特i 1……i n、比较比特c、结果比特res,还包括两组量子逻辑门RY门,其中,第一组包括:RY(a 0)门、受i 1实控的RY(a 1)门……受i n实控的RY(a n)门,实控(实心圆点)表示控制比特的在执行前的量子态为|1>态时,才执行该量子逻辑门,对应分段线性函数的第一段线性函数,即第一段分段子量子线路;第二组包括:RY(b 0)门、受i 1和c实控的RY(b 1)门……受i n和c实控的RY(b n)门,对应分段线性函数的第二段线性函数,即第二段分段子量子线路。这是因为:自变量首先小于分段点横坐标,故第一段线性函数对应的第一组逻辑门与比较比特无关;在自变量大于分段点横坐标后,才开始执行第二组逻辑门对应的第二段线性函数,此时,第二组逻辑门需要与比较比特关联起来。
对于第一组逻辑门,RY(a 0)门中的参数a 0映射第一段线性函数的截距(定义域的左端点函数值),RY(a 1)门至RY(a n)门中的参数a 1至a n映射第一段线性函数的斜率。第二组逻辑门的参数同理确定,需要说明的是,b 0映射的为:第二段函数与第一段函数间的分段点函数值减去上一段函数的左端点函数值后的函数值,b 1至b n映射的为:第二段函数的斜率减去上一段函数的斜率后的斜率值。如果是两段以上的多段线性函数,相应增加多出的分段点对应的比较比特,以此类推。本领域技术人员能够理解的是,在实际应用中,由于RY门的参数即旋转角度取值范围为0至2π,映射后的取值可以注意三角函数本身性质,通常可以在π/4的单调区间上构造一对一映射。
通过依次运行量子比较器线路和分段子量子线路,最终通过测量结果比特res,得到对应结果比特的量子态及其振幅。
S1204,根据所述第一子量子线路和各所述分段子量子线路,构建所述分段线性函数对应的量子线路。
可选地,目标分段线性函数可以为目标期权的收益函数f(S T)。在实际应用中,还可以运行所述量子线路,根据所述量子线路的运行结果,计算所述目标期权的收益。
以欧式期权为例,存在四种期权基本交易,收益函数f(S t)公式如下:
买入欧式期权看涨收益:f(S t)=max{0,S t-K}-C;
买入欧式期权看跌收益:f(S t)=max{K-S t,0}-C;
卖出欧式期权看涨收益:f(S t)=C-max{0,S t-K};
卖出欧式期权看跌收益:f(S t)=C-max{K-S t,0};
其中,S t为期权价值,K为行权价,C为期权成本。可知,一种期权对应一种收益函数,且为分段线性函数。
示例性的,一支为买入看涨期权的收益函数为:
Figure PCTCN2022095134-appb-000010
其中,行权价K 0=1,期权成本C 0=1,左端点为0,左端点函数值为-1,分段点横坐标即为行权价1;
一支卖出看涨期权的收益函数为:
Figure PCTCN2022095134-appb-000011
其中,行权价K 1=2,期权成本C 1=2,左端点为0,左端点函数值为2,分段点横坐标即为行权价2。
可选地,可以运行当前量子线路,测量所述量子线路的第二量子比特,得到所述第二量子比特的振幅;对所述第二量子比特的振幅进行振幅估计,得到所述收益函数的期望值E[f(S T)],作为所述目标期权的收益。
振幅估计可以通过量子振幅估计算法QAE及其改进或变型版本实现,一种优选方式具体为:获取结果比特的振幅值对应的当前幅角上界值以及当前幅角下界值,并计算当前幅角上界值以及当前幅角下界值的第一差值,作为目标差值;在目标差值大于预设精度阈值时,根据预设中间变量参数、当前幅角上界值以及当前幅角下界值,确定下一迭代步骤对应的下一幅角放大因子以及下一标记参数;控制预设放大量子线路以下一幅角放大因子对结果比特所在的量子线路进行放大,并根据预设观测总次数,对放大后的结果比特所在的量子线路中的结果比特的量子态进行测量;根据当前幅角上界值、当前幅角下界值、下一幅角放大因子、下一标记参数以及结果比特的量子态的测量结果,计算结果比特的振幅值的下一幅角上界值以及下一幅角下界值的第二差值,作为目标差值,直至目标差值不大于精度阈值;
根据结果比特的量子态的测量结果,确定结果比特的振幅值。
上述步骤所采用的量子比特(即结果比特)的振幅值估算方法,通过确定各个迭代步骤中的放大量子线路的放大参数,以不断迭代使得幅角上界值以及下界值的差值在精度阈值内,避免产生振幅值无法收敛的问题,提高振幅值的精确性。且其依据的原理和更详细的实施过程见中国专利文献,申请号202011591351.6,申请日2020年12月29日,申请名称“量子线路的振幅估计方法、装置、存储介质及电子装置”,在此不再赘述。可选地,在实际应用中,还可以将所述目标期权的收益折算为现值。其中,一种折算公式可以为: E[f(S T)]*e -rt
在一个实施例中,可以在量子计算领域中实现线性函数的表示,并填补相关技术的空白。
参见图9,图9为实施例提供的一种基于量子线路的期权组合收益计算装置的结构示意图,与图5所示的流程相对应,所述装置包括:制备模块601,用于将目标分段线性函数的自变量制备到第一量子比特上;第一构建模块602,用于基于所述第一量子比特和所述分段线性函数的分段点,构建用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路;第二构建模块603,用于基于所述第一量子比特和所述第一子量子线路包含的输出比较结果的比较比特,构建所述分段线性函数中每一段线性函数对应的分段子量子线路;第三构建模块604,用于根据所述第一子量子线路和各所述分段子量子线路,构建所述分段线性函数对应的量子线路。
可选地,所述制备模块用于:针对目标线性函数的自变量的概率分布,从所述概率分布中获取2 N个采样点,将所述2 N个采样点对应的自变量值以及概率制备至N个第一量子比特上。
可选地,所述第一构建模块用于:获取与所述第一量子比特对应的辅助比特,以及用于输出比较结果的比较比特;根据所述分段点横坐标,确定待构建的、用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路的量子逻辑门,并结合所述第一量子比特、所述辅助比特和所述比较比特,构建所述第一子量子线路。
可选地,所述第二构建模块用于:获取用于输出所述分段线性函数的第二量子比特;根据所述分段线性函数的每一段线性函数,对应添加作用于所述第二量子比特的含参量子逻辑门,并确定所述含参量子逻辑门的参数值;通过所述第一量子比特和所述比较比特控制所述含参量子逻辑门,得到所述分段线性函数中每一段线性函数对应的分段子量子线路。
可选地,所述目标分段线性函数为目标期权的收益函数;所述装置还包括:计算模块,用于运行所述量子线路,根据所述量子线路的运行结果,计算所述目标期权的收益。
可选地,所述计算模块用于:运行当前量子线路,测量所述量子线路的第二量子比特,得到所述第二量子比特的振幅;对所述第二量子比特的振幅进行振幅估计,得到所述收益函数的期望值,作为所述目标期权的收益。
可选地,所述装置还包括:折算模块,用于将所述目标期权的收益折算为现值。
在一个实施例中,可以在量子计算领域中实现线性函数的表示,并填补相关技术的空白。
再一实施例提供了一种存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行上述任一项中方法实施例中的步骤。
可选地,在本实施例中,上述存储介质可以被设置为存储用于执行以下步骤的计算机程序:S11,将目标分段线性函数的自变量制备到第一量子比特上; S12,基于所述第一量子比特和所述分段线性函数的分段点,构建用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路;S13,基于所述第一量子比特和所述第一子量子线路包含的输出比较结果的比较比特,构建所述分段线性函数中每一段线性函数对应的分段子量子线路;S14,根据所述第一子量子线路和各所述分段子量子线路,构建所述分段线性函数对应的量子线路。
再一实施例还提供了一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一项中方法实施例中的步骤。
可选地,上述电子装置还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。
可选地,在本实施例中,上述处理器可以被设置为通过计算机程序执行以下步骤:S11,将目标分段线性函数的自变量制备到第一量子比特上;S12,基于所述第一量子比特和所述分段线性函数的分段点,构建用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路;S13,基于所述第一量子比特和所述第一子量子线路包含的输出比较结果的比较比特,构建所述分段线性函数中每一段线性函数对应的分段子量子线路;S14,根据所述第一子量子线路和各所述分段子量子线路,构建所述分段线性函数对应的量子线路。
参见图10,图10为实施例提供的一种基于量子线路的期权组合收益计算方法的流程示意图,可以包括如下步骤。
S2201,将目标对象的价值及其概率分布制备到第一量子比特上。
可选地,可以针对目标对象的价值的概率分布,从所述概率分布中获取2 N个采样点,将所述2 N个采样点对应的价值以及概率制备至N个第一量子比特上。
在实际应用中,一种优选的采样区间的确定方式为:获取价值概率分布数据中价值对应的价值均值以及价值标准差;根据价值均值以及三倍价值标准差的差值确定左端点,并根据左端点以及六倍价值标准差,确定右端点;根据左端点以及右端点,确定用于2 N个采样点的采样区间。
对于取样标准差误差较大的情况,为了进一步提高期权估计精度,可以对采样区间进行对应调整。首先计算价值概率分布数据中价值的价值均值以及价值标准差,然后基于价值均值以及三倍价值标准差的差值确定左端点,即将价值均值减去三倍价值标准差,作为采样区间的左端点;然后基于左端点向右加大约6倍价值标准差,作为采样区间的右端点。通过上述方式,可在价值标准差很大的时候大大缩小因区间选取导致的误差。
以上过程在实施的时候,可基于已确定的左端点是否落在被采样数据的分布范围内,而对已确定的左端点进行修正,并基于修正后的左端点确定右端点,保证采样区间的完整性,避免因实际采样点的限制条件,缩小采样区间。
然后,可以根据所述2 N个采样点对应的价值确定所述N个量子比特(第一量子比特,或称采样比特)对应的各个本征态,并根据2 N个采样点对应的价值概率确定各个本征态的振幅值,以完成N个量子比特中每个量子比特的制 备。
S2202,确定所述目标对象的期权组合中每支期权的第一收益函数,并根据所述第一收益函数,确定所述期权组合对应的第二收益函数;
可选地,可以针对期权组合中的每支期权,将所述目标对象的价值、行权价和期权成本,代入该支期权对应的收益函数中,得到第一收益函数;将每支期权分别对应的第一收益函数进行组合,得到所述期权组合对应的第二收益函数。
对于多支期权组合,将每支期权的行权价和期权成本的具体值代入对应的收益函数中,代入具体值后的收益函数即为第一收益函数。由于收益函数均为分段线性,可以将各个第一收益函数进行线性组合,得到期权组合对应的一个第二收益函数,具体可以包括:对各支期权对应的第一收益函数进行处理,以使处理后函数对应的期权成本归0;根据行权价大小,确定处理后的、已组合期权的第一收益函数和处理后的、待组合期权的第一收益函数,并确定已组合期权的第一收益函数对应的分段点数组、分段斜率数组和分段点的函数值数组;根据各支期权,更新分段点数组、分段斜率数组和分段点的函数值数组,更新后的分段点数组、分段斜率数组和分段点的函数值数组对应无成本期权组合的第二收益函数;根据各支期权的成本价,对无成本期权组合的第二收益函数进行处理,得到包含成本的、期权组合对应的第二收益函数。
示例性的,用户购买了两支期权,一支为买入看涨期权,第一收益函数为:
Figure PCTCN2022095134-appb-000012
其中,行权价K 0=1,期权成本C 0=1;
另一支为卖出看涨期权,第一收益函数为:
Figure PCTCN2022095134-appb-000013
其中,行权价K 1=2,期权成本C 1=2。
可以以分段点、分段斜率、分段点的函数值作为参数,用于表示分段线性函数。一种具体的第一收益函数的组合方式为:
首先,消除第一收益函数中的期权成本影响,处理得到:
Figure PCTCN2022095134-appb-000014
Figure PCTCN2022095134-appb-000015
对上述两支期权,按照行权价升序遍历每支期权处理后的收益函数,将行权价最小的f′ 0(S t)作为处理后的已组合期权的第一收益函数(f′ 0(S t)前面无更小行权价的期权,相当于与0组合),f′ 1(S t)作为处理后的当前待组合期权的第一收益函数;
此时,分段点数组(指横坐标)、分段斜率数组、分段点的函数值数组为f′ 0(S t)的参数,分别为:{0,1}、{0,1}、{0,0};可知,函数与横坐标轴的交点为行权价点;
如果当前待组合期权的行权价和已组合期权的最右一个分段点(该点即为行权价点)不同,则在分段点数组中加入当前待组合期权的行权价2,得到{0,1,2};
在分段点的函数值数组中加入待组合期权行权价点与已组合期权行权价点的距离与已组合期权中斜率非0的部分的分段斜率的乘积,加上行权价点的函数值:(2-1)*1+0=1,得到{0,0,1};
继续判断如果当前待组合期权为看涨,则分段点的函数值不变,在分段斜率数组中加入已组合期权的分段斜率加1的值(如果当前待组合期权为买入)或减1的值(如果当前待组合期权为卖出),即加入斜率1-1=0,得到{0,1,0};
否则当前待组合期权为看跌,则分段斜率数组中加入已组合期权中斜率非0的部分的分段斜率,并将加入分段斜率数组前的所有分段斜率减1(如果当前待组合期权为买入)或加1(如果当前待组合期权为卖出),并根据加入分段点的函数值数组中的值和新斜率更新函数值数组中的其他值。
如果当前待组合期权的行权价和已组合期权的最右分段点相同(行权价相同),则分段点不变,继续执行上述看涨或看跌的判断步骤。
由上,可得f′ 0(S t)和f′ 1(S t)组合后的分段点数组{0,1,2}、分段斜率数组{0,1,0}和分段点的函数值数组{0,0,1},从而表示出组合后的收益函数:
Figure PCTCN2022095134-appb-000016
最后,考虑f 0(S t)、f 1(S t)的期权成本,得到期权组合对应的第二收益函数:
Figure PCTCN2022095134-appb-000017
可得,该第二收益函数对应分段点数组{0,1,2}、分段斜率数组{0,1,0}和分段点的函数值数组{1,1,2}。
S2203,基于所述第一量子比特和所述第二收益函数,构建和运行表示收益函数的量子线路;
可选地,可以构建包含第一量子比特的、表示收益函数的量子线路;将第二收益函数的预设参数,输入量子线路中;运行当前量子线路,得到当前量子线路的运行结果。其中,预设参数可以包括:前述用于表示第二收益函数的分段点数组、分段斜率数组和分段点的函数值数组参数,以及第二收益函数的定义域和值域等等。
可选地,可以通过运行当前量子线路,测量当前量子线路的第二量子比特, 得到第二量子比特的振幅。其中,第二量子比特可以为预设的一位量子比特,称为结果比特。更具体的,第二量子比特的振幅可以为第二量子比特的|1>态的振幅。
在一种实现方式中,由于收益函数为分段线性函数,可以构建表示每一段的线性函数的第一子量子线路、用于比较自变量与分段点横坐标大小的第二子量子线路(量子比较器),组成表示分段线性函数的量子线路。
对于量子比较器线路,第二收益函数中的分段点,除起始点0外,其余分段点横坐标即为行权价,可以通过比较自变量S T与行权价K的大小,根据大小比较结果,运行对应段的线性函数的第一子量子线路。
示例性的,如图6所示,图6为实施例提供的一种量子比较器线路示意图。由于价值S t制备在N个采样比特上,需要设置与N个采样比特一一对应的N位辅助比特,作为比较过程中的进位量子比特,进位量子比特位用于存储编码收益的量子态对应的每一位与行权价的补码的每一位的进位。
然后,根据行权价对应的二进制补码确定待作用在制备后的每个采样比特及对应辅助比特上的量子逻辑门,并将各量子逻辑门执行操作后的结果制备至预设的比较比特上。
可选地,可以根据行权价对应的二进制补码的每一位编码值,依次确定待作用在制备后的每个对应位上的采样比特及对应辅助比特上的量子逻辑门。其中,该二进制补码的一位的编码值为0时,对应的量子逻辑门为Toffoli门,该二进制补码的一位的编码值为1时,对应的量子逻辑门为逻辑或门。需要说明的是,仅在二进制补码的第一位编码值为0时,对应无量子逻辑门操作;在二进制补码的第一位编码值为1时,对应CNOT门操作。
如图6所示,|i 1>、|i 2>……|i n>为N个采样比特,|i 1>为最低位,|i n>为最高位,|a 1>、|a 2>……|a n>为辅助比特,|a 1>为最低位,|a n>为最高位,C为比较比特。通过t[1,...,n]表示行权价的一组n位二进制补码,t[1]为最低位,t[n]为最高位。其中,行权价的二进制补码位数、辅助比特的比特数与采样比特的比特数相同且一一对应,均为N。
示例性的,如图6所示,t[1]=1时,确定待作用在第一位采样比特|i 1>和第一位辅助比特|a 1>的量子逻辑门为CNOT门;t[1]=0时,则无需对第一位辅助比特进行任何操作。
而针对t[2]、t[3]...t[n]确定量子逻辑门的思路相同。示例性的,如图6中的虚框所示,在t[2]=1时,确定待作用在第二位采样比特、第一位辅助比特及第二位辅助比特的量子逻辑门为逻辑或门;在t[2]=0时,确定待作用在第二位采样比特、第一位辅助比特及第二位辅助比特的量子逻辑门为Toffoli门。
依次类推,直至确定第n位辅助比特|a n>上的待作用量子逻辑门后,然后通过最后一个CNOT门将|a n>制备至比较比特上,即将价值S t与行权价K的大小比对结果制备至比较比特上。例如,经过测量比较比特c,得到|0>态,说明S t小于K,否则得到|1>态,说明S t大于等于K。
在运行量子比较器线路后,得到自变量S T与行权价K的大小比较结果,然后运行第一子量子线路,得到第一子量子线路的第二量子比特的振幅。
示例性的,继续以第二收益函数
Figure PCTCN2022095134-appb-000018
为例,对应分段点数组{0,1,2}、分段斜率数组{0,1,0}和分段点的函数值数组{1,1,2}。可知,分段点除起点0外,1和2为原两个期权的行权价,设K1=1,K2=2。需要两条量子比较器线路,分别对应行权价K1、K2,对应比较比特为c 1、c 2。运行该两条量子比较器线路,在c 1、c 2上得到自变量S T与行权价K1、自变量S T与行权价K2的比较结果,进而运行第一子量子线路。如图11所示,第一子量子线路包括:制备后的采样比特i 1……i n、比较比特c 1和c 2、结果比特res,还包括三组量子逻辑门,其中,第一组包括:RY(θ 0)门、受i 1实控的RY(θ 1)门……受i n实控的RY(θ n)门,实控(实心圆点)表示控制比特的在执行前的量子态为|1>态时,才执行该量子逻辑门,对应分段线性函数(第二收益函数)的第一段函数;第二组包括:RY(a 0)门、受i 1和c 1实控的RY(a 1)门……受i n和c 1实控的RY(a n)门,对应分段线性函数的第二段函数;第三组包括:RY(b 0)门、受i 1和c 2实控的RY(b 1)门……受i n和c 2实控的RY(b n)门,对应分段线性函数的第三段函数。
对于第一组逻辑门,RY(θ 0)门中的参数θ 0映射第一段函数的左端分段点函数值,RY(θ 1)门至RY(θ n)门中的参数θ 1至θ n映射第一段函数的斜率。第二组和第三组逻辑门的参数同理确定,需要说明的是,a 0映射的为:第二段函数的左端分段点函数值减去上一段函数的左端分段点函数值后的函数值,a 1至a n映射的为:第二段函数的斜率减去上一段函数的斜率后的斜率值,第三组以此类推。本领域技术人员能够理解的是,在实际应用中,由于RY门的参数即旋转角度取值范围为0至2π,映射后的取值可以注意三角函数本身性质,通常可以在π/4的单调区间上构造一对一映射。
通过运行量子比较器线路和第一子量子线路,最终通过测量结果比特res,得到对应量子态及其振幅。
S2204,根据所述量子线路的运行结果,计算所述期权组合的收益。
可选地,可以对第二量子比特的振幅进行振幅估计,获得第二收益函数的期望值E[f(S T)],作为期权组合的收益。
振幅估计可以通过量子振幅估计算法QAE及其改进或变型版本实现,一种优选方式具体为:获取结果比特的振幅值对应的当前幅角上界值以及当前幅角下界值,并计算当前幅角上界值以及当前幅角下界值的第一差值,作为目标差值;在目标差值大于预设精度阈值时,根据预设中间变量参数、当前幅角上界值以及当前幅角下界值,确定下一迭代步骤对应的下一幅角放大因子以及下一标记参数;控制预设放大量子线路以下一幅角放大因子对结果比特所在的量子 线路进行放大,并根据预设观测总次数,对放大后的结果比特所在的量子线路中的结果比特的量子态进行测量;根据当前幅角上界值、当前幅角下界值、下一幅角放大因子、下一标记参数以及结果比特的量子态的测量结果,计算结果比特的振幅值的下一幅角上界值以及下一幅角下界值的第二差值,作为目标差值,直至目标差值不大于精度阈值;根据结果比特的量子态的测量结果,确定结果比特的振幅值。
上述步骤所采用的量子比特(即结果比特)的振幅值估算方法,通过确定各个迭代步骤中的放大量子线路的放大参数,以不断迭代使得幅角上界值以及下界值的差值在精度阈值内,避免产生振幅值无法收敛的问题,提高振幅值的精确性。且其依据的原理和更详细的实施过程见中国专利文献,申请号202011591351.6,申请日2020年12月29日,申请名称“量子线路的振幅估计方法、装置、存储介质及电子装置”,在此不再赘述。
在实际应用中,第二量子比特的振幅可以为关于S T的线性函数
Figure PCTCN2022095134-appb-000019
的期望值的开方
Figure PCTCN2022095134-appb-000020
其中,线性公式为:
Figure PCTCN2022095134-appb-000021
f max为f(S T)的最大值,f min为f(S T)的最小值,c为缩放因子,可由实际需求确定,例如为0.2。通过该线性公式,即可反解出第二收益函数的期望值E[f(S T)]。
可选地,在实际应用中,还可以将期权组合的收益折算为现值。其中,一种折算公式可以为:E[f(S T)]*e -rt
这里,可在样本量较大时基于量子线路实现期权收益计算,对计算进行并行加速,提高了期权计算效率和准确率,并且实现对多支期权组合进行收益计算,具备较好的通用性。
参见图12,图12为实施例提供的一种基于量子线路的期权组合收益计算装置,所述装置包括:制备模块2601,用于将目标对象的价值及其概率分布制备到第一量子比特上;确定模块2602,用于确定所述目标对象的期权组合中每支期权的第一收益函数,并根据所述第一收益函数,确定所述期权组合对应的第二收益函数;运行模块2603,用于基于所述第一量子比特和所述第二收益函数,构建和运行表示收益函数的量子线路;计算模块2604,用于根据所述量子线路的运行结果,计算所述期权组合的收益。
可选地,所述制备模块用于:针对目标对象的价值的概率分布,从所述概率分布中获取2 N个采样点,将所述2 N个采样点对应的价值以及概率制备至N个第一量子比特上。
可选地,所述确定模块用于:针对期权组合中的每支期权,将所述目标对象的价值、行权价和期权成本,代入该支期权对应的收益函数中,得到第一收益函数;将每支期权分别对应的第一收益函数进行组合,得到所述期权组合对应的第二收益函数。
可选地,所述运行模块,包括:构建单元,用于构建包含所述第一量子比特的、表示收益函数的量子线路;输入单元,用于将所述第二收益函数的预设参数,输入所述量子线路中;运行单元,用于运行当前量子线路,得到所述当 前量子线路的运行结果。
可选地,所述运行单元用于:运行当前量子线路,测量所述当前量子线路的第二量子比特,得到所述第二量子比特的振幅。
可选地,所述计算模块用于:对所述第二量子比特的振幅进行振幅估计,得到所述第二收益函数的期望值,作为所述期权组合的收益。
可选地,所述装置还包括:折算模块,用于将所述期权组合的收益折算为现值。
这里,可在样本量较大时基于量子线路实现期权收益计算,对计算进行并行加速,提高了期权计算效率和准确率,并且实现对多支期权组合进行收益计算,具备较好的通用性。
再一实施例提供了一种存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行上述任一项中方法实施例中的步骤。
可选地,在本实施例中,上述存储介质可以被设置为存储用于执行以下步骤的计算机程序:S21,将目标对象的价值及其概率分布制备到第一量子比特上;S22,确定所述目标对象的期权组合中每支期权的第一收益函数,并根据所述第一收益函数,确定所述期权组合对应的第二收益函数;S23,基于所述第一量子比特和所述第二收益函数,构建和运行表示收益函数的量子线路;S24,根据所述量子线路的运行结果,计算所述期权组合的收益。
再一实施例还提供了一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一项中方法实施例中的步骤。
可选地,上述电子装置还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。
可选地,在本实施例中,上述处理器可以被设置为通过计算机程序执行以下步骤:S21,将目标对象的价值及其概率分布制备到第一量子比特上;S222,确定所述目标对象的期权组合中每支期权的第一收益函数,并根据所述第一收益函数,确定所述期权组合对应的第二收益函数;S3,基于所述第一量子比特和所述第二收益函数,构建和运行表示收益函数的量子线路;S24,根据所述量子线路的运行结果,计算所述期权组合的收益。
以上依据图式所示的实施例详细说明了本发明的构造、特征及作用效果,以上所述仅为本发明的较佳实施例,但本发明不以图面所示限定实施范围,凡是依照本发明的构想所作的改变,或修改为等同变化的等效实施例,仍未超出说明书与图示所涵盖的精神时,均应在本发明的保护范围内。

Claims (16)

  1. 一种线性函数对应的量子线路的构建方法,其特征在于,所述方法包括:
    将目标线性函数的自变量制备到第一量子比特上;
    获取用于输出所述目标线性函数的第二量子比特,添加作用于所述第二量子比特的含参量子逻辑门,并通过所述第一量子比特控制所述含参量子逻辑门;
    根据所述目标线性函数,确定所述含参量子逻辑门的参数值,得到所述目标线性函数对应的量子线路。
  2. 根据权利要求1所述的方法,其特征在于,所述将目标线性函数的自变量制备到第一量子比特上,包括:
    针对目标线性函数的自变量的概率分布,从所述概率分布中获取2N个采样点,将所述2N个采样点对应的自变量值以及概率制备至N个第一量子比特上。
  3. 根据权利要求1所述的方法,其特征在于,所述添加作用于所述第二量子比特的含参量子逻辑门,并通过所述第一量子比特控制所述含参量子逻辑门,包括:
    添加所述目标线性函数的截距对应的第一含参量子逻辑门,所述第一含参量子逻辑门作用于所述第二量子比特;
    分别添加所述目标线性函数的斜率对应的第二含参量子逻辑门,其中,一第一量子比特对应一第二含参量子逻辑门,所述第二含参量子逻辑门作用于所述第二量子比特且受对应的第一量子比特控制。
  4. 根据权利要求3所述的方法,其特征在于,所述根据所述目标线性函数,确定所述含参量子逻辑门的参数值,包括:
    根据所述目标线性函数的截距,确定所述第一含参量子逻辑门的参数值;
    根据所述目标线性函数的斜率,确定所述第二含参量子逻辑门的参数值。
  5. 根据权利要求1-4任一项所述的方法,其特征在于,所述含参量子逻辑门为RY门。
  6. 根据权利要求1-4任一项所述的方法,其特征在于,所述线性函数是分段线性函数,以及所述方法还包括:
    基于所述第一量子比特和所述分段线性函数的分段点,构建用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路;
    其中,获取用于输出所述目标线性函数的第二量子比特,添加作用于所述第二量子比特的含参量子逻辑门,并通过所述第一量子比特控制所述含参量子逻辑门包括:
    基于所述第一量子比特和所述第一子量子线路包含的输出比较结果的比较比特,构建所述分段线性函数中每一段线性函数对应的分段子量子线路;以及
    其中,根据所述目标线性函数,确定所述含参量子逻辑门的参数值,得到所述目标线性函数对应的量子线路包括:
    根据所述第一子量子线路和各所述分段子量子线路,构建所述分段线性函数对应的量子线路。
  7. 根据权利要求6所述的方法,其特征在于,所述基于所述第一量子比特和所述分段线性函数的分段点,构建用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路,包括:
    获取用于输出所述分段线性函数的第二量子比特;
    获取与所述第一量子比特对应的辅助比特,以及用于输出比较结果的比较比特;
    根据所述分段点横坐标,确定待构建的、用于将所述自变量与所述分段点横坐标进行比较的第一子量子线路的量子逻辑门,并结合所述第一量子比特、所述辅助比特和所述比较比特,构建所述第一子量子线路。
  8. 根据权利要求6所述的方法,其特征在于,所述基于所述第一量子比特和所述第一子量子线路包含的输出比较结果的比较比特,构建所述分段线性函数中每一段线性函数对应的分段子量子线路,包括:
    获取用于输出所述分段线性函数的第二量子比特;
    根据所述分段线性函数的每一段线性函数,对应添加作用于所述第二量子比特的含参量子逻辑门,并确定所述含参量子逻辑门的参数值;
    通过所述第一量子比特和所述比较比特控制所述含参量子逻辑门,得到所述分段线性函数中每一段线性函数对应的分段子量子线路。
  9. 根据权利要求6-8任一项所述的方法,其特征在于,所述分段线性函数为目标期权的收益函数;所述方法还包括:
    运行所述量子线路,根据所述量子线路的运行结果,计算所述目标期权的收益。
  10. 根据权利要求9所述的方法,其特征在于,所述运行所述量子线路,根据所述量子线路的运行结果,计算所述目标期权的收益,包括:
    运行当前量子线路,测量所述量子线路的第二量子比特,得到所述第二量子比特的振幅;
    对所述第二量子比特的振幅进行振幅估计,得到所述收益函数的期望值,作为所述目标期权的收益。
  11. 根据权利要求9所述的方法,其特征在于,所述方法还包括:
    将所述目标期权的收益折算为现值。
  12. 一种线性函数对应的量子线路的构建装置,其特征在于,所述装置包括:
    制备模块,用于将目标线性函数的自变量制备到第一量子比特上;
    添加模块,用于获取用于输出所述目标线性函数的第二量子比特,添加作用于所述第二量子比特的含参量子逻辑门,并通过所述第一量子比特控制所述含参量子逻辑门;
    确定模块,用于根据所述目标线性函数,确定所述含参量子逻辑门的参数值,得到所述目标线性函数对应的量子线路。
  13. 根据权利要求12所述的装置,其特征在于,所述制备模块用于:
    针对目标线性函数的自变量的概率分布,从所述概率分布中获取2N个采样点,将所述2N个采样点对应的自变量值以及概率制备至N个第一量子比特上。
  14. 根据权利要求12所述的装置,其特征在于,所述添加模块用于:
    添加所述目标线性函数的截距对应的第一含参量子逻辑门,所述第一含参量子逻辑门作用于所述第二量子比特;
    分别添加所述目标线性函数的斜率对应的第二含参量子逻辑门,其中,一第一量子比特对应一第二含参量子逻辑门,所述第二含参量子逻辑门作用于所 述第二量子比特且受对应的第一量子比特控制。
  15. 一种存储介质,其特征在于,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行所述权利要求1至11任一项中所述的方法。
  16. 一种电子装置,包括存储器和处理器,其特征在于,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行所述权利要求1至11任一项中所述的方法。
PCT/CN2022/095134 2021-05-28 2022-05-26 一种线性函数对应的量子线路的构建方法及装置 WO2022247887A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP22810611.8A EP4328808A1 (en) 2021-05-28 2022-05-26 Method and apparatus for constructing quantum circuit corresponding to linear function
US18/515,886 US11966815B2 (en) 2021-05-28 2023-11-21 Method and apparatus for constructing quantum circuit corresponding to linear function

Applications Claiming Priority (6)

Application Number Priority Date Filing Date Title
CN202110593126.4A CN115409620A (zh) 2021-05-28 2021-05-28 一种基于量子线路的期权组合收益计算方法及装置
CN202110595092.2 2021-05-28
CN202110595106.0 2021-05-28
CN202110593126.4 2021-05-28
CN202110595092.2A CN115409185A (zh) 2021-05-28 2021-05-28 一种线性函数对应的量子线路的构建方法及装置
CN202110595106.0A CN115409186A (zh) 2021-05-28 2021-05-28 一种分段线性函数对应的量子线路的构建方法及装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/515,886 Continuation US11966815B2 (en) 2021-05-28 2023-11-21 Method and apparatus for constructing quantum circuit corresponding to linear function

Publications (1)

Publication Number Publication Date
WO2022247887A1 true WO2022247887A1 (zh) 2022-12-01

Family

ID=84228443

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/095134 WO2022247887A1 (zh) 2021-05-28 2022-05-26 一种线性函数对应的量子线路的构建方法及装置

Country Status (3)

Country Link
US (1) US11966815B2 (zh)
EP (1) EP4328808A1 (zh)
WO (1) WO2022247887A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117556916A (zh) * 2024-01-12 2024-02-13 深圳量旋科技有限公司 Sn2反应路径模拟方法和装置、存储介质、量子计算设备

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107025206A (zh) * 2017-04-13 2017-08-08 广西师范大学 一种量子傅立叶变换实现量子线路设计的方法
CN108710951A (zh) * 2018-05-17 2018-10-26 合肥本源量子计算科技有限责任公司 一种构建量子线路的方法及系统
CN109165741A (zh) * 2018-08-02 2019-01-08 合肥本源量子计算科技有限责任公司 量子线路的处理方法、装置、存储介质和电子装置
US10325218B1 (en) * 2016-03-10 2019-06-18 Rigetti & Co, Inc. Constructing quantum process for quantum processors
CN112016691A (zh) * 2020-08-14 2020-12-01 合肥本源量子计算科技有限责任公司 一种量子线路的构建方法及装置
CN112651509A (zh) * 2020-10-14 2021-04-13 腾讯科技(深圳)有限公司 量子线路的确定方法及装置
CN112819167A (zh) * 2019-11-15 2021-05-18 华为技术有限公司 生成量子线路的方法和相关设备

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10325218B1 (en) * 2016-03-10 2019-06-18 Rigetti & Co, Inc. Constructing quantum process for quantum processors
CN107025206A (zh) * 2017-04-13 2017-08-08 广西师范大学 一种量子傅立叶变换实现量子线路设计的方法
CN108710951A (zh) * 2018-05-17 2018-10-26 合肥本源量子计算科技有限责任公司 一种构建量子线路的方法及系统
CN109165741A (zh) * 2018-08-02 2019-01-08 合肥本源量子计算科技有限责任公司 量子线路的处理方法、装置、存储介质和电子装置
CN112819167A (zh) * 2019-11-15 2021-05-18 华为技术有限公司 生成量子线路的方法和相关设备
CN112016691A (zh) * 2020-08-14 2020-12-01 合肥本源量子计算科技有限责任公司 一种量子线路的构建方法及装置
CN112651509A (zh) * 2020-10-14 2021-04-13 腾讯科技(深圳)有限公司 量子线路的确定方法及装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117556916A (zh) * 2024-01-12 2024-02-13 深圳量旋科技有限公司 Sn2反应路径模拟方法和装置、存储介质、量子计算设备
CN117556916B (zh) * 2024-01-12 2024-03-22 深圳量旋科技有限公司 Sn2反应路径模拟方法和装置、存储介质、量子计算设备

Also Published As

Publication number Publication date
EP4328808A1 (en) 2024-02-28
US20240095571A1 (en) 2024-03-21
US11966815B2 (en) 2024-04-23

Similar Documents

Publication Publication Date Title
CN109784470A (zh) 神经网络量化方法及装置
US11966815B2 (en) Method and apparatus for constructing quantum circuit corresponding to linear function
CN112073126B (zh) 一种网络节点重要性的排序方法及装置
Wilkens et al. Quantum computing for financial risk measurement
CN114492814B (zh) 基于量子计算模拟目标体系能量的方法、装置及介质
CN114358216B (zh) 基于机器学习框架的量子聚类方法及相关装置
Albareti et al. A structured survey of quantum computing for the financial industry
Stamatopoulos et al. Derivative pricing using quantum signal processing
CN115409620A (zh) 一种基于量子线路的期权组合收益计算方法及装置
CN114819170A (zh) 基于量子线路的期权估算方法、装置、介质及电子装置
CN114998025A (zh) 投资组合决策生成方法、装置、电子设备及存储介质
CN116011681A (zh) 一种气象数据预测方法、装置、存储介质及电子装置
CN114492815B (zh) 一种基于量子化学计算目标体系能量的方法、装置及介质
CN115545947A (zh) 基于变分量子线路的最优投资组合确定方法及相关装置
Ghysels et al. Quantum Computational Algorithms for Derivative Pricing and Credit Risk in a Regime Switching Economy
US20240086750A1 (en) Quantum Circuit-Based Value-at-Risk Estimation Method, Device, Medium and Electronic Device
CN115409186A (zh) 一种分段线性函数对应的量子线路的构建方法及装置
CN115116552A (zh) 一种量子化学模拟的分子能量计算方法及装置
CN115409185A (zh) 一种线性函数对应的量子线路的构建方法及装置
CN114757357B (zh) 量子线路的振幅估计方法、装置、存储介质及电子装置
CN115131119A (zh) 基于傅里叶展开的量子期权估算方法及相关装置
CN115147201A (zh) 基于镜像对称处理的量子期权估算方法及相关装置
CN117494824A (zh) 量子芯片系统、量子计算机及其性能改进方法、相关装置
Baranes et al. Predicting Earnings Directional Movement Utilizing Recurrent Neural Networks (RNN)
CN114418108B (zh) 酉算子编译方法、计算设备、装置及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22810611

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2022810611

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2022810611

Country of ref document: EP

Effective date: 20231122

NENP Non-entry into the national phase

Ref country code: DE