§
    º³Ùg{  ã                  óN   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dd„ZdS )zÂPass manager for optimization level 2, providing medium optimization.

Level 2 pass manager: medium optimization by noise adaptive qubit mapping and
gate cancellation using commutativity rules.
é    )Úannotations)ÚPassManagerConfig)ÚStagedPassManager)Úcommon)ÚPassManagerStagePluginManagerÚpass_manager_configr   Úreturnr   c           
     ó  — t          ¦   «         }| j        }| j        }| j        }| j        pd}| j        pd}| j        pd}| j        pd}| j        pd}	| j	        pd}
| j
        }|                     d|| d¬¦  «        }|s|r|                     d|| d¬¦  «        }|}nd}d}|                     d	|| d¬¦  «        }|r|j        r|�.|                     d
¬¦  «        rt          j        ||d¬¦  «        }nt          j        d¬¦  «        }|                     d|	| d¬¦  «        }|                     d|
| d¬¦  «        }t          j        ||||	|
||¬¦  «        }|                     d|| d¬¦  «        }t#          ||||||||¬¦  «        S )a�  Level 2 pass manager: medium optimization by initial layout selection and
    gate cancellation using commutativity rules.

    This pass manager applies the user-given initial layout. If none is given, a search
    for a perfect layout (i.e. one that satisfies all 2-qubit interactions) is conducted.
    If no such layout is found, qubits are laid out on the most densely connected subset
    which also exhibits the best gate fidelities.

    The pass manager then transforms the circuit to match the coupling constraints.
    It is then unrolled to the basis, and any flipped cx directions are fixed.
    Finally, optimizations in the form of commutative gate cancellation and redundant
    reset removal are performed.

    Args:
        pass_manager_config: configuration of the pass manager.

    Returns:
        a level 2 pass manager.

    Raises:
        TranspilerError: if the passmanager config is invalid.
    ÚdefaultÚsabreÚ
translatorÚroutingé   )Úoptimization_levelÚlayoutNÚtranslationT)Ústrict_directionF)Úremove_reset_in_zeroÚoptimizationÚ
scheduling)Úlayout_methodÚrouting_methodÚtranslation_methodÚoptimization_methodÚscheduling_methodÚbasis_gatesÚtargetÚinit)Úpre_initr   r   r   r   Úpre_optimizationr   r   )r   r   Úcoupling_mapÚinitial_layoutÚinit_methodr   r   r   r   r   r   Úget_passmanager_stageÚis_symmetricÚget_non_global_operation_namesr   Úgenerate_pre_op_passmanagerÚ#generate_control_flow_options_checkr   )r   Úplugin_managerr   r!   r"   r#   r   r   r   r   r   r   Ú
routing_pmr   r   r   r    r   Úschedr   r   s                        úb/granary/edev/quantum/lib/python3.11/site-packages/qiskit/transpiler/preset_passmanagers/level2.pyÚlevel_2_pass_managerr-      sS  € õ. 3Ñ4Ô4€NØ%Ô1€KØ&Ô3€LØ(Ô7€NØ%Ô1Ð>°Y€KØ'Ô5ÐB¸€MØ(Ô7ÐB¸7€NØ,Ô?ÐOÀ<ÐØ-ÔAÐNÀYÐØ+Ô=ÐJÀÐØ Ô'€Fð  ×5Ò5Ø�>Ð#6È1ð 6ñ ô €Jð
 ð �~ð Ø×5Ò5Ø�mÐ%8ÈQð 6ñ 
ô 
ˆð ˆˆàˆØˆØ ×6Ò6ØÐ)Ð+>ÐSTð 7ñ ô €Kð 	ð Z˜\Ô6ð ZØÐ˜v×DÒDÐVZÐDÑ[Ô[Ðå!Ô=Ø�L°uð
ñ 
ô 
ÐÐõ "Ô=ÐSXÐYÑYÔYÐà!×7Ò7ØÐ+Ð-@ÐUVð 8ñ ô €Lð ×0Ò0ØÐ'Ð)<ÐQRð 1ñ ô €Eõ Ô9Ø#Ø%Ø-Ø/Ø+ØØðñ ô €Hð ×/Ò/Ø�Ð0ÀQð 0ñ ô €Dõ ØØØØØØ)Ø!Øð	ñ 	ô 	ð 	ó    N)r   r   r	   r   )Ú__doc__Ú
__future__r   Ú$qiskit.transpiler.passmanager_configr   Úqiskit.transpiler.passmanagerr   Ú%qiskit.transpiler.preset_passmanagersr   Ú,qiskit.transpiler.preset_passmanagers.pluginr   r-   © r.   r,   ú<module>r6      s›   ððð ð
 #Ð "Ð "Ð "Ð "Ð "Ø BÐ BÐ BÐ BÐ BÐ BØ ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8ðð ð ð ð ð ð
\ð \ð \ð \ð \ð \r.   