qiskit.optimization.applications.ising.partition

Generate Number Partitioning (Partition) instances, and convert them into a Hamiltonian given as a Pauli list.

Functions

get_operator(values)

Construct the Hamiltonian for a given Partition instance.

partition_value(x, number_list)

Compute the value of a partition.

get_operator(values)[source]

Construct the Hamiltonian for a given Partition instance.

Given a list of numbers for the Number Partitioning problem, we construct the Hamiltonian described as a list of Pauli gates.

Parameters

values (numpy.ndarray) – array of values.

Returns

operator for the Hamiltonian and a constant shift for the obj function.

Return type

tuple(WeightedPauliOperator, float)

partition_value(x, number_list)[source]

Compute the value of a partition.

Parameters
  • x (numpy.ndarray) – binary string as numpy array.

  • number_list (numpy.ndarray) – list of numbers in the instance.

Returns

difference squared between the two sides of the number

partition.

Return type

float