Skip to content

Commit c4ebdf7

Browse files
authored
🐛 Fix Coupling Limit Computation (#216)
## Description For whatever reason, the computation of the coupling limit of an architecture is broken since its introduction. It remains unclear, why this was not detected earlier, but definitely shows the lack of tests for that feature. ## Checklist: <!--- This checklist serves as a reminder of a couple of things that ensure your pull request will be merged swiftly. --> - [x] The pull request only contains commits that are related to it. - [x] I have added appropriate tests and documentation. - [x] I have made sure that all CI jobs on GitHub pass. - [x] The pull request introduces no new warnings and follows the project's style guidelines.
2 parents 66ffa8a + 6344b43 commit c4ebdf7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Architecture.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,9 @@ void Architecture::findCouplingLimit(
552552
}
553553
visited[node] = true;
554554

555-
if (d.at(node) < curSum) {
556-
d[node] = curSum;
555+
auto& elem = d[node];
556+
if (elem == 0 || elem > curSum) {
557+
elem = curSum;
557558
}
558559
if (connections.at(node).empty()) {
559560
visited[node] = false;

test/test_architecture.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,11 @@ TEST(TestArchitecture, MinimumNumberOfSwapsError) {
152152
EXPECT_THROW(architecture.minimumNumberOfSwaps(permutation, swaps),
153153
std::runtime_error);
154154
}
155+
156+
TEST(TestArchitecture, TestCouplingLimitRing) {
157+
Architecture architecture{};
158+
const CouplingMap cm = {{0, 1}, {1, 0}, {1, 2}, {2, 1}, {2, 3},
159+
{3, 2}, {3, 4}, {4, 3}, {4, 0}, {0, 4}};
160+
architecture.loadCouplingMap(5, cm);
161+
EXPECT_EQ(architecture.getCouplingLimit(), 2);
162+
}

0 commit comments

Comments
 (0)