'Boolean N-SAT compatibility issue

So I'm following the steps that are described in this web page:

https://qiskit.org/textbook/ch-applications/satisfiability-grover.html

to solve other SAT problems using qiskit... everything was going as described, until I reach this part:

    backend = Aer.get_backend('aer_simulator')
    quantum_instance = QuantumInstance(backend, shots=1024)

    problem = AmplificationProblem(oracle=oracle, is_good_state=v.is_correct)

    grover = Grover(quantum_instance=quantum_instance)
    result = grover.amplify(problem)
    result.top_measurement

I encounter this error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/wg/_ml06fx93y16vp67ddnck18c0000gn/T/ipykernel_96293/2289216011.py in <module>

     10 grover = Grover(quantum_instance=quantum_instance)
-->  11 result = grover.amplify(problem)
     12 result.top_measurement

~/opt/anaconda3/envs/QC/lib/python3.9/site-packages/qiskit/algorithms/amplitude_amplifiers/grover.py in amplify(self, amplification_problem)

    247 
    248             all_circuit_results.append(circuit_results)
--> 249             oracle_evaluation=amplification_problem.is_good_state(top_measurement)
    250             if oracle_evaluation is True:
    251                 break  # we found a solution

/var/folders/wg/_ml06fx93y16vp67ddnck18c0000gn/T/ipykernel_96293/3999473027.py in is_correct(self, guess)

     33                     lit_eval = not guess[int(literal)-1]
     34                 else:
---> 35                     lit_eval = guess[int(literal)-1]
     36                 clause_eval |= lit_eval
     37             if clause_eval is False:

ValueError: invalid literal for int() with base 10: ''

I'm assuming that there was a mistranslation issue somewhere, where the boolean is being interpreted as an int. If anyone know a solution or recognizes something that I messed up, I'd highly appreciate the feedback. Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source