Skip to content

Conversation

@Morningliumengkun
Copy link
Collaborator

Summary

  • add independent tropical_in_new package with src, tests, docs, and example
  • include UAI parsing helpers and tropical MPE contraction pipeline
  • provide example asia_network model and runnable script

Test plan

  • pytest tropical_in_new/tests

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a standalone tropical tensor network package for computing Most Probable Explanation (MPE) in probabilistic graphical models. The package includes UAI format parsing, tropical (max-plus) semiring operations, variable elimination ordering heuristics, and a complete MPE inference pipeline.

Changes:

  • Added independent tropical_in_new package with complete source implementation, test suite, documentation, and examples
  • Implemented UAI model parsing utilities and tropical tensor contraction primitives
  • Provided runnable Asia network example with model file and execution script

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
tropical_in_new/src/init.py Public API exports for the tropical tensor network package
tropical_in_new/src/primitives.py Core tropical semiring operations including safe_log, tropical_einsum, and argmax tracing
tropical_in_new/src/network.py Tensor network construction from factor graphs
tropical_in_new/src/contraction.py Variable elimination ordering heuristics and contraction tree execution
tropical_in_new/src/mpe.py High-level MPE API and assignment recovery from backpointers
tropical_in_new/src/utils.py UAI format parsing for models and evidence files
tropical_in_new/tests/conftest.py Test configuration with sys.path setup
tropical_in_new/tests/test_primitives.py Unit tests for tropical primitives
tropical_in_new/tests/test_contraction.py Unit tests for contraction ordering and execution
tropical_in_new/tests/test_mpe.py Integration tests comparing MPE results against brute force
tropical_in_new/examples/asia_network/main.py Example script demonstrating MPE computation
tropical_in_new/examples/asia_network/model.uai Example UAI model file
tropical_in_new/docs/usage_guide.md User guide with quick start examples
tropical_in_new/docs/mathematical_description.md Mathematical description of tropical tensor network approach
tropical_in_new/docs/api_reference.md API reference documentation
tropical_in_new/README.md Package overview and structure
tropical_in_new/requirements.txt Package dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Update docs/imports and improve validation coverage.
Copy link
Member

@GiggleLiu GiggleLiu left a comment

Choose a reason for hiding this comment

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

I wish the folder name tropical_in_new can be replaced with a better one in this pr, it is hard to change in later revision. You can also leave it to a later refactor (leave an issue if you want to make this change later).

The rest looks good. Well done!

Copy link
Member

@GiggleLiu GiggleLiu left a comment

Choose a reason for hiding this comment

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

For all the remaining comments, please address or make an issue.

@GiggleLiu
Copy link
Member

I will these pr comments.

- Use einsum with elimination directly in contract_tree instead of
  separate ReduceNode for multi-node buckets
- Generalize _brute_force_mpe with itertools.product for any number
  of variables
- Add assert statements in utils.py for internal consistency checks
- Add comprehensive tests for error paths, edge cases, and
  read_evidence_file/read_model_file (coverage now 98%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@GiggleLiu GiggleLiu merged commit b4bed2e into main Jan 24, 2026
3 checks passed
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