LocalOptimizer
Extends:
is a compiler engine which optimizes locally (merging rotations, cancelling gates with their inverse) in a local window of user- defined size.
It stores all commands in a dict of lists, where each qubit has its own gate pipeline. After adding a gate, it tries to merge / cancel successive gates using the get_merged and getInverse functions of the gate (if available). For examples, see BasicRotationGate. Once a list corresponding to a qubit contains >=m gates, the pipeline is sent on to the next engine.
Constructor Summary
Public Constructor | ||
public |
constructor(m: number) |
Method Summary
Public Methods | ||
public |
Cache a command, i.e., inserts it into the command lists of all qubits involved. |
|
public |
Check whether a qubit pipeline must be sent on and, if so, optimize the pipeline and then send it on. |
|
public |
getGateIndices(idx: number, i: number, IDs: number[]): number[] Return all indices of a command, each index corresponding to the command's index in one of the qubits' command lists. |
|
public |
Try to merge or even cancel successive gates using the get_merged and getInverse functions of the gate (see, e.g., BasicRotationGate). |
|
public |
receive(commandList: *) Receive commands from the previous engine and cache them. |
|
public |
sendQubitPipeline(idx: number, n: number) Send n gate operations of the qubit with index idx to the next engine. |
Inherited Summary
From class BasicEngine | ||
public |
|
|
public |
allocateQubit(dirty: boolean): Qureg Return a new qubit as a list containing 1 qubit object (quantum register of size 1). |
|
public |
allocateQureg(n: number): Qureg Allocate n qubits and return them as a quantum register, which is a list of qubit objects. |
|
public |
deallocateQubit(qubit: BasicQubit) Deallocate a qubit (and sends the deallocation command down the pipeline). |
|
public |
isAvailable(cmd: Command): boolean Default implementation of isAvailable: Ask the next engine whether a command is available, i.e., whether it can be executed by the next engine(s). |
|
public |
isMetaTagSupported(metaTag: function): boolean Check if there is a compiler engine handling the meta tag |
|
public |
receive() |
|
public |
Forward the list of commands to the next engine in the pipeline. |
Public Constructors
public constructor(m: number) source
Override:
BasicEngine#constructorParams:
Name | Type | Attribute | Description |
m | number | Number of gates to cache per qubit, before sending on the first gate. |
Public Methods
public cacheCMD(cmd: Command) source
Cache a command, i.e., inserts it into the command lists of all qubits involved.
Params:
Name | Type | Attribute | Description |
cmd | Command |
public checkAndSend() source
Check whether a qubit pipeline must be sent on and, if so, optimize the pipeline and then send it on.
public getGateIndices(idx: number, i: number, IDs: number[]): number[] source
Return all indices of a command, each index corresponding to the command's index in one of the qubits' command lists.
public optimize(idx: number, lim: number): * source
Try to merge or even cancel successive gates using the get_merged and getInverse functions of the gate (see, e.g., BasicRotationGate).
It does so for all qubit command lists.
Return:
* |
public receive(commandList: *) source
Receive commands from the previous engine and cache them. If a flush gate arrives, the entire buffer is sent on.
Override:
BasicEngine#receiveParams:
Name | Type | Attribute | Description |
commandList | * |