Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Fix offsets computation for messages/potentials; Support AND factor #126

Merged
merged 8 commits into from
Mar 23, 2022

Conversation

StannisZhou
Copy link
Contributor

The messages and potentials offsets for factors/factor groups should not be done by type, since they are only used in updating messages/potentials which works with the whole flat array. This PR fixes it.

Also added support for AND factors by slightly tweaking the existing OR factor implementation.

Resolves #125

Copy link
Contributor

@antoine-dedieu antoine-dedieu left a comment

Choose a reason for hiding this comment

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

LGTM after updating the docstrings

@codecov-commenter
Copy link

codecov-commenter commented Mar 23, 2022

Codecov Report

Merging #126 (7c2a31c) into master (ce3fd91) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #126   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          857       856    -1     
=========================================
- Hits           857       856    -1     
Impacted Files Coverage Δ
pgmax/factors/__init__.py 100.00% <ø> (ø)
pgmax/factors/logical.py 100.00% <100.00%> (ø)
pgmax/fg/graph.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce3fd91...7c2a31c. Read the comment docs.

@StannisZhou StannisZhou merged commit ad52b65 into vicariousinc:master Mar 23, 2022
@StannisZhou StannisZhou deleted the factors branch March 23, 2022 23:46
Copy link
Contributor

@antoine-dedieu antoine-dedieu left a comment

Choose a reason for hiding this comment

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

Minor

]
)
num_parents = len(self.variables) - 1
relevant_state = (-self.edge_states_offset + 1) / 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
relevant_state = (-self.edge_states_offset + 1) / 2
relevant_state = (-self.edge_states_offset + 1) // 2

parents_edge_states[ii, 1] contains the message index of the parent variable's relevant state.
For ORFactors the relevant state is 0, for ANDFactors the relevant state is 1.
Both indices only take into account the LogicalFactors of the FactorGraph
The parent variable's other state is parents_edge_states[ii, 2] + edge_states_offset
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The parent variable's other state is parents_edge_states[ii, 2] + edge_states_offset
The parent variable's other state is parents_edge_states[ii, 1] + edge_states_offset

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

Successfully merging this pull request may close these issues.

Better handle message/log potentials updates with multiple factor types
3 participants