QPanda3
Supported by OriginQ
Loading...
Searching...
No Matches
pyqpanda3.vqcircuit.vqcircuit.VQCircuit Class Reference

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.
 

Constructor & Destructor Documentation

◆ __init__()

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.

Member Function Documentation

◆ __call__()

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.

Parameters
paramsa numpy.ndarray object with all params to generate QCircuit objects

◆ __lshift__() [1/3]

VQCircuit pyqpanda3.vqcircuit.vqcircuit.VQCircuit.__lshift__ ( self,
qcircuit )

lshift(*args, **kwargs) Overloaded function.

  1. lshift(self: vqcircuit.VQCircuit, qgate: QPanda3::QGate) -> vqcircuit.VQCircuit

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

Parameters
qgatethe 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.
  1. lshift(self: vqcircuit.VQCircuit, qcircuit: QPanda3::QCircuit) -> vqcircuit.VQCircuit

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

Parameters
qcircuitthe quantum qcircuit will be inserted to the variational quantum circuit,its gates are with fixed params or without params gate to be inserted.
  1. lshift(self: vqcircuit.VQCircuit, vqgate: QPanda3::VariationalQuantumGate) -> vqcircuit.VQCircuit

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.

Parameters
vqgatea variational quantum gate object

◆ __lshift__() [2/3]

VQCircuit pyqpanda3.vqcircuit.vqcircuit.VQCircuit.__lshift__ ( self,
qgate )

lshift(*args, **kwargs) Overloaded function.

  1. lshift(self: vqcircuit.VQCircuit, qgate: QPanda3::QGate) -> vqcircuit.VQCircuit

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

Parameters
qgatethe 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.
  1. lshift(self: vqcircuit.VQCircuit, qcircuit: QPanda3::QCircuit) -> vqcircuit.VQCircuit

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

Parameters
qcircuitthe quantum qcircuit will be inserted to the variational quantum circuit,its gates are with fixed params or without params gate to be inserted.
  1. lshift(self: vqcircuit.VQCircuit, vqgate: QPanda3::VariationalQuantumGate) -> vqcircuit.VQCircuit

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.

Parameters
vqgatea variational quantum gate object

◆ __lshift__() [3/3]

VQCircuit pyqpanda3.vqcircuit.vqcircuit.VQCircuit.__lshift__ ( self,
vqgate )

lshift(*args, **kwargs) Overloaded function.

  1. lshift(self: vqcircuit.VQCircuit, qgate: QPanda3::QGate) -> vqcircuit.VQCircuit

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

Parameters
qgatethe 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.
  1. lshift(self: vqcircuit.VQCircuit, qcircuit: QPanda3::QCircuit) -> vqcircuit.VQCircuit

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

Parameters
qcircuitthe quantum qcircuit will be inserted to the variational quantum circuit,its gates are with fixed params or without params gate to be inserted.
  1. lshift(self: vqcircuit.VQCircuit, vqgate: QPanda3::VariationalQuantumGate) -> vqcircuit.VQCircuit

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.

Parameters
vqgatea variational quantum gate object

◆ append()

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.

Parameters
selfThe current VQCircuit instance.
sub_vqcThe sub-VQCircuit to be appended.
placeholder_mapA 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.
Returns
The current VQCircuit instance with the sub_vqc appended.

◆ display_ansatz()

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.

◆ get_gradients() [1/2]

ResGradients pyqpanda3.vqcircuit.vqcircuit.VQCircuit.get_gradients ( self,
numpy.ndarray[numpy.float64] params,
observable,
DiffMethod diff_method )

get_gradients(*args, **kwargs) Overloaded function.

  1. get_gradients(self: vqcircuit.VQCircuit, params: numpy.ndarray[numpy.float64], observable: QPanda3::Hamiltonian, diff_method: vqcircuit.DiffMethod) -> vqcircuit.ResGradients

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.

Parameters
paramsAn array of parameter values.
observableThe Hamiltonian for which the expectation value gradients are computed.
diff_methodThe differentiation method to use for computing gradients.
Returns
A ResGradients object containing the computed gradients.
  1. get_gradients(self: vqcircuit.VQCircuit, params: numpy.ndarray[numpy.float64], observable: QPanda3::Hamiltonian, param_group_total: int, diff_method: vqcircuit.DiffMethod) -> vqcircuit.ResNGradients

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.

Parameters
paramsAn array of parameter values.
observableThe Hamiltonian for which the expectation value gradients are computed.
param_group_totalThe total number of parameter groups.
diff_methodThe differentiation method to use for computing gradients.
Returns
A ResNGradients object containing the computed gradients.

◆ get_gradients() [2/2]

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.

  1. get_gradients(self: vqcircuit.VQCircuit, params: numpy.ndarray[numpy.float64], observable: QPanda3::Hamiltonian, diff_method: vqcircuit.DiffMethod) -> vqcircuit.ResGradients

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.

Parameters
paramsAn array of parameter values.
observableThe Hamiltonian for which the expectation value gradients are computed.
diff_methodThe differentiation method to use for computing gradients.
Returns
A ResGradients object containing the computed gradients.
  1. get_gradients(self: vqcircuit.VQCircuit, params: numpy.ndarray[numpy.float64], observable: QPanda3::Hamiltonian, param_group_total: int, diff_method: vqcircuit.DiffMethod) -> vqcircuit.ResNGradients

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.

