Skip to content

Commit 7970096

Browse files
committed
Add commented part after checking if dp_bounds are infinite
1 parent 7ed6e82 commit 7970096

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

exact_kmeans/ilp.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -735,27 +735,29 @@ def enumerate_sizes(
735735
add_remaining_points=True,
736736
)
737737

738-
# # TODO: This is still not working properly
739-
# if not self.config.get("fill_cluster_sizes", False) and isinstance(
740-
# found_bound, float
741-
# ):
742-
# n_fixed_points += search_end
743-
# k_fixed += 1
744-
# dp_bound = (
745-
# found_bound
746-
# + self.dp_bounds[self.n - n_fixed_points][self.k - k_fixed]
747-
# )
748-
# logger.info(
749-
# f"Bound for {test_sizes} ({found_bound}) with DP bound ({dp_bound})"
750-
# )
751-
# if dp_bound > tightest_upper_bound.value:
752-
# logger.info(
753-
# f"Bound for {test_sizes} ({found_bound}) "
754-
# f"with DP bound ({dp_bound}) "
755-
# "is greater than the current upper bound "
756-
# f"{tightest_upper_bound.value}, skipping..."
757-
# )
758-
# found_bound = "ilp_sum_bound_greater"
738+
if not self.config.get("fill_cluster_sizes", False) and isinstance(
739+
found_bound, float
740+
):
741+
n_fixed_points += search_end
742+
k_fixed += 1
743+
dp_bound = (
744+
found_bound
745+
+ self.dp_bounds[self.n - n_fixed_points][self.k - k_fixed]
746+
)
747+
logger.info(
748+
f"Bound for {test_sizes} ({found_bound}) with DP bound ({dp_bound})"
749+
)
750+
if (
751+
np.isfinite(dp_bound).all()
752+
and dp_bound > tightest_upper_bound.value
753+
):
754+
logger.info(
755+
f"Bound for {test_sizes} ({found_bound}) "
756+
f"with DP bound ({dp_bound}) "
757+
"is greater than the current upper bound "
758+
f"{tightest_upper_bound.value}, skipping..."
759+
)
760+
found_bound = "ilp_sum_bound_greater"
759761
if found_bound not in {"infeasible", "ilp_sum_bound_greater"}:
760762
found_bound = "branch"
761763
# If the program is feasible and we have less than k clusters

0 commit comments

Comments
 (0)