![]() |
QPanda3
Supported by OriginQ
|
Public Member Functions | |
None | __init__ (self, bool pre_split=...) |
init(self: vqcircuit.VQCircuit, pre_split: bool = True) -> None | |
Param (self, *args, **kwargs) | |
Param(*args, **kwargs) Overloaded function. | |
VQCircuit | append (self, VQCircuit sub_vqc, placeholder_map) |
append(self: vqcircuit.VQCircuit, sub_vqc: vqcircuit.VQCircuit, placeholder_map: list[tuple[QPanda3::VQCParamSystem::ParamExpression, QPanda3::VQCParamSystem::ParamExpression]]) -> vqcircuit.VQCircuit | |
str | display_ansatz (self) |
display_ansatz(self: vqcircuit.VQCircuit) -> str | |
list[int] | get_Param_dims (self) |
get_Param_dims(self: vqcircuit.VQCircuit) -> list[int] | |
ResGradients | get_gradients (self, numpy.ndarray[numpy.float64] params, observable, DiffMethod diff_method) |
get_gradients(*args, **kwargs) Overloaded function. | |
ResNGradients | get_gradients (self, numpy.ndarray[numpy.float64] params, observable, int param_group_total, DiffMethod diff_method) |
get_gradients(*args, **kwargs) Overloaded function. | |
ResGradientsAndExpectation | get_gradients_and_expectation (self, numpy.ndarray[numpy.float64] params, observable, DiffMethod diff_method) |
get_gradients_and_expectation(*args, **kwargs) Overloaded function. | |
ResNResGradientsAndExpectation | get_gradients_and_expectation (self, numpy.ndarray[numpy.float64] params, observable, int param_group_total, DiffMethod diff_method) |
get_gradients_and_expectation(*args, **kwargs) Overloaded function. | |
int | mutable_parameter_total (self) |
mutable_parameter_total(self: vqcircuit.VQCircuit) -> int | |
None | set_Param (self, list[int] dim_size_s, list[str] dim_label_s) |
set_Param(*args, **kwargs) Overloaded function. | |
None | set_Param (self, list[int] dim_size_s) |
set_Param(*args, **kwargs) Overloaded function. | |
__call__ (self, *args, **kwargs) | |
call(self: vqcircuit.VQCircuit, params: numpy.ndarray[numpy.float64]) -> QPanda3::VQCircuitResultOld | |
VQCircuit | __lshift__ (self, qgate) |
lshift(*args, **kwargs) Overloaded function. | |
VQCircuit | __lshift__ (self, qcircuit) |
lshift(*args, **kwargs) Overloaded function. | |
VQCircuit | __lshift__ (self, vqgate) |
lshift(*args, **kwargs) Overloaded function. | |
None pyqpanda3.vqcircuit.vqcircuit.VQCircuit.__init__ | ( | self, | |
bool | pre_split = ... ) |
init(self: vqcircuit.VQCircuit, pre_split: bool = True) -> None
Constructs a new instance of the VariationalQuantumCircuit class.
This constructor initializes a new empty instance of the VariationalQuantumCircuit class, ready for further configuration and use.
pyqpanda3.vqcircuit.vqcircuit.VQCircuit.__call__ | ( | self, | |
* | args, | ||
** | kwargs ) |
call(self: vqcircuit.VQCircuit, params: numpy.ndarray[numpy.float64]) -> QPanda3::VQCircuitResultOld
Applies parameter values to the variational quantum circuit and evaluates it.
This method applies the provided parameter values (data
) to the variational quantum circuit, considering the specified dimension sizes (dim_size_s
). operator (<<
). The variational quantum gate to be inserted is specified as the parameter vqgate
.It then evaluates the circuit and returns the result as a VQCircuitResult
object.
params | a numpy.ndarray object with all params to generate QCircuit objects |
VQCircuit pyqpanda3.vqcircuit.vqcircuit.VQCircuit.__lshift__ | ( | self, | |
qcircuit ) |
lshift(*args, **kwargs) Overloaded function.
Inserts a quantum gate into the variational quantum circuit.
This operator overload allows for the insertion of quantum gates into the variational quantum circuit using the stream insertion operator (<<
). The quantum
qgate | the quantum gate will be inserted to the variational quantum circuit,the qgate is with fixed params or without pparams gate to be inserted is specified as the parameter qgate . |
Inserts a quantum circuit into the variational quantum circuit.
This operator overload allows for the insertion of a complete quantum circuit into the variational quantum circuit using the stream insertion operator (<<
). The quantum circuit to be inserted is specified as the parameter qcircuit
qcircuit | the quantum qcircuit will be inserted to the variational quantum circuit,its gates are with fixed params or without params gate to be inserted. |
Inserts a variational quantum gate into the variational quantum circuit.
This operator overload allows for the insertion of a variational quantum gate into the variational quantum circuit using the stream insertion operator (<<
). The variational quantum gate to be inserted is specified as the parameter vqgate
.
vqgate | a variational quantum gate object |
VQCircuit pyqpanda3.vqcircuit.vqcircuit.VQCircuit.__lshift__ | ( | self, | |
qgate ) |
lshift(*args, **kwargs) Overloaded function.
Inserts a quantum gate into the variational quantum circuit.
This operator overload allows for the insertion of quantum gates into the variational quantum circuit using the stream insertion operator (<<
). The quantum
qgate | the quantum gate will be inserted to the variational quantum circuit,the qgate is with fixed params or without pparams gate to be inserted is specified as the parameter qgate . |
Inserts a quantum circuit into the variational quantum circuit.
This operator overload allows for the insertion of a complete quantum circuit into the variational quantum circuit using the stream insertion operator (<<
). The quantum circuit to be inserted is specified as the parameter qcircuit
qcircuit | the quantum qcircuit will be inserted to the variational quantum circuit,its gates are with fixed params or without params gate to be inserted. |
Inserts a variational quantum gate into the variational quantum circuit.
This operator overload allows for the insertion of a variational quantum gate into the variational quantum circuit using the stream insertion operator (<<
). The variational quantum gate to be inserted is specified as the parameter vqgate
.
vqgate | a variational quantum gate object |
VQCircuit pyqpanda3.vqcircuit.vqcircuit.VQCircuit.__lshift__ | ( | self, | |
vqgate ) |
lshift(*args, **kwargs) Overloaded function.
Inserts a quantum gate into the variational quantum circuit.
This operator overload allows for the insertion of quantum gates into the variational quantum circuit using the stream insertion operator (<<
). The quantum
qgate | the quantum gate will be inserted to the variational quantum circuit,the qgate is with fixed params or without pparams gate to be inserted is specified as the parameter qgate . |
Inserts a quantum circuit into the variational quantum circuit.
This operator overload allows for the insertion of a complete quantum circuit into the variational quantum circuit using the stream insertion operator (<<
). The quantum circuit to be inserted is specified as the parameter qcircuit
qcircuit | the quantum qcircuit will be inserted to the variational quantum circuit,its gates are with fixed params or without params gate to be inserted. |
Inserts a variational quantum gate into the variational quantum circuit.
This operator overload allows for the insertion of a variational quantum gate into the variational quantum circuit using the stream insertion operator (<<
). The variational quantum gate to be inserted is specified as the parameter vqgate
.
vqgate | a variational quantum gate object |
VQCircuit pyqpanda3.vqcircuit.vqcircuit.VQCircuit.append | ( | self, | |
VQCircuit | sub_vqc, | ||
placeholder_map ) |
append(self: vqcircuit.VQCircuit, sub_vqc: vqcircuit.VQCircuit, placeholder_map: list[tuple[QPanda3::VQCParamSystem::ParamExpression, QPanda3::VQCParamSystem::ParamExpression]]) -> vqcircuit.VQCircuit
Appends a sub-VQCircuit to the current VQCircuit with a placeholder map.
This method appends the given sub_vqc to the current VQCircuit instance. The placeholder_map is used to map parameters in the sub_vqc to the parameters in the current VQCircuit.
Add all quantum gates in a VQCircuit object subvqc to a VQCircuit object self. The addition process only re-maps and sets the placeholder. If the variable parameter of a quantum gate is in the form of an expression, during the addition process, it still retains its expression form, but the placeholder that constitutes the expression changes from a placeholder of subvqc to a placeholder of self. When self updates the value of the placeholder, subvqc is not affected.
self | The current VQCircuit instance. |
sub_vqc | The sub-VQCircuit to be appended. |
placeholder_map | A list of tuples where each tuple contains two ParamExpression objects. The first element is the parameter from the sub_vqc, and the second element is the corresponding parameter in the current VQCircuit. |
str pyqpanda3.vqcircuit.vqcircuit.VQCircuit.display_ansatz | ( | self | ) |
display_ansatz(self: vqcircuit.VQCircuit) -> str
Displays the structure of the ansatz (variational quantum circuit).
This method prints or otherwise displays the structure and components of the variational quantum circuit (ansatz) to the user.
ResGradients pyqpanda3.vqcircuit.vqcircuit.VQCircuit.get_gradients | ( | self, | |
numpy.ndarray[numpy.float64] | params, | ||
observable, | |||
DiffMethod | diff_method ) |
get_gradients(*args, **kwargs) Overloaded function.
Retrieve the gradients of the expectation value with respect to the parameters.
This function computes the gradients of the expectation value of a given Hamiltonian with respect to the specified parameters using the specified differentiation method.
params | An array of parameter values. |
observable | The Hamiltonian for which the expectation value gradients are computed. |
diff_method | The differentiation method to use for computing gradients. |
Retrieve the gradients of the expectation value with respect to the parameters.
This function computes the gradients of the expectation value of a given Hamiltonian with respect to the specified parameters using the specified differentiation method.
params | An array of parameter values. |
observable | The Hamiltonian for which the expectation value gradients are computed. |
param_group_total | The total number of parameter groups. |
diff_method | The differentiation method to use for computing gradients. |
ResNGradients pyqpanda3.vqcircuit.vqcircuit.VQCircuit.get_gradients | ( | self, | |
numpy.ndarray[numpy.float64] | params, | ||
observable, | |||
int | param_group_total, | ||
DiffMethod | diff_method ) |
get_gradients(*args, **kwargs) Overloaded function.
Retrieve the gradients of the expectation value with respect to the parameters.
This function computes the gradients of the expectation value of a given Hamiltonian with respect to the specified parameters using the specified differentiation method.
params | An array of parameter values. |
observable | The Hamiltonian for which the expectation value gradients are computed. |
diff_method | The differentiation method to use for computing gradients. |
Retrieve the gradients of the expectation value with respect to the parameters.
This function computes the gradients of the expectation value of a given Hamiltonian with respect to the specified parameters using the specified differentiation method.
params | An array of parameter values. |
observable | The Hamiltonian for which the expectation value gradients are computed. |
param_group_total | The total number of parameter groups. |
diff_method | The differentiation method to use for computing gradients. |
ResGradientsAndExpectation pyqpanda3.vqcircuit.vqcircuit.VQCircuit.get_gradients_and_expectation | ( | self, | |
numpy.ndarray[numpy.float64] | params, | ||
observable, | |||
DiffMethod | diff_method ) |
get_gradients_and_expectation(*args, **kwargs) Overloaded function.
Retrieve the gradients of the expectation value and the expectation value itself with respect to the parameters.
this function computes both the gradients of the expectation value and the expectation value of a given Hamiltonian with respect to the specified parameters using the specified differentiation method.
params | An array of parameter values. |
observable | The Hamiltonian for which the expectation value and its gradients are computed. |
diff_method | The differentiation method to use for computing gradients. |
Retrieve the gradients of the expectation value and the expectation value itself with respect to the parameters.
This function computes both the gradients of the expectation value and the expectation value of a given Hamiltonian with respect to the specified parameters using the specified differentiation method.
params | An array of parameter values. |
observable | The Hamiltonian for which the expectation value and its gradients are computed. |
param_group_total | The total number of parameter groups. |
diff_method | The differentiation method to use for computing gradients. |
ResNResGradientsAndExpectation pyqpanda3.vqcircuit.vqcircuit.VQCircuit.get_gradients_and_expectation | ( | self, | |
numpy.ndarray[numpy.float64] | params, | ||
observable, | |||
int | param_group_total, | ||
DiffMethod | diff_method ) |
get_gradients_and_expectation(*args, **kwargs) Overloaded function.
Retrieve the gradients of the expectation value and the expectation value itself with respect to the parameters.
this function computes both the gradients of the expectation value and the expectation value of a given Hamiltonian with respect to the specified parameters using the specified differentiation method.
params | An array of parameter values. |
observable | The Hamiltonian for which the expectation value and its gradients are computed. |
diff_method | The differentiation method to use for computing gradients. |
Retrieve the gradients of the expectation value and the expectation value itself with respect to the parameters.
This function computes both the gradients of the expectation value and the expectation value of a given Hamiltonian with respect to the specified parameters using the specified differentiation method.
params | An array of parameter values. |
observable | The Hamiltonian for which the expectation value and its gradients are computed. |
param_group_total | The total number of parameter groups. |
diff_method | The differentiation method to use for computing gradients. |
list[int] pyqpanda3.vqcircuit.vqcircuit.VQCircuit.get_Param_dims | ( | self | ) |
get_Param_dims(self: vqcircuit.VQCircuit) -> list[int]
Retrieves the dimension information of the Param
object.
Param
object. int pyqpanda3.vqcircuit.vqcircuit.VQCircuit.mutable_parameter_total | ( | self | ) |
mutable_parameter_total(self: vqcircuit.VQCircuit) -> int
Get the total number of mutable parameters.
This function returns the total number of parameters used.
pyqpanda3.vqcircuit.vqcircuit.VQCircuit.Param | ( | self, | |
* | args, | ||
** | kwargs ) |
Param(*args, **kwargs) Overloaded function.
Retrieves the multi-dimensional array indices and associates a label with the corresponding parameter.
This method takes a vector of indices (idxs
) specifying a position in a multi-dimensional array, along with a label string (element_label
) to identify the parameter at that position.It returns the provided indices and internally associates the label with the corresponding parameter.
idxs | a vector of indices specifying a position in a multi-dimensional array |
emement_label | a label string to identify the parameter |
Retrieves the multi-dimensional array indices and associates a label with the corresponding parameter.
This method takes a vector of indices (idxs
) specifying a position in a multi-dimensional array, along with a label string (element_label
) to identify the parameter at that position.It returns the provided indices and internally associates the label with the corresponding parameter.
idxs | a vector of indices specifying a position in a multi-dimensional array |
Retrieves the multidimensional array index for a variable parameter with a specified label.
This method takes a label string for a variable parameter and returns the corresponding multidimensional array index.
emement_label | a label string to identify the parameter |
None pyqpanda3.vqcircuit.vqcircuit.VQCircuit.set_Param | ( | self, | |
list[int] | dim_size_s ) |
set_Param(*args, **kwargs) Overloaded function.
Sets the dimension sizes and labels for the Param
object.
This method allows the user to specify both the dimension sizes and corresponding labels for the Param
object.
dim_size_s | a vector with dim's sizes |
dim_label_s | a vector with dim's labels |
Sets the dimension sizes for the Param
object.
This method allows the user to specify the dimension sizes for the Param
object using a vector of size_t values.
dim_size_s | a vector with dim's sizes |
None pyqpanda3.vqcircuit.vqcircuit.VQCircuit.set_Param | ( | self, | |
list[int] | dim_size_s, | ||
list[str] | dim_label_s ) |
set_Param(*args, **kwargs) Overloaded function.
Sets the dimension sizes and labels for the Param
object.
This method allows the user to specify both the dimension sizes and corresponding labels for the Param
object.
dim_size_s | a vector with dim's sizes |
dim_label_s | a vector with dim's labels |
Sets the dimension sizes for the Param
object.
This method allows the user to specify the dimension sizes for the Param
object using a vector of size_t values.
dim_size_s | a vector with dim's sizes |