diff --git a/exact_kmeans/ilp.py b/exact_kmeans/ilp.py index 1f11f21..c6a888c 100755 --- a/exact_kmeans/ilp.py +++ b/exact_kmeans/ilp.py @@ -735,27 +735,29 @@ def enumerate_sizes( add_remaining_points=True, ) - # # TODO: This is still not working properly - # if not self.config.get("fill_cluster_sizes", False) and isinstance( - # found_bound, float - # ): - # n_fixed_points += search_end - # k_fixed += 1 - # dp_bound = ( - # found_bound - # + self.dp_bounds[self.n - n_fixed_points][self.k - k_fixed] - # ) - # logger.info( - # f"Bound for {test_sizes} ({found_bound}) with DP bound ({dp_bound})" - # ) - # if dp_bound > tightest_upper_bound.value: - # logger.info( - # f"Bound for {test_sizes} ({found_bound}) " - # f"with DP bound ({dp_bound}) " - # "is greater than the current upper bound " - # f"{tightest_upper_bound.value}, skipping..." - # ) - # found_bound = "ilp_sum_bound_greater" + if not self.config.get("fill_cluster_sizes", False) and isinstance( + found_bound, float + ): + n_fixed_points += search_end + k_fixed += 1 + dp_bound = ( + found_bound + + self.dp_bounds[self.n - n_fixed_points][self.k - k_fixed] + ) + logger.info( + f"Bound for {test_sizes} ({found_bound}) with DP bound ({dp_bound})" + ) + if ( + np.isfinite(dp_bound).all() + and dp_bound > tightest_upper_bound.value + ): + logger.info( + f"Bound for {test_sizes} ({found_bound}) " + f"with DP bound ({dp_bound}) " + "is greater than the current upper bound " + f"{tightest_upper_bound.value}, skipping..." + ) + found_bound = "ilp_sum_bound_greater" if found_bound not in {"infeasible", "ilp_sum_bound_greater"}: found_bound = "branch" # If the program is feasible and we have less than k clusters