|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "Solver.hpp" |
| 4 | +#include "ir/QuantumComputation.hpp" |
| 5 | +#include "na/NAComputation.hpp" |
| 6 | +#include "na/NADefinitions.hpp" |
| 7 | + |
| 8 | +#include <cstdint> |
| 9 | + |
| 10 | +namespace na { |
| 11 | +using namespace qc; |
| 12 | + |
| 13 | +class CodeGenerator { |
| 14 | +private: |
| 15 | + /** |
| 16 | + * @brief Calculate the coordinates of a point in the 2D grid from its |
| 17 | + * discrete coordinates. |
| 18 | + * |
| 19 | + * @details The parameters specify the measures that were used for the |
| 20 | + * abstraction of the 2D grid. In the abstraction the 2D plane is divided into |
| 21 | + * interaction sites. Each site is identified by a discrete coordinate. The |
| 22 | + * exact (discrete) position of an atom in a site is given by the discrete |
| 23 | + * offset from the sites' origin. |
| 24 | + * |
| 25 | + * @param q A qubit that contains the discrete coordinates of the interaction |
| 26 | + * site together with the discrete offset. |
| 27 | + * @param maxHOffset The maximal possible horizontal offset of an atom in a |
| 28 | + * site. This value determines the width of a site in x-direction. |
| 29 | + * @param maxVOffset The maximal possible vertical offset of an atom in a |
| 30 | + * site. This value determines the height of a site in y-direction. |
| 31 | + * @param minEntanglingY The minimal y-coordinate of the entangling zone. All |
| 32 | + * discrete y-coordinates smaller than this value are considered to be in the |
| 33 | + * top storage zone. If this value is 0, there is no top storage zone. |
| 34 | + * @param maxEntanglingY The maximal y-coordinate of the entangling zone. All |
| 35 | + * discrete y-coordinates greater than this value are considered to be in the |
| 36 | + * bottom storage zone. |
| 37 | + * @param minAtomDist The minimal distance between two atoms in the 2D grid, |
| 38 | + * i.e., between the discrete sites in one interaction site. |
| 39 | + * @param noInteractionRadius The radius of atoms in order to avoid |
| 40 | + * interactions. This is used as the minimal distance between two atoms in two |
| 41 | + * different interaction sites. |
| 42 | + * @param zoneDist The distance between the top storage zone and the |
| 43 | + * entangling zone and between the entangling zone and the bottom storage |
| 44 | + * zone. This distance already includes the minimal distance between two atoms |
| 45 | + * and the no interaction radius, i.e., it is the minimal distance between two |
| 46 | + * atoms in different zones. |
| 47 | + * @return The coordinates of the point in the 2D grid. |
| 48 | + */ |
| 49 | + static auto coordFromDiscrete(NASolver::Result::Qubit q, int64_t maxHOffset, |
| 50 | + int64_t maxVOffset, int64_t minEntanglingY, |
| 51 | + int64_t maxEntanglingY, int64_t minAtomDist, |
| 52 | + int64_t noInteractionRadius, int64_t zoneDist) |
| 53 | + -> Point; |
| 54 | + |
| 55 | +public: |
| 56 | + /** |
| 57 | + * @brief Generate a NAComputation from a QuantumComputation and a NASolver |
| 58 | + * result. |
| 59 | + * |
| 60 | + * @details The function generates a NAComputation from a QuantumComputation |
| 61 | + * and a NASolver result. The solver works with an abstraction of the 2D grid. |
| 62 | + * In the abstraction the 2D plane is divided into |
| 63 | + * interaction sites. Each site is identified by a discrete coordinate. The |
| 64 | + * exact (discrete) position of an atom in a site is given by the discrete |
| 65 | + * offset from the sites' origin. This function calculates the exact position |
| 66 | + * of each qubit in the 2D grid from the discrete coordinates and offsets. For |
| 67 | + * the calculation, the measures used for the abstraction are required. |
| 68 | + * |
| 69 | + * @warning This function expects a QuantumComputation that was used as input |
| 70 | + * for the NASolver. Additionally, this function assumes the quantum circuit |
| 71 | + * represented by the QuantumComputation to be of the following form: |
| 72 | + * First, all qubits are initialized in the |+> state by applying a Hadamard |
| 73 | + * gate to each qubit. Then, a set of entangling gates (CZ) is applied to the |
| 74 | + * qubits. Finally, hadamard gates are applied to some qubits. Unfortunately, |
| 75 | + * the function cannot deal with arbitrary quantum circuits as the NASolver |
| 76 | + * cannot do either. |
| 77 | + * |
| 78 | + * @param input The QuantumComputation that was used as input for the |
| 79 | + * NASolver. |
| 80 | + * @param result The result of the NASolver. |
| 81 | + * @param maxHOffset The maximal possible horizontal offset of an atom in a |
| 82 | + * site. This value determines the width of a site in x-direction. |
| 83 | + * @param maxVOffset The maximal possible vertical offset of an atom in a |
| 84 | + * site. This value determines the height of a site in y-direction. |
| 85 | + * @param minEntanglingY The minimal y-coordinate of the entangling zone. All |
| 86 | + * discrete y-coordinates smaller than this value are considered to be in the |
| 87 | + * top storage zone. If this value is 0, there is no top storage zone. |
| 88 | + * @param maxEntanglingY The maximal y-coordinate of the entangling zone. All |
| 89 | + * discrete y-coordinates greater than this value are considered to be in the |
| 90 | + * bottom storage zone. |
| 91 | + * @param minAtomDist The minimal distance between two atoms in the 2D grid, |
| 92 | + * i.e., between the discrete sites in one interaction site. |
| 93 | + * @param noInteractionRadius The radius of atoms in order to avoid |
| 94 | + * interactions. This is used as the minimal distance between two atoms in two |
| 95 | + * different interaction sites. |
| 96 | + * @param zoneDist The distance between the top storage zone and the |
| 97 | + * entangling zone and between the entangling zone and the bottom storage |
| 98 | + * zone. This distance already includes the minimal distance between two atoms |
| 99 | + * and the no interaction radius, i.e., it is the minimal distance between two |
| 100 | + * atoms in different zones. |
| 101 | + * @return The generated NAComputation. |
| 102 | + */ |
| 103 | + [[nodiscard]] static auto |
| 104 | + generate(const QuantumComputation& input, const NASolver::Result& result, |
| 105 | + uint16_t maxHOffset, uint16_t maxVOffset, uint16_t minEntanglingY, |
| 106 | + uint16_t maxEntanglingY, uint16_t minAtomDist = 1, |
| 107 | + uint16_t noInteractionRadius = 10, uint16_t zoneDist = 24) |
| 108 | + -> NAComputation; |
| 109 | +}; |
| 110 | +} // namespace na |
0 commit comments