CNFSolver
QuICT.algorithm.quantum_algorithm.CNFSolver ¶
A solver for CNF satisfiability problem by using grover's search algorithm.
Parameters:
-
cnf_file(str) –Path to the cnf dimacs file.
Source code in QuICT/algorithm/quantum_algorithm/cnf_solver/cnf_solver.py
check_solution ¶
Check if the given assignment is a satisfying assignment for the cnf.
Parameters:
-
assignment(str) –the variable assignments to be tested.
Returns: bool, whether or not the cnf is satisfied.
Source code in QuICT/algorithm/quantum_algorithm/cnf_solver/cnf_solver.py
circuit ¶
Construct grover search circuit for cnf-sat problem.
Parameters:
-
iteration(int) –number of cnf oracle query in the circuit.
Returns: Circuit, the quantum circuit for cnf-sat problem with given iteration.
Source code in QuICT/algorithm/quantum_algorithm/cnf_solver/cnf_solver.py
run ¶
Given number of solution, run cnf solver with the optimal grover iteration.
Parameters:
-
n_solution(int) –number of solutions for the cnf-sat problem.
-
backend(Any, default:StateVectorSimulator()) –Device to run the quantum algorithm.
-
shots(int, default:1) –Number of experiments to run.
Dict[str, int], a dictionary in which the key-value pairs are sample strings, denoting cnf
-
Dict[str, int]–variable assignments, with their number of times been sampled.
Source code in QuICT/algorithm/quantum_algorithm/cnf_solver/cnf_solver.py
run_iterative ¶
Search by iterative grover without knowning the number of satisfiable solutions.
Parameters:
-
backend(Any, default:StateVectorSimulator()) –Device to run the quantum algorithm.
Tuple[str, int] | None, when success, the satisfying assignment and the number of
-
Union[Tuple[str, int], None]–oracle calls been used are returned.