Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Circuits are not compatible when calling TruthTableOracle #1125

Closed
PabloAMC opened this issue Jul 20, 2020 · 0 comments · Fixed by #1128
Closed

Circuits are not compatible when calling TruthTableOracle #1125

PabloAMC opened this issue Jul 20, 2020 · 0 comments · Fixed by #1128

Comments

@PabloAMC
Copy link

Information

  • Qiskit Aqua version: 0.7.3
  • Python version: Python 3.7.6
  • Operating system: IBM Quantum Experience

What is the current behavior?

CircuitError                              Traceback (most recent call last)
<ipython-input-27-e8ddb0ce8be9> in <module>
----> 1 oracle = TruthTableOracle(bitmap, optimization = True, mct_mode = 'basic')
      2 oracle.circuit.num_qubits

/opt/conda/lib/python3.7/site-packages/qiskit/aqua/components/oracles/truth_table_oracle.py in __init__(self, bitmaps, optimization, mct_mode)
    134         ] if esop_exprs else None
    135 
--> 136         self.construct_circuit()
    137 
    138     def _get_esop_ast(self, bitmap):

/opt/conda/lib/python3.7/site-packages/qiskit/aqua/components/oracles/truth_table_oracle.py in construct_circuit(self)
    214                         mct_mode=self._mct_mode
    215                     )
--> 216                     self._circuit += ci
    217             self._variable_register = self._ancillary_register = None
    218             for qreg in self._circuit.qregs:

/opt/conda/lib/python3.7/site-packages/qiskit/circuit/quantumcircuit.py in __iadd__(self, rhs)
    442     def __iadd__(self, rhs):
    443         """Overload += to implement self.extend."""
--> 444         return self.extend(rhs)
    445 
    446     def __len__(self):

/opt/conda/lib/python3.7/site-packages/qiskit/circuit/quantumcircuit.py in extend(self, rhs)
    335         """
    336         # Check registers in LHS are compatible with RHS
--> 337         self._check_compatible_regs(rhs)
    338 
    339         # Add new registers

/opt/conda/lib/python3.7/site-packages/qiskit/circuit/quantumcircuit.py in _check_compatible_regs(self, rhs)
    706                 if element2.name == element1.name:
    707                     if element1 != element2:
--> 708                         raise CircuitError("circuits are not compatible")
    709 
    710     def qasm(self, formatted=False, filename=None):

CircuitError: 'circuits are not compatible'

Steps to reproduce the problem

First load some basic libraries

%matplotlib inline
# Importing standard Qiskit libraries and configuring account
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from qiskit.visualization import *
# Loading your IBM Q account(s)
provider = IBMQ.load_account()

from qiskit.aqua.components.oracles import Oracle, TruthTableOracle
from qiskit.circuit import QuantumRegister, ClassicalRegister, QuantumCircuit, Qubit

import math
import numpy as np

Then define the following bitmap (this is funny because if you change the bitmap the error might not happen)

bitmap = ['0000000000000000000000000000000000000000000000000000000000000000', 
'0000000000000000110011001100110000000000000000000000000000000000', 
'0000000000000000110011001100110000000000000000000000000000000000', 
'0000000000100000000000000010000100000000001100000000000000100000']
print(len(bitmap[0]),len(bitmap[1]),len(bitmap[2]),len(bitmap[3]))
print(2**6)

what returns 64 in all cases as expected. Finally call

oracle = TruthTableOracle(bitmap, optimization = True, mct_mode = 'basic')

What is the expected behavior?

Returns an ordinary oracle from the class TruthTableOracle.

Suggested solutions

If one changes the bitmap, the optimization, or the mct_mode, the error dissapears. However, the problems seems deep into qiskit.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant