Skip to content

Commit

Permalink
Fixes black
Browse files Browse the repository at this point in the history
  • Loading branch information
matt035343 committed Jun 12, 2024
1 parent 2776bef commit 84be586
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
8 changes: 6 additions & 2 deletions anti_clustering/tabu_search_heuristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ def _solve(self, distance_matrix: npt.NDArray[float], num_groups: int) -> npt.ND
i = self.rnd.randint(0, len(distance_matrix) - 1)

# Get possible swaps
possible_exchanges = [j for j in self._get_exchanges(cluster_assignment, i) if (i,j) not in tabu_swaps and (j,i) not in tabu_swaps]
possible_exchanges = [
j
for j in self._get_exchanges(cluster_assignment, i)
if (i, j) not in tabu_swaps and (j, i) not in tabu_swaps
]

if len(possible_exchanges) == 0:
continue
Expand All @@ -76,7 +80,7 @@ def _solve(self, distance_matrix: npt.NDArray[float], num_groups: int) -> npt.ND
if new_objective > objective:
cluster_assignment = new_cluster_assignment
objective = new_objective
tabu_swaps.append((i,j))
tabu_swaps.append((i, j))
# Delete oldest tabu swap if tabu list is full
if len(tabu_swaps) > self.tabu_tenure:
tabu_swaps.pop(0)
Expand Down
20 changes: 11 additions & 9 deletions examples/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@
# Mean of differences
mean_df = difference_df.reset_index(level=[1]).groupby(["level_1"]).mean()

summary.append(pd.DataFrame(
{
"Method": [method.__class__.__name__],
"Clusters": [k],
"∆M": [round(mean_df.loc['mean'][0], 4)],
"∆SD": [round(mean_df.loc['std'][0], 4)],
"Time (s)": [time_taken],
}
))
summary.append(
pd.DataFrame(
{
"Method": [method.__class__.__name__],
"Clusters": [k],
"∆M": [round(mean_df.loc["mean"][0], 4)],
"∆SD": [round(mean_df.loc["std"][0], 4)],
"Time (s)": [time_taken],
}
)
)
print("Summary (lower ∆M and ∆SD is better):")
print(pd.concat(summary).to_string())

0 comments on commit 84be586

Please sign in to comment.