Skip to content

Hybrid Improvements#2135

Merged
varunagrawal merged 6 commits intodevelopfrom
hybrid-improvements
May 16, 2025
Merged

Hybrid Improvements#2135
varunagrawal merged 6 commits intodevelopfrom
hybrid-improvements

Conversation

@varunagrawal
Copy link
Copy Markdown
Contributor

@varunagrawal varunagrawal commented May 15, 2025

  1. Add a factor with the Dead Mode Removal marginal threshold when a discrete variable which was removed is added back again. This helps to get back information which improves the performance in later steps by allowing for Dead Mode Removal to operate better.
  2. Update TableFactor to only record probabilities above 1e-11. This helps keep the TableFactor smaller and improve sparsity.
  3. Added DiscreteBayesNet::joint as a new method since it is a common operation.

Here is an illustrative example:
Say we have a HybridBayesNet with the conditionals
$BN = P(X(0) | M(0))P(M(0))$
where X(0) is a continuous variable and M(0) is a discrete variable. Assuming P(M(0)) was 0.1, 0.9, then DMR (with threshold 0.85) would remove this conditional and assign M(0)=1.

In the next update step, we add the factor $\phi(X(1), M(0))$, and the discrete measurement $\phi(M(0))$. Note that we have reintroduced M(0) again and there is new information.
From our previous step, M(0) = 1, but the new factors might make it such that M(0)=0 is the better assignment.
The way I handle that is to reintroduce P(M(0)) = {0.15, 0.85} so we get the graph:
$FG = \phi(X(1), M(0)) \phi(M(0)) P(M(0))$.
This way, when we eliminate the information from the previous and current steps are fused giving us a better estimate of M(0).

@varunagrawal varunagrawal requested a review from dellaert May 15, 2025 19:00
@varunagrawal varunagrawal self-assigned this May 15, 2025
Copy link
Copy Markdown
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

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

The CI fails. That’s probably easy to fix, but a bigger problem is that I don’t really understand what you’re saying about “re-introducing information”. The whole point of dead mode removal is getting rid of information, so I think this needs more explanation. Maybe you can give an example in PR comment that is also implemented in a unit test.

/* ************************************************************************* */
// The implementation is: build the entire joint into one factor and then prune.
// TODO(Frank): This can be quite expensive *unless* the factors have already
// NOTE: This can be quite expensive *unless* the factors have already
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add my name back. For any notes/to dos we should have a name.

for (DiscreteKey dkey : newFactors.discreteKeys()) {
Key key = dkey.first;
if (fixedValues_.find(key) != fixedValues_.end()) {
// Add corresponding discrete factor to reintroduce the information
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don’t understand this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I updated the PR comment. I can add a unit test later if that's okay? I'll put it in as a TODO.

@dellaert
Copy link
Copy Markdown
Member

OK but then I guess you have to keep track of which variables were removed? That can be a pretty long list. And where do you keep this list? Or maybe I’m still not understanding.

@varunagrawal
Copy link
Copy Markdown
Contributor Author

We keep track of those variables in a DiscreteValues object called fixedValues_. This is why this PR was pretty straightforward once I figured out the issue. :)

Copy link
Copy Markdown
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

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

Ok

@varunagrawal varunagrawal merged commit bbd0ef5 into develop May 16, 2025
51 of 52 checks passed
@varunagrawal varunagrawal deleted the hybrid-improvements branch May 16, 2025 02:54
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.

2 participants