Skip to content

[WIP] The counting version of branching #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GiggleLiu
Copy link
Collaborator

@GiggleLiu GiggleLiu commented Mar 29, 2025

This PR is not finished yet. It is about solving the set covering problem with coefficients:

Given subsets $\{s_1, s_2, \ldots, s_m\}$ and the set of all elements $S = \bigcup_i s_i$, find a sequence of real numbers $\{c_1, c_2, \ldots, c_m\}$, such that

$$\sum_i c_i s_i = S \quad\quad \text{\# each element is covered by exactly once.}$$

where the multiplication and addition operations are performed by treating the sets as bitstrings.

@ArrogantGao @YijiawWang It would be great if one of you could include this feature to the counting version of branching.

Copy link

codecov bot commented Mar 29, 2025

Codecov Report

Attention: Patch coverage is 96.96970% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/OptimalBranchingCore/src/setcovering.jl 96.87% 1 Missing ⚠️
Files with missing lines Coverage Δ
lib/OptimalBranchingCore/src/bitbasis.jl 100.00% <100.00%> (ø)
lib/OptimalBranchingCore/src/setcovering.jl 92.00% <96.87%> (-3.81%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ArrogantGao
Copy link
Collaborator

ArrogantGao commented Mar 29, 2025

So the problem can be represented as follows?
Given a set $S = \{v_1, v_2, ..., v_n\}$ and a set of is sub sets: $\{s_1, s_2, ..., s_m\}$, target is to find Bool variables $[x_1, x_2, ..., x_m]$ and real variables $[c_1, c_2, ..., c_m]$.
The function to minimize:

$$\sum_{i = 1}^m \gamma^{-d_i} x_i$$

Constraints:

  1. For all $i \in [1, n]$, $V_i = \{j | v_i \in s_j \}$, $\sum_{j \in V_i} c_j = 1$.
  2. $x_i = 0$ iff $c_i =0$

The second constraint seems to be quite hard if we allow $c_i$ to be negative.

@YijiawWang
Copy link
Collaborator

YijiawWang commented Mar 29, 2025

I did some small-scale experiments on RRGs and grid graphs and found that under the current loss function and constraints with $$cmax=10$$, the solutions all return to integer exact cover results with c_i = 0 / 1. Perhaps I should try different forms of constraints?
Additionally, since the values from the solutions of IP solver for $$\sum_{\text{i covers j}}{c_i}$$ often deviate slightly from being exactly 1 (more like 1−1e-10, it might need to address the precision issues.

weights = collect(1:7.0)
num_items = 5
result_ip = OptimalBranchingCore.weighted_minimum_signed_exact_cover(IPSolver(max_itr = 10, verbose = false), weights, subsets, num_items, 10.0)
@test result_ip ≈ [1.0, -1.0, 1.0, 0.0, 0.0, 0.0, 0.0]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YijiawWang in many cases, we only have 0-1 outcome, but in some cases, we can have -1 weights. Here is an example.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we only pursuit approximate cover, then we may have more non-Boolean coefficients. In this case, the requirement is not cover some entries exactly once. Instead, we need to reduce the norm
2 distance.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YijiawWang in many cases, we only have 0-1 outcome, but in some cases, we can have -1 weights. Here is an example.

Soga! But in the set covering problem corresponding to the candidate clauses, the sizes of the sub-sets (the number of tbl entries covered by each candidate) and their weights (the truncated sc after removing the candidate) are generally proportional. So maybe it's not common to encounter situations like sub_set_2 in the example, where a smaller sub-set has a larger weight, making it more advantageous for c_2 to take a negative value?

Copy link
Collaborator

@YijiawWang YijiawWang Mar 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we only pursuit approximate cover, then we may have more non-Boolean coefficients. In this case, the requirement is not cover some entries exactly once. Instead, we need to reduce the norm 2 distance.

Soga! I see! Maybe using dynamic ob to give approximate solutions might better match the sparse structures compared to methods like MPS? However, in approximate cover, I'm worried that, similar to when we worked on QEC before, if we only consider local distance loss, we might discard branches that could play a significant role in the future, resulting in large errors? I wonder if we could try using a method like BP to first introduce an approximate environmental context for the approximate cover?

(This is a BP algorithm on counting ISs that ensures convergence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants