Skip to content
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

Add BinaryDecisionDiagrams.jl to Juice #90

Merged
merged 2 commits into from
Aug 24, 2021

Conversation

RenatoGeh
Copy link
Contributor

Hi,

Sending this PR in preparation for Tractables/ProbabilisticCircuits.jl#79.

Please let me know if the code's notation/naming doesn't follow Juice's.

Thanks

@codecov
Copy link

codecov bot commented Aug 10, 2021

Codecov Report

Merging #90 (20979b5) into master (48359a7) will decrease coverage by 0.21%.
The diff coverage is 92.79%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #90      +/-   ##
==========================================
- Coverage   88.30%   88.08%   -0.22%     
==========================================
  Files          30       31       +1     
  Lines        2590     3197     +607     
==========================================
+ Hits         2287     2816     +529     
- Misses        303      381      +78     
Impacted Files Coverage Δ
src/LogicCircuits.jl 100.00% <ø> (ø)
src/Utils/misc.jl 85.96% <ø> (+0.96%) ⬆️
src/sdd/sdds.jl 97.87% <83.33%> (-2.13%) ⬇️
src/bdd/bdds.jl 92.89% <92.89%> (ø)
src/Utils/cubitvector.jl 33.33% <0.00%> (-16.67%) ⬇️
src/queries/satisfies.jl 62.24% <0.00%> (-14.29%) ⬇️
src/queries/satisfies_flow.jl 47.18% <0.00%> (-4.77%) ⬇️
src/Utils/data.jl 81.76% <0.00%> (-3.32%) ⬇️
src/bit_circuit.jl 81.30% <0.00%> (-1.87%) ⬇️

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 48359a7...20979b5. Read the comment docs.

function Diagram(v::Bool)::Diagram
α = new()
α.index, α.value = -1, v
lock(_bdd_mutex)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is locks used because its possible to build the structure in parallel?
Is it needed for other caases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only for concurrency reasons.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good. Mostly wanted to see where the concurrency happens.

src/bdd/bdds.jl Outdated
- `value`: terminal boolean value
- `id`: unique identifier
"""
mutable struct Diagram
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not name it BinaryDecisionDiagram? Is there collision with other things we have.
Unless Diagram can be something else too I guess, so is this limiteed to BDDs only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. Diagram can be kind of confusing. It was originally named that in the BDD.jl package, and frankly I don't know why I chose that name. How about Bdd to parallel with Juice's Sdd?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure Bdd works as well. Can also have a alias of it as BinaryDecisionDiagram so both works.

Copy link
Collaborator

@khosravipasha khosravipasha left a comment

Choose a reason for hiding this comment

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

Overall looks comprenensive and well tested, thanks for the PR. Had a few questions inline, and also:

  1. If I understand correctly here BDD defines structure and everything for itself seperate than LogicCircuits. Can we complile BDDs currently to LogicCircuits? Or will need to integrate that later. Just want to make sure we will add it later on if its not possible yet.

  2. At some point, I want to write some docs and tutorials for both compilation and SDD and BDDs at some point, what are the main user facing function for BDDs supported with this PR, want to keep track of them (other than the obvious load an save).
    reduce!, restrict, shannon, eliminate, marginalize, mentions, print_nf, normal_form. Did I miss any important one? I guess they all have examples on how to use in the tests? If yes that's enough for me later on.

@RenatoGeh
Copy link
Contributor Author

Overall looks comprenensive and well tested, thanks for the PR. Had a few questions inline, and also:

1. If I understand correctly here BDD defines structure and everything for itself seperate than LogicCircuits. Can we complile BDDs currently to LogicCircuits? Or will need to integrate that later. Just want to make sure we will add it later on if its not possible yet.

Yes, it's completely separate from LogicCircuits for now. I can write a compile function to convert it to a LogicCircuit as a placeholder until we can make BDD fully compatible with Juice.

2. At some point, I want to write some docs and tutorials for both compilation and SDD and BDDs at some point, what are the main user facing function for BDDs supported with this PR, want to keep track of them (other than the obvious load an save).
   `reduce!`, `restrict`, `shannon`, `eliminate`, `marginalize`, `mentions`, `print_nf`, `normal_form`. Did I miss any important one? I guess they all have examples on how to use in the tests? If yes that's enough for me later on.

There are some others: atmost, atleast, exactly, forget from the top of my head. We have some examples in the tests. But documentation is definitely lacking. I can add some proper doc on the BDD side. And then we can work together on the tutorials and docs.

@khosravipasha
Copy link
Collaborator

khosravipasha commented Aug 11, 2021

Cool, thanks, we don't have to do those two in this PR. I added issues to track them.

@khosravipasha
Copy link
Collaborator

@RenatoGeh Thanks for the rename, planning to merge this sometime tonight.

@khosravipasha khosravipasha merged commit f8c0f7d into Tractables:master Aug 24, 2021
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