Mermin polynomials used for optimization

a_matrix(n, t)[source]

Constitutes the matrix a of the Mermin polynomial.

Parameters:
  • n (int) – The number of qubits.
  • t (np.array(list(float))) – The table of coefficients.
Returns:

np.array(complex) – The matrice a of mn.

a_prime_matrix(n, t)[source]

Constitutes the matrix a’ of the Mermin polynomial.

Parameters:
  • n (int) – The number of qubits.
  • t (np.array(list(float))) – The table of coefficients.
Returns:

np.array(complex) – The matrice a’ of mn.

first_coefficients_generation(n)[source]

Generates the very first coefficients for the calculation of MU.

Example :
>>> first_coefficients_generation(2)
[[ 0.24006446 -0.97020025 0.03287126]
 [0.72092088 -0.59054414  0.36267162]
 [-0.76022821 0.64723032 -0.056089]
 [-0.0278048  0.48298397 -0.87518763]]
Parameters:n (int) – The number of qubits.
Returns:np.array(list(float)) – The table of list of the coefficient taken randomly.
mermin(n, t)[source]

Calculates the Mermin polynomial \(mn\).

Parameters:
  • n (int) – The number of qubits.
  • t (np.array(list(float))) – The table of coefficients.
Returns:

np.array(complex) – The Mermin polynomial \(mn\).

mermin_prime(n, t)[source]

Calculates the Mermin polynomial \(mn'\).

Parameters:
  • n (int) – The number of qubits
  • t (np.array(list(float))) – The table of coefficients
Returns:

np.array(complex) – The Mermin polynomial \(mn'\)

mu_calculation(mn, mn_prime, vector, type_of_mu)[source]
Calculates MU, the value of the calculation of the vector with the
mermin polynomial.
Parameters:
  • mn (np.array(complex)) – The Mermin polynomial \(mn\).
  • mn_prime (np.array(complex)) – The Mermin polynomial \(mn'\).
  • vector (list(int)) – The state vector.
  • bool (type_of_mu) – If False, the classical calculation will be made. If not, another method is used.
Returns:

float – The value of the calculation.

mu_file_saving(n, file_path, first_mu, first_parameters, maximal_mu, maximisation_parameters, type_of_mu)[source]

Creates a file to write the various calculation parameters

Parameters:
  • n (int) – The number of qubits.
  • file_path (string) – The path where the file is to be saved
  • first_mu (float) – The value of the calculation of the vector with the mermin polynomial
  • first_parameters (np.array(list(float))) – The first coefficients of Mu calculation
  • maximal_mu (float) – The value of the maximal Mu calculated
new_coefficients_generation(n, old_coefficients, alpha)[source]

Random generation of new parameters for MU maximization

Parameters:
  • n (int) – The number of qubits
  • old_coefficients (np.array(list(float))) – The table of the coefficients that didn’t maximize Mu
  • alpha (int) – The value of the descent step (used in the random walk method)
Returns:

np.array(list(float)) – Table of new coefficients

xbest_calculation(n, type_of_mu, alpha, alpha_minimum, c_maximum, vector, file_path, saving_file=True)[source]
Maximizes Mu. The algorithm used here is called the Random walk method.
The principle is simple. We randomly generate first parameters which are used to calculate Mu. The first value of Mu is called Mu0. Then, we calculate new parameters based on the previous ones and a variable called the descent step. With the new parameters, we calculate a new value of Mu. If this value is better than the previous one, we keep it and continue the researches until a counter is at its maximum value. The goal here is to take a big circle of research scope and to reduce it (by decreasing the decent step) more and more until the maximum value of Mu is found.
Parameters:
  • n (int) – The number of qubits.
  • bool (type_of_mu) – If False is specified, the classical calculation will be made. If not, another method is used.
  • alpha (int) – The value of the descent step.
  • alpha_minimum (int) – The minimum value of the descent step (which is the length of the radius).
  • c_maximum (int) – The maximum value of the counter.
  • vector (list(int)) – The vector for the calculation of Mu.
  • file_path (string) – The path where the file is to be saved.
  • saving_file (boolean) – If set to True, a file will be created / overloaded with the information about the calculation of Mu. If not, only the calculations are made.
Returns:

np.array(list(float)) – The array that contains the parameters that maximizes Mu.