Skip to content

Commit

Permalink
🎨 pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jan 15, 2024
1 parent c940d49 commit e599ab8
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion include/Architecture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
4 changes: 2 additions & 2 deletions include/heuristic/HeuristicMapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -486,4 +486,4 @@ inline bool operator>(const HeuristicMapper::Node& x,
}

return x < y;
}
}
10 changes: 5 additions & 5 deletions include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Matrix>& 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)
Expand Down
3 changes: 2 additions & 1 deletion src/Architecture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ void Architecture::createFidelityTable() {

fidelityDistanceTables.clear();
if (fidelityAvailable) {
Dijkstra::buildEdgeSkipTable(couplingMap, fidelityDistanceTables, swapFidelityCosts);
Dijkstra::buildEdgeSkipTable(couplingMap, fidelityDistanceTables,
swapFidelityCosts);
}
}

Expand Down
23 changes: 13 additions & 10 deletions src/configuration/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =

Check warning on line 34 in src/configuration/Configuration.cpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

src/configuration/Configuration.cpp:34:13 [clang-diagnostic-unused-variable]

unused variable 'lookaheadHeuristicPropertiesJson'

Check notice

Code scanning / CodeQL

Unused local variable

Variable lookaheadHeuristicPropertiesJson is not used.
lookaheadSettings["heuristic_properties"];
heuristicPropertiesJson["fidelity_aware"] =
isFidelityAware(lookaheadHeuristic);
lookaheadSettings["lookaheads"] = nrLookaheads;
lookaheadSettings["first_factor"] = firstLookaheadFactor;
lookaheadSettings["factor"] = lookaheadFactor;
Expand Down
4 changes: 2 additions & 2 deletions src/heuristic/HeuristicMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ void Dijkstra::dijkstra(const CouplingMap& couplingMap,
}
}

void Dijkstra::buildEdgeSkipTable(const CouplingMap& couplingMap,
void Dijkstra::buildEdgeSkipTable(const CouplingMap& couplingMap,
std::vector<Matrix>& 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
Expand Down

0 comments on commit e599ab8

Please sign in to comment.