Parameters
paramsAn array of parameter values.
observableThe Hamiltonian for which the expectation value gradients are computed.
param_group_totalThe total number of parameter groups.
diff_methodThe differentiation method to use for computing gradients.
Returns
A ResNGradients object containing the computed gradients.

◆ get_gradients_and_expectation() [1/2]

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.

  1. get_gradients_and_expectation(self: vqcircuit.VQCircuit, params: numpy.ndarray[numpy.float64], observable: QPanda3::Hamiltonian, diff_method: vqcircuit.DiffMethod) -> vqcircuit.ResGradientsAndExpectation

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.

Parameters
paramsAn array of parameter values.
observableThe Hamiltonian for which the expectation value and its gradients are computed.
diff_methodThe differentiation method to use for computing gradients.
Returns
A ResGradientsAndExpectation object containing the computed gradients and expectation value.
  1. get_gradients_and_expectation(self: vqcircuit.VQCircuit, params: numpy.ndarray[numpy.float64], observable: QPanda3::Hamiltonian, param_group_total: int, diff_method: vqcircuit.DiffMethod) -> vqcircuit.ResNResGradientsAndExpectation

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.

Parameters
paramsAn array of parameter values.
observableThe Hamiltonian for which the expectation value and its gradients are computed.
param_group_totalThe total number of parameter groups.
diff_methodThe differentiation method to use for computing gradients.
Returns
A ResNResGradientsAndExpectation object containing the computed gradients and expectation value.

◆ get_gradients_and_expectation() [2/2]

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.

  1. get_gradients_and_expectation(self: vqcircuit.VQCircuit, params: numpy.ndarray[numpy.float64], observable: QPanda3::Hamiltonian, diff_method: vqcircuit.DiffMethod) -> vqcircuit.ResGradientsAndExpectation

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.

Parameters
paramsAn array of parameter values.
observableThe Hamiltonian for which the expectation value and its gradients are computed.
diff_methodThe differentiation method to use for computing gradients.
Returns
A ResGradientsAndExpectation object containing the computed gradients and expectation value.
  1. get_gradients_and_expectation(self: vqcircuit.VQCircuit, params: numpy.ndarray[numpy.float64], observable: QPanda3::Hamiltonian, param_group_total: int, diff_method: vqcircuit.DiffMethod) -> vqcircuit.ResNResGradientsAndExpectation

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.

Parameters
paramsAn array of parameter values.
observableThe Hamiltonian for which the expectation value and its gradients are computed.
param_group_totalThe total number of parameter groups.
diff_methodThe differentiation method to use for computing gradients.
Returns
A ResNResGradientsAndExpectation object containing the computed gradients and expectation value.

◆ get_Param_dims()

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.

Returns
returns a vector of size_t values representing the dimension sizes associated with the Param object.

◆ mutable_parameter_total()

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.

Returns
The total number of mutable parameters.

◆ Param()

pyqpanda3.vqcircuit.vqcircuit.VQCircuit.Param ( self,
* args,
** kwargs )

Param(*args, **kwargs) Overloaded function.

  1. Param(self: vqcircuit.VQCircuit, idxs: list[int], emement_label: str) -> QPanda3::VQCParamSystem::ParamExpression

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.

Parameters
idxsa vector of indices specifying a position in a multi-dimensional array
emement_labela label string to identify the parameter
Returns
th position in the multi-dimensional array
  1. Param(self: vqcircuit.VQCircuit, idxs: list[int]) -> QPanda3::VQCParamSystem::ParamExpression

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.

Parameters
idxsa vector of indices specifying a position in a multi-dimensional array
Returns
th position in the multi-dimensional array
  1. Param(self: vqcircuit.VQCircuit, emement_label: str) -> QPanda3::VQCParamSystem::ParamExpression

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.

Parameters
emement_labela label string to identify the parameter
Returns
th position in the multi-dimensional array

◆ set_Param() [1/2]

None pyqpanda3.vqcircuit.vqcircuit.VQCircuit.set_Param ( self,
list[int] dim_size_s )

set_Param(*args, **kwargs) Overloaded function.

  1. set_Param(self: vqcircuit.VQCircuit, dim_size_s: list[int], dim_label_s: list[str]) -> None

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.

Parameters
dim_size_sa vector with dim's sizes
dim_label_sa vector with dim's labels
  1. set_Param(self: vqcircuit.VQCircuit, dim_size_s: list[int]) -> None

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.

Parameters
dim_size_sa vector with dim's sizes

◆ set_Param() [2/2]

None pyqpanda3.vqcircuit.vqcircuit.VQCircuit.set_Param ( self,
list[int] dim_size_s,
list[str] dim_label_s )

set_Param(*args, **kwargs) Overloaded function.

  1. set_Param(self: vqcircuit.VQCircuit, dim_size_s: list[int], dim_label_s: list[str]) -> None

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.

Parameters
dim_size_sa vector with dim's sizes
dim_label_sa vector with dim's labels
  1. set_Param(self: vqcircuit.VQCircuit, dim_size_s: list[int]) -> None

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.

Parameters
dim_size_sa vector with dim's sizes

The documentation for this class was generated from the following file: