qiskit.optimization.applications.ising.exact_cover

exact cover

Functions

check_solution_satisfiability(sol, …)

check solution satisfiability

get_operator(list_of_subsets)

Construct the Hamiltonian for the exact solver problem.

get_solution(x)

param x

binary string as numpy array.

check_solution_satisfiability(sol, list_of_subsets)[source]

check solution satisfiability

get_operator(list_of_subsets)[source]

Construct the Hamiltonian for the exact solver problem.

Note

Assumption: the union of the subsets contains all the elements to cover.
The Hamiltonian is:
sum_{each element e}{(1-sum_{every subset_i that contains e}{Xi})^2},
where Xi (Xi=1 or 0) means whether should include the subset i.
Parameters

list_of_subsets (list) – list of lists (i.e., subsets)

Returns

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

Return type

tuple(WeightedPauliOperator, float)

get_solution(x)[source]
Parameters

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

Returns

graph solution as binary numpy array.

Return type

numpy.ndarray