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

Variable ordering for exact inference. #153

Merged
merged 5 commits into from
Mar 9, 2025
Merged

Conversation

samuelsonric
Copy link
Contributor

I noticed the following comment in the exact inference implementation.

# order impacts performance, but we currently have no ordering heuristics

This patch adds an ordering heuristic. The effect on performance can be dramatic: for example, if we load this network.

julia> using BayesNets, BenchmarkTools

julia> bn = readxdsl("riverland.xdsl"); 

without ordering

julia> @benchmark infer(
           bn,
           [:Economic_Impact, :Electricity_Use],
           evidence=Assignment(:Clay_Content=>1, :Agrochemical_Type=>2))
BenchmarkTools.Trial: 41 samples with 1 evaluation per sample.
 Range (min … max):  118.883 ms … 129.514 ms  ┊ GC (min … max): 0.00% … 4.63%
 Time  (median):     122.314 ms               ┊ GC (median):    2.85%
 Time  (mean ± σ):   123.157 ms ±   2.325 ms  ┊ GC (mean ± σ):  2.64% ± 1.07%

                  █ ▆                                            
  ▄▁▁▁▁▁▁▄▄▁▁▁▁▄▁▇█▇█▇▇▄▄▇▄▇▄▄▁▁▁▁▁▁▄▄▁▁▁▁▄▄▁▁▁▁▄▁▄▁▁▄▁▁▁▁▄▁▁▁▄ ▁
  119 ms           Histogram: frequency by time          130 ms <

 Memory estimate: 55.27 MiB, allocs estimate: 13050.

with ordering

julia> @benchmark infer(
           bn,
           [:Economic_Impact, :Electricity_Use],
           evidence=Assignment(:Clay_Content=>1, :Agrochemical_Type=>2))
BenchmarkTools.Trial: 1605 samples with 1 evaluation per sample.
 Range (min … max):  3.040 ms …  13.740 ms  ┊ GC (min … max): 0.00% … 75.38%
 Time  (median):     3.068 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   3.111 ms ± 440.326 μs  ┊ GC (mean ± σ):  0.96% ±  4.51%

   ▆█▅                                                         
  ▄████▆▄▄▃▃▂▂▂▂▂▂▂▁▂▂▁▂▁▁▂▁▂▂▁▂▁▁▁▁▁▂▂▁▁▂▁▂▁▂▂▁▂▁▂▁▁▁▁▁▁▂▁▁▂ ▃
  3.04 ms         Histogram: frequency by time        3.57 ms <

 Memory estimate: 558.35 KiB, allocs estimate: 9740.

@mykelk
Copy link
Member

mykelk commented Mar 9, 2025

Thanks for this great contribution! I think CI.yml needs to be updated to use actions/cache v4 so that we can run the tests.

@samuelsonric
Copy link
Contributor Author

hmmm

@mykelk
Copy link
Member

mykelk commented Mar 9, 2025

I think we want that for cache---not just checkout. It shows up on a different line.

@samuelsonric
Copy link
Contributor Author

oh, I updated the wrong one

@samuelsonric
Copy link
Contributor Author

checkout seems to have a version 4 in any case: https://github.com/actions/checkout

@samuelsonric
Copy link
Contributor Author

CliqueTrees should work with Julia 1.8+. Worth noting that 1.10 is the new LTS!

@mykelk
Copy link
Member

mykelk commented Mar 9, 2025

I think CliqueTrees requires Julia 1.8 and later. I think the Project.toml needs to be updated to reflect this.

@samuelsonric
Copy link
Contributor Author

Ok: tests pass locally on Julia 1.8. I updated the Project and the CI.

@mykelk mykelk merged commit 1166f6f into sisl:master Mar 9, 2025
7 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.

2 participants