mindquantum.algorithm.qaia.QAIA

View Source On Gitee
class mindquantum.algorithm.qaia.QAIA(J, h=None, x=None, n_iter=1000, batch_size=1)[source]

The base class of QAIA.

This class contains the basic and common functions of all the algorithms.

Parameters
  • J (Union[numpy.array, csr_matrix]) – The coupling matrix with shape \((N x N)\).

  • h (numpy.array) – The external field with shape \((N, )\).

  • x (numpy.array) – The initialized spin value with shape \((N x batch_size)\). Default: None.

  • n_iter (int) – The number of iterations. Default: 1000.

  • batch_size (int) – The number of sampling. Default: 1.

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.

calc_energy(x=None)[source]

Calculate energy.

Parameters

x (numpy.array) – The spin value with shape \((N x batch_size)\). If None, the initial spin will be used. Default: None.

initialize()[source]

Randomly initialize spin values.