From e599ab871726f404b20d149731593989b605e793 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 06:54:54 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/Architecture.hpp | 2 +- include/heuristic/HeuristicMapper.hpp | 4 ++-- include/utils.hpp | 10 +++++----- src/Architecture.cpp | 3 ++- src/configuration/Configuration.cpp | 23 +++++++++++++---------- src/heuristic/HeuristicMapper.cpp | 4 ++-- src/utils.cpp | 4 ++-- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/include/Architecture.hpp b/include/Architecture.hpp index c40e3832c..b6a9c3777 100644 --- a/include/Architecture.hpp +++ b/include/Architecture.hpp @@ -399,7 +399,7 @@ class Architecture { /** true if the coupling map contains no unidirectional edges */ [[nodiscard]] bool bidirectional() const { return isBidirectional; } - + /** true if the coupling map contains no bidirectional edges */ [[nodiscard]] bool unidirectional() const { return isUnidirectional; } diff --git a/include/heuristic/HeuristicMapper.hpp b/include/heuristic/HeuristicMapper.hpp index f6cc1df48..ab071670d 100644 --- a/include/heuristic/HeuristicMapper.hpp +++ b/include/heuristic/HeuristicMapper.hpp @@ -144,7 +144,7 @@ class HeuristicMapper : public Mapper { bool principallyAdmissibleHeur = true; bool tightHeur = true; bool fidelityAwareHeur = false; - + /** * @brief check the `results.config` for any invalid settings */ @@ -486,4 +486,4 @@ inline bool operator>(const HeuristicMapper::Node& x, } return x < y; -} \ No newline at end of file +} diff --git a/include/utils.hpp b/include/utils.hpp index 1237fd10b..0ae25a851 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -89,18 +89,18 @@ class Dijkstra { * if k > distanceTables.size() a cost of 0 can be assumed * * @param couplingMap coupling map specifying all edges in the architecture - * @param distanceTables vector to fill with target tables (from 0 skips in - * the first entry to k skips in the last entry, where k is the last index - * not containing a matrix of pure 0s i.e. k+1 = diameter of the coupling + * @param distanceTables vector to fill with target tables (from 0 skips in + * the first entry to k skips in the last entry, where k is the last index + * not containing a matrix of pure 0s i.e. k+1 = diameter of the coupling * graph) * @param edgeWeights matrix containing costs for swapping any two, connected * qubits (this might be uniform for all edges or different for each edge, as * e.g. in the case of fidelity-aware distances or distances on * mixed bi/unidirectional architectures) */ - static void buildEdgeSkipTable(const CouplingMap& couplingMap, + static void buildEdgeSkipTable(const CouplingMap& couplingMap, std::vector& distanceTables, - const Matrix& edgeWeights); + const Matrix& edgeWeights); /** * @brief builds a distance table containing the minimal costs for moving * logical qubits from one physical qubit to another (along the cheapest path) diff --git a/src/Architecture.cpp b/src/Architecture.cpp index 67d5d8fc1..e613d1c93 100644 --- a/src/Architecture.cpp +++ b/src/Architecture.cpp @@ -276,7 +276,8 @@ void Architecture::createFidelityTable() { fidelityDistanceTables.clear(); if (fidelityAvailable) { - Dijkstra::buildEdgeSkipTable(couplingMap, fidelityDistanceTables, swapFidelityCosts); + Dijkstra::buildEdgeSkipTable(couplingMap, fidelityDistanceTables, + swapFidelityCosts); } } diff --git a/src/configuration/Configuration.cpp b/src/configuration/Configuration.cpp index a51d6a359..b1eb3f2a7 100644 --- a/src/configuration/Configuration.cpp +++ b/src/configuration/Configuration.cpp @@ -19,19 +19,22 @@ nlohmann::json Configuration::json() const { config["debug"] = debug; if (method == Method::Heuristic) { - auto& heuristicJson = config["settings"]; - heuristicJson["heuristic"] = ::toString(heuristic); - auto& heuristicPropertiesJson = heuristicJson["heuristic_properties"]; + auto& heuristicJson = config["settings"]; + heuristicJson["heuristic"] = ::toString(heuristic); + auto& heuristicPropertiesJson = heuristicJson["heuristic_properties"]; heuristicPropertiesJson["admissible"] = isAdmissible(heuristic); - heuristicPropertiesJson["principally_admissible"] = isPrincipallyAdmissible(heuristic); - heuristicPropertiesJson["tight"] = isTight(heuristic); + heuristicPropertiesJson["principally_admissible"] = + isPrincipallyAdmissible(heuristic); + heuristicPropertiesJson["tight"] = isTight(heuristic); heuristicPropertiesJson["fidelity_aware"] = isFidelityAware(heuristic); - heuristicJson["initial_layout"] = ::toString(initialLayout); + heuristicJson["initial_layout"] = ::toString(initialLayout); if (lookaheadHeuristic != LookaheadHeuristic::None) { - auto& lookaheadSettings = heuristicJson["lookahead"]; - lookaheadSettings["heuristic"] = ::toString(lookaheadHeuristic); - auto& lookaheadHeuristicPropertiesJson = lookaheadSettings["heuristic_properties"]; - heuristicPropertiesJson["fidelity_aware"] = isFidelityAware(lookaheadHeuristic); + auto& lookaheadSettings = heuristicJson["lookahead"]; + lookaheadSettings["heuristic"] = ::toString(lookaheadHeuristic); + auto& lookaheadHeuristicPropertiesJson = + lookaheadSettings["heuristic_properties"]; + heuristicPropertiesJson["fidelity_aware"] = + isFidelityAware(lookaheadHeuristic); lookaheadSettings["lookaheads"] = nrLookaheads; lookaheadSettings["first_factor"] = firstLookaheadFactor; lookaheadSettings["factor"] = lookaheadFactor; diff --git a/src/heuristic/HeuristicMapper.cpp b/src/heuristic/HeuristicMapper.cpp index 2feb9c220..afc829b28 100644 --- a/src/heuristic/HeuristicMapper.cpp +++ b/src/heuristic/HeuristicMapper.cpp @@ -865,7 +865,7 @@ void HeuristicMapper::recalculateFixedCostNonFidelity(Node& node) { // swap costs for (auto& swap : node.swaps) { if (swap.op == qc::SWAP) { - // branch clone intended for performance reasons (checking edge-wise for + // branch clone intended for performance reasons (checking edge-wise for // bidirectionality is not O(1)) // NOLINTBEGIN(bugprone-branch-clone) if (architecture->bidirectional()) { @@ -1023,7 +1023,7 @@ void HeuristicMapper::applySWAP(const Edge& swap, std::size_t layer, node.costFixed += architecture->getSwapFidelityCost(swap.first, swap.second); } else { - // branch clone intended for performance reasons (checking edge-wise for + // branch clone intended for performance reasons (checking edge-wise for // bidirectionality is not O(1)) // NOLINTBEGIN(bugprone-branch-clone) if (architecture->bidirectional()) { diff --git a/src/utils.cpp b/src/utils.cpp index 24f5ff05d..55e664031 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -72,9 +72,9 @@ void Dijkstra::dijkstra(const CouplingMap& couplingMap, } } -void Dijkstra::buildEdgeSkipTable(const CouplingMap& couplingMap, +void Dijkstra::buildEdgeSkipTable(const CouplingMap& couplingMap, std::vector& distanceTables, - const Matrix& edgeWeights) { + const Matrix& edgeWeights) { /* to find the cheapest distance between 2 qubits skipping any 1 edge, we iterate over all edges, for each assume the current edge to be the one skipped and are thereby able to retrieve the distance by just adding the distances