import pylab
from qiskit_aqua import run_algorithm
from qiskit_aqua.input import get_input_instance
from qiskit.tools.visualization import matplotlib_circuit_drawer as draw
from qiskit.tools.visualization import plot_histogram

with open('3sat3-5.cnf', 'r') as f:
    sat_cnf = f.read()
print(sat_cnf)

algorithm_cfg = {
    'name': 'Grover'
}

oracle_cfg = {
    'name': 'SAT',
    'cnf': sat_cnf
}

params = {
    'problem': {'name': 'search', 'random_seed': 50},
    'algorithm': algorithm_cfg,
    'oracle': oracle_cfg,
    'backend': {'name': 'qasm_simulator'}
}

result = run_algorithm(params)
print(result['result'])

pylab.rcParams['figure.figsize'] = (8, 4)
plot_histogram(result['measurements'])

#draw(result['circuit'])