Hypergraphstates used for optimization

convert_in_binary(number_to_convert, number_of_bits=0)[source]

Converts an int into a string containing its bits.

Example:
>>> convert_in_binary(5,3)
101
>>> convert_in_binary(5,3)
00101
Parameters:
  • number_to_convert (int) – the number that is going to be converted.
  • number_of_bits (int) – the number of bits required.
Returns:

String number : The converted number.

corresponding_state_determination(n, state, hyperedges)[source]
Determines the states corresponding to an hyperedge. That is the states
where the vertices linked by the hyperedge are equal to 1.
Parameters:
  • n (int) – The number of qubits.
  • state (list(int)) – The state of the vector.
  • hyperedges (list(list(int))) – a list containing the lists of the vertices which are linked by an hyperedge.
Param:

boolean – True if the state is in an hyperedge.

hyperedges_computation(n, state_vector, hyperedges)[source]
Puts the phases in the right places. Wherever there is an edge or an
hyperedge between some vertices, a minus sign is put where those vertices are all in state 1.
Example:
>>> hyperedges_computation(2, [0.5, 0.5, 0.5, 0.5], [[0,1]])
[0.5, 0.5, 0.5, -0.5]
Parameters:
  • n (int) – The number of qubits.
  • state_vector (list(int)) – The initialized state vector.
  • hyperedges (list[list[int]) – a list containing the lists of the vertices which are linked by an hyperedge.
Returns:

list(int) – The correct state vector.

putting_in_list(number)[source]

Puts every figure of the number in a list.

Example:
>>> putting_in_list(000)
 [0, 0, 0]
Parameters:number (int) – The number to split.
Returns:list(int) – The list with every digit of the number in a case.
state_vector_initialisation(n)[source]
Initializes the state vector; which is to create an array with the size
of 2 to the power of n. Every number in the array is equal to 1 over the square root of 2 to the power of n.
Example:
>>> state_vector_initialisation(3)
[0.35355339 0.35355339 0.35355339 0.35355339 0.35355339 0.35355339
 0.35355339 0.35355339]
Parameters:n (int) – The number of qubits.
Returns:list(int) – The initialized state vector.
states_formation(n)[source]

Calculates every state for n qubits.

Example:
>>> states_formation(3)
 [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
Parameters:n (int) – The number of qubits.
Returns:list(list(int)) – A list of all the possible states of the qubits which are also contained in a list.