MatchingDAGCircuit
QuICT.qcda.optimization.template_optimization.template_matching.Match ¶
Class to store matches
Source code in QuICT/qcda/optimization/template_optimization/template_matching/matching_dag_circuit.py
QuICT.qcda.optimization.template_optimization.template_matching.MatchingDAGCircuit ¶
Bases: DAGCircuit
DAG circuit class tailored for template matching algorithm.
Source code in QuICT/qcda/optimization/template_optimization/template_matching/matching_dag_circuit.py
all_predecessors ¶
Return all predecessors (direct and undirect) of start.
start can be a node id (int) or many node ids (Iterable).
Return values of single node query will be cached if cache_enable is True
Parameters:
-
start(int / Iterable) –the start node(s)
-
cache_enabled(bool, default:True) –whether use cache
Returns:
-
set(Set[int]) –set of predecessors
Source code in QuICT/qcda/optimization/template_optimization/template_matching/matching_dag_circuit.py
all_successors ¶
Return all successors (direct and indirect) of start.
start can be a node id (int) or many node ids (Iterable).
Return values of single node query will be cached if cache_enable is True.
Parameters:
-
start(int / Iterable) –the start node(s)
-
cache_enabled(bool, default:True) –whether use cache
Returns:
-
Set[int]–Set[int]: set of successors
Source code in QuICT/qcda/optimization/template_optimization/template_matching/matching_dag_circuit.py
get_circuit ¶
Output the circuit of this DAG.
Returns:
-
Circuit(Circuit) –the circuit
Source code in QuICT/qcda/optimization/template_optimization/template_matching/matching_dag_circuit.py
init_forward_matching ¶
Initialize forward matching info.
Parameters:
-
node_id(int) –the start node of forward matching
-
other_id(int) –the start node of the other circuit to match
-
s2v_enabled(bool, default:False) –whether initialize successors_to_visit
Source code in QuICT/qcda/optimization/template_optimization/template_matching/matching_dag_circuit.py
matching_info ¶
Returns:
-
List[NodeInfo]–List[NodeInfo]: matching info used by backward_match
Source code in QuICT/qcda/optimization/template_optimization/template_matching/matching_dag_circuit.py
QuICT.qcda.optimization.template_optimization.template_matching.MatchingDAGNode ¶
Bases: DAGNode
DAG node class tailored for template matching algorithm.
Source code in QuICT/qcda/optimization/template_optimization/template_matching/matching_dag_circuit.py
compare_with ¶
Compare self to the node other under mapping qubit_mapping.
qubit i of self is mapped to qubit qubit_mapping[i] of other.
If qubit_mapping is None, only compare gate type.
The order of control qubits is ignored.
Parameters:
-
other(MatchingDAGNode) –the other node
-
qubit_mapping(list, default:None) –mapping
Returns:
-
bool(bool) –same or not
Source code in QuICT/qcda/optimization/template_optimization/template_matching/matching_dag_circuit.py
matchable ¶
Returns:
-
bool(bool) –Whether the node can be matched
node_info ¶
Return
tuple: (the matched node, whether is blocked)
pop_successors_to_visit ¶
Pop the first element of successors_to_visit. If no more, return None.
Returns:
-
int(int) –first element of successors_to_visit