mindquantum.algorithm.qaia.SFC

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

Coherent Ising Machine with separated feedback control algorithm.

Reference: Coherent Ising machines with optical error correction circuits.

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 (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 drawn from normal distribution N(0, 0.1). Default: None.

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

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

  • dt (float) – The step size. Default: 0.1.

  • k (float) – parameter of deviation between mean-field and error variables. Default: 0.2.

Examples

>>> import numpy as np
>>> from mindquantum.algorithm.qaia import SFC
>>> J = np.array([[0, -1], [-1, 0]])
>>> solver = SFC(J, batch_size=5)
>>> solver.update()
>>> print(solver.calc_cut())
[1. 1. 1. 1. 1.]
>>> print(solver.calc_energy())
[-1. -1. -1. -1. -1.]
initialize()[source]

Initialize spin values and error variables.

update()[source]

Dynamical evolution.