mindquantum.algorithm.qaia.QAIA
- class mindquantum.algorithm.qaia.QAIA(J, h=None, x=None, n_iter=1000, batch_size=1, backend='cpu-float32')[source]
The base class of QAIA.
This class contains the basic and common functions of all the algorithms.
Note
For memory efficiency, the input array 'x' is not copied and will be modified in-place during optimization. If you need to preserve the original data, please pass a copy using x.copy().
- Parameters
J (Union[numpy.array, scipy.sparse.spmatrix]) – The coupling matrix with shape (N x N).
h (numpy.array) – The external field with shape (N x 1).
x (numpy.array) – The initialized spin value with shape (N x batch_size). Will be modified during optimization. If not provided (
None
), will be initialized as random values uniformly distributed in [-0.01, 0.01]. Default:None
.n_iter (int) – The number of iterations. Default:
1000
.batch_size (int) – The number of sampling. Default:
1
.backend (str) – Computation backend and precision to use: 'cpu-float32','gpu-float32', 'gpu-float16', 'gpu-int8','npu-float32'. Default:
'cpu-float32'
.
- calc_cut(x=None)[source]
Calculate cut value.
- Parameters
x (numpy.array) – The spin value with shape (N x batch_size). If
None
, the initial spin will be used. Default:None
.