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

Changes for GraphPPL v4 #390

Merged
merged 124 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
fd200b9
Implement variable properties
bvdmitri Feb 26, 2024
2cc9fa6
major refactoring, preprocessing of properties
bvdmitri Feb 26, 2024
fe99796
Activation of variables
bvdmitri Feb 26, 2024
5dd318f
commite intermediate work
bvdmitri Feb 26, 2024
d66fb61
Fix model creation
bvdmitri Feb 26, 2024
c84323f
First simple model runs
bvdmitri Feb 26, 2024
991980e
Better performance
bvdmitri Feb 26, 2024
d6e0deb
Performance improvements
bvdmitri Feb 27, 2024
7eb45c6
refactoring
bvdmitri Feb 27, 2024
db3e379
Simplify code
bvdmitri Feb 27, 2024
0a454a0
2prev
bvdmitri Feb 27, 2024
69a8e14
futher improvements
bvdmitri Feb 27, 2024
7b8c6f5
restore the pipeline option
bvdmitri Feb 27, 2024
1162249
Remove unused code
bvdmitri Feb 27, 2024
3a7851f
Write tests
bvdmitri Feb 27, 2024
25c11ae
improve code
bvdmitri Feb 27, 2024
6d910bb
Support iterator based factorization
bvdmitri Feb 28, 2024
c07a4ff
Change the file structure
bvdmitri Feb 29, 2024
c92127d
2prev
bvdmitri Feb 29, 2024
ef5a0d5
Tests and tests structure
bvdmitri Mar 1, 2024
85b127e
more tests
bvdmitri Mar 1, 2024
f7bdeec
Refactor the factor node creation
bvdmitri Mar 1, 2024
0d464a1
Refactor functional dependencies
bvdmitri Mar 1, 2024
7307782
Reimplement node macro
wouterwln Mar 1, 2024
7e6bb76
further refactoring
bvdmitri Mar 1, 2024
3b346d5
Update node macro with old alias system
wouterwln Mar 1, 2024
84802e8
Further refactoring
bvdmitri Mar 4, 2024
30ead2f
Remove old code
bvdmitri Mar 4, 2024
4408de4
to delete
bvdmitri Mar 4, 2024
03ae1a0
Restore the previous API
bvdmitri Mar 4, 2024
ed19026
Merge branch 'dev-gp-4.0.0' into reimplement-node-macro
bvdmitri Mar 4, 2024
7b7998b
after merge
bvdmitri Mar 4, 2024
4841a7d
return to the old Beta interface names
bvdmitri Mar 4, 2024
6361f97
2prev
bvdmitri Mar 4, 2024
9f438e5
Merge pull request #386 from ReactiveBayes/reimplement-node-macro
bvdmitri Mar 4, 2024
b765164
remove old code
bvdmitri Mar 4, 2024
617472c
refactoring
bvdmitri Mar 6, 2024
a5de01a
refactoring
bvdmitri Mar 8, 2024
5cd3a66
BFE refactoring
bvdmitri Mar 8, 2024
e258d1b
fix alias for InvWishart
bvdmitri Mar 11, 2024
49511a4
Refactoring of the sum node
bvdmitri Mar 11, 2024
a239041
update for SSM
bvdmitri Mar 11, 2024
5177d3c
Fix for factorization in deterministic nodes
bvdmitri Mar 11, 2024
be0821d
Refactor ther prod node
bvdmitri Mar 11, 2024
56e8464
More tests
bvdmitri Mar 11, 2024
8036b40
Fix rule error printing
bvdmitri Mar 12, 2024
3dafa50
Remove MeanField and BetheFactorization
bvdmitri Mar 13, 2024
f7d123e
add alias for AR node
bvdmitri Mar 13, 2024
eb1d3ce
sync with GraphPPL backend in RxInfer
bvdmitri Mar 15, 2024
c81c47c
2prev
bvdmitri Mar 15, 2024
0ac3ce3
fix typo
bvdmitri Mar 15, 2024
f5f4187
remove old code
bvdmitri Mar 15, 2024
76b4e89
enable distributions and prior nodes
bvdmitri Mar 15, 2024
bc54774
add some comments
bvdmitri Mar 18, 2024
43395a2
Fix gaussian mixture
bvdmitri Mar 18, 2024
2504e6c
2prev
bvdmitri Mar 18, 2024
51a5f81
Fix mixture node
bvdmitri Mar 18, 2024
df4bb07
2prev
bvdmitri Mar 18, 2024
9b1f268
attempt to fix gamma mixture
bvdmitri Mar 18, 2024
7d13669
fix GammaMixture
bvdmitri Mar 18, 2024
12cb5c7
fix test
bvdmitri Mar 18, 2024
bab59a7
fix kldivergency
bvdmitri Mar 19, 2024
03497c6
dispatch on node functional form trait
bvdmitri Mar 19, 2024
2e2eff7
A path towards fixing the delta node
bvdmitri Mar 19, 2024
07e66e4
2prev
bvdmitri Mar 19, 2024
0dd9ab1
Fix static inputs
bvdmitri Mar 19, 2024
dd54797
fix cvi
bvdmitri Mar 19, 2024
1888238
2prev
bvdmitri Mar 19, 2024
8b5c27c
2prev
bvdmitri Mar 19, 2024
24c9813
fix cvi rule
bvdmitri Mar 19, 2024
5423028
fix CVI rule
bvdmitri Mar 19, 2024
2602839
resolve some todos
bvdmitri Mar 19, 2024
f4d7cda
2prev
bvdmitri Mar 19, 2024
c0716c7
2prev
bvdmitri Mar 19, 2024
f49549a
revert CVI rule
bvdmitri Mar 19, 2024
798e20d
fix differential entropy
bvdmitri Mar 19, 2024
ccce9ee
Fix Probit node
bvdmitri Mar 20, 2024
efd4bde
fix functional dependencies
bvdmitri Mar 20, 2024
3295345
move tests to GraphPPL
bvdmitri Mar 20, 2024
622f893
Fix a portion of tests
bvdmitri Mar 20, 2024
5a4efd9
Fix a portion of tests
bvdmitri Mar 20, 2024
6bf7afd
remove unnecessary tests
bvdmitri Mar 20, 2024
e03faa7
fix update! call
bvdmitri Mar 22, 2024
a4d3ddb
implement linked datavars
bvdmitri Mar 25, 2024
63bfa21
datavars are not clamped
bvdmitri Mar 25, 2024
b9b0674
fix test
bvdmitri Mar 25, 2024
fb40132
Improve performance
bvdmitri Mar 25, 2024
0cc8a21
fix tests
bvdmitri Mar 27, 2024
103f8be
fix tests
bvdmitri Mar 27, 2024
bc78c68
fix tests
bvdmitri Mar 27, 2024
129fe4a
Fix more tests
bvdmitri Mar 27, 2024
4befc69
fix tests
bvdmitri Mar 27, 2024
5e8ce30
fix Aqua tests
bvdmitri Mar 27, 2024
2317057
fix tests
bvdmitri Mar 27, 2024
727fdf3
fix tests
bvdmitri Mar 27, 2024
de043bf
Generate docs for nodes defined in the node macro
bvdmitri Mar 27, 2024
9e426ae
2prev
bvdmitri Mar 27, 2024
4f80486
fix docs
bvdmitri Mar 27, 2024
6a5340f
fix predefined nodes printing
bvdmitri Mar 27, 2024
af18f54
Improve index.md
bvdmitri Mar 27, 2024
fa3cadc
Improve documentation
bvdmitri Mar 27, 2024
96b5440
mark const fields in the deffered message
bvdmitri Mar 27, 2024
388b6f1
change the structure of the Message to be mutable
bvdmitri Mar 27, 2024
4556f3a
Move some docs to the private comments
bvdmitri Mar 27, 2024
3febf5d
add method for update! with missing data
bvdmitri Mar 28, 2024
804cb9b
Add marginal tests
bvdmitri Mar 28, 2024
80752a5
Update the documentation
bvdmitri Mar 28, 2024
ba062c2
Fix documentation
bvdmitri Mar 28, 2024
e07aa38
2prec
bvdmitri Mar 28, 2024
fb3b1a4
add sdtype method for distribution objects
bvdmitri Apr 3, 2024
a06b5d6
Merge pull request #389 from ReactiveBayes/dev-sdtype-for-dist-objects
bvdmitri Apr 4, 2024
fb74dd9
style: make format
bvdmitri Apr 4, 2024
1e74517
minor changes to the docs
bvdmitri Apr 4, 2024
ef53a6d
update: Bump version to 4.0.0
bvdmitri Apr 4, 2024
60e78c7
Merge branch 'main' into dev-4.0.0-examples
bvdmitri Apr 4, 2024
4017a99
style: make format
bvdmitri Apr 4, 2024
3753342
fix BIFM helper
bvdmitri Apr 4, 2024
00c8023
style: make format
bvdmitri Apr 4, 2024
1b64e1c
adjust gcv node
bvdmitri Apr 4, 2024
0f56185
fix for CT node
bvdmitri Apr 4, 2024
e3db99c
Fix for require marginal dependencies
bvdmitri Apr 4, 2024
d66275e
Fix for init macro
bvdmitri Apr 10, 2024
b7e368e
style: make format
bvdmitri Apr 10, 2024
56aed30
Bump Rocket's version
bvdmitri Apr 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ benchmark: benchmark_init ## Runs simple benchmark
.PHONY: docs

doc_init:
julia --project=docs -e 'ENV["PYTHON"]=""; using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate();'
julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate();'

docs: doc_init ## Generate documentation
julia --project=docs/ docs/make.jl
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ReactiveMP"
uuid = "a194aa59-28ba-4574-a09c-4a745416d6e3"
authors = ["Dmitry Bagaev <d.v.bagaev@tue.nl>", "Albert Podusenko <a.podusenko@tue.nl>", "Bart van Erp <b.v.erp@tue.nl>", "Ismail Senoz <i.senoz@tue.nl>"]
version = "3.14.0"
version = "4.0.0"

[deps]
BayesBase = "b4ee3484-f114-42fe-b91c-797d54a0c67e"
Expand Down Expand Up @@ -65,7 +65,7 @@ Optimisers = "0.2"
PositiveFactorizations = "0.2"
Random = "1.9"
Requires = "1"
Rocket = "1.7.0"
Rocket = "1.8.0"
SpecialFunctions = "1.4, 2"
StaticArrays = "1.2"
StatsBase = "0.33, 0.34"
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@

# Reactive message passing engine

ReactiveMP.jl is a Julia package that provides an efficient reactive message passing based Bayesian inference engine on a factor graph. The package is a part of the bigger and user-friendly ecosystem for automatic Bayesian inference called [RxInfer](https://github.com/reactivebayes/RxInfer.jl). While ReactiveMP.jl exports only the inference engine, RxInfer provides convenient tools for model and inference constraints specification as well as routines for running efficient inference both for static and real-time datasets.
ReactiveMP.jl is a Julia package that provides an efficient reactive message passing based Bayesian inference engine on a factor graph. The package is a part of the bigger and user-friendly ecosystem for automatic Bayesian inference called [RxInfer](https://github.com/reactivebayes/RxInfer.jl). While ReactiveMP.jl exports only the inference engine, RxInfer provides convenient tools for model and inference constraints specification as well as routines for running efficient inference both for static and dynamic datasets.

# Examples
## Examples and tutorials

Tutorials and examples are available in the [RxInfer documentation](https://reactivebayes.github.io/RxInfer.jl/stable/).
The ReactiveMP.jl package is intended for advanced users with a deep understanding of message passing principles.
Accesible tutorials and examples are available in the [RxInfer documentation](https://reactivebayes.github.io/RxInfer.jl/stable/).

# License

Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ReactiveMP = "a194aa59-28ba-4574-a09c-4a745416d6e3"
Rocket = "df971d30-c9d6-4b37-b8ff-e965b2cb3a40"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"

[compat]
Documenter = "1.0.0"
41 changes: 26 additions & 15 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,41 @@ DocMeta.setdocmeta!(ReactiveMP, :DocTestSetup, :(using ReactiveMP, Distributions

makedocs(
modules = [ ReactiveMP ],
warnonly = Documenter.except(:doctest, :eval_block, :example_block, :meta_block, :parse_error, :setup_block),
clean = true,
sitename = "ReactiveMP.jl",
pages = [
"Introduction" => "index.md",
"Library" => [
"Factor nodes" => "lib/nodes.md",
"Messages" => "lib/message.md",
"Marginals" => "lib/marginal.md",
"Message update rules" => "lib/rules.md",
"Helper utils" => "lib/helpers.md",
"Algebra utils" => "lib/algebra.md",
"Specific factor nodes" => [
"Delta" => "lib/nodes/delta.md",
"Flow" => "lib/nodes/flow.md",
"BIFM" => "lib/nodes/bifm.md",
"Logical" => "lib/nodes/logical.md",
"Continuous transition" => "lib/nodes/ctransition.md",
"Autoregressive" => "lib/nodes/ar.md",
]
],
"Custom functionality" => [
"Custom functional form" => "custom/custom-functional-form.md",
"Custom addons" => "custom/custom-addons.md"
],
"Library" => [
"Messages" => "lib/message.md",
"Factor nodes" => [
"Overview" => "lib/nodes/nodes.md",
"Flow" => "lib/nodes/flow.md"
],
"Message update rules" => "lib/rules/rules.md",
"Helper utils" => "lib/helpers.md",
"Algebra utils" => "lib/algebra/common.md",
"Exported methods" => "lib/methods.md"
"Custom addons" => "custom/custom-addons.md"
],
"Contributing" => "extra/contributing.md",
"Extra" => [
"Contributing" => "extra/contributing.md",
"Extensions" => "extra/extensions.md",
"Exported methods" => "extra/methods.md"
]

],
format = Documenter.HTML(
prettyurls = get(ENV, "CI", nothing) == "true"
prettyurls = get(ENV, "CI", nothing) == "true",
example_size_threshold = 200 * 1024,
size_threshold_warn = 200 * 1024,
)
)

Expand Down
6 changes: 6 additions & 0 deletions docs/src/custom/custom-addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ here we add the number of operations from the addons that are being multiplied a
### More information

For more advanced information check the implementation of the log-scale or memory addons.

### Built-in addons

```@docs
ReactiveMP.AddonDebug
```
19 changes: 2 additions & 17 deletions docs/src/custom/custom-functional-form.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ q(x) = f\left(\frac{\overrightarrow{\mu}(x)\overleftarrow{\mu}(x)}{\int \overrig

```@docs
AbstractFormConstraint
UnspecifiedFormConstraint
CompositeFormConstraint
```

Expand All @@ -28,6 +29,7 @@ Every custom functional form must implement a new method for the [`default_form_
default_form_check_strategy
FormConstraintCheckEach
FormConstraintCheckLast
FormConstraintCheckPickDefault
```

### Prod constraint
Expand All @@ -46,22 +48,6 @@ The main function that a custom functional form must implement, which we referre
constrain_form
```

### Is point mass form constraint (optional)

Every custom functional form may implement a new method for the [`is_point_mass_form_constraint`](@ref) function that returns either `true` or `false`. This is an utility function that simplifes computation of the Bethe Free Energy and is not strictly necessary.

```@docs
is_point_mass_form_constraint
```

### Compatibility with `@constraints` macro (optional)

To make custom functional form constraint compatible with the `@constraints` macro, it must implement a new method for the [`make_form_constraint`](@ref) function.

```@docs
make_form_constraint
```

## [Custom Functional Form Example](@id custom-functional-form-example)

In this demo we show how to build a custom functional form constraint that is compatible with the `ReactiveMP.jl` inference backend. An important part of the functional forms constraint implementation is the `prod` function in the [`BayesBase`](https://reactivebayes.github.io/BayesBase.jl/stable/) package. We show a relatively simple use-case, which might not be very useful in practice, but serves as a simple step-by-step guide. Assume that we want a specific posterior marginal of some random variable in our model to have a specific Gaussian parametrisation, for example mean-precision. We can use built-in `NormalMeanPrecision` distribution, but we still need to define our custom functional form constraint:
Expand All @@ -76,7 +62,6 @@ struct MeanPrecisionFormConstraint <: AbstractFormConstraint end
Next we define the behaviour of our functional form constraint:

```@example custom-functional-form-example
ReactiveMP.is_point_mass_form_constraint(::MeanPrecisionFormConstraint) = false
ReactiveMP.default_form_check_strategy(::MeanPrecisionFormConstraint) = FormConstraintCheckLast()
ReactiveMP.default_prod_constraint(::MeanPrecisionFormConstraint) = GenericProd()

Expand Down
2 changes: 1 addition & 1 deletion docs/src/extra/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ We use default [Julia style guide](https://docs.julialang.org/en/v1/manual/style

- Use 4 spaces for indentation
- Type names use `UpperCamelCase`. For example: `AbstractFactorNode`, `RandomVariable`, etc..
- Function names are `lowercase` with underscores, when necessary. For example: `activate!`, `randomvar`, `as_variable`, etc..
- Function names are `lowercase` with underscores, when necessary. For example: `activate!`, `randomvar`, etc..
- Variable names and function arguments use `snake_case`
- The name of a method that modifies its argument(s) must end in `!`

Expand Down
File renamed without changes.
19 changes: 15 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,29 @@ ReactiveMP.jl
!!! note
This package exports only an inference engine, for the full ecosystem with convenient model and constraints specification we refer user to the [`RxInfer.jl`](https://github.com/reactivebayes/RxInfer.jl) package and its [documentation](https://reactivebayes.github.io/RxInfer.jl/stable/).

## Ideas and principles behind `ReactiveMP.jl`

`ReactiveMP.jl` is a particular implementation of message passing on factor graphs, which does not create any specific message passing schedule in advance, but rather _reacts_ on changes in the data source (hence _reactive_ in the name of the package). The detailed explanation of the ideas and principles behind the _Reactive Message Passing_ can be found in PhD disseration of _Dmitry Bagaev_ titled [__Reactive Probabilistic Programming for Scalable Bayesian Inference__](https://pure.tue.nl/ws/portalfiles/portal/313860204/20231219_Bagaev_hf.pdf) ([link2](https://research.tue.nl/nl/publications/reactive-probabilistic-programming-for-scalable-bayesian-inferenc), [link3](https://github.com/bvdmitri/phdthesis)).

## Examples and tutorials

Tutorials and examples are available in the [RxInfer documentation](https://reactivebayes.github.io/RxInfer.jl/stable/).
The `ReactiveMP.jl` package is intended for advanced users with a deep understanding of message passing principles.
Accesible tutorials and examples are available in the [RxInfer documentation](https://reactivebayes.github.io/RxInfer.jl/stable/).

## Table of Contents

```@contents
Pages = [
"lib/nodes.md",
"lib/message.md",
"lib/node.md",
"lib/math.md",
"extra/contributing.md"
"lib/marginal.md",
"lib/rules.md",
"lib/nodes.md",
"lib/helpers.md",
"lib/algebra.md",
"extra/contributing.md",
"extra/extensions.md",
"extra/methods.md",
]
Depth = 2
```
Expand Down
19 changes: 19 additions & 0 deletions docs/src/lib/algebra.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# [Algebra common utilities](@id lib-helpers-algebra-common)

## [diageye](@id lib-helpers-algebra-diageye)

```@docs
diageye
ReactiveMP.CompanionMatrix
ReactiveMP.PermutationMatrix
ReactiveMP.StandardBasisVector
ReactiveMP.GammaShapeLikelihood
ReactiveMP.ImportanceSamplingApproximation
ReactiveMP.mul_inplace!
ReactiveMP.negate_inplace!
ReactiveMP.mul_trace
ReactiveMP.rank1update
ReactiveMP.v_a_vT
ReactiveMP.powerset
ReactiveMP.besselmod
```
7 changes: 0 additions & 7 deletions docs/src/lib/algebra/common.md

This file was deleted.

13 changes: 5 additions & 8 deletions docs/src/lib/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@

`ReactiveMP` implements various structures/functions/methods as "helper" structures that might be useful in various contexts.

## [SkipIndexIterator](@id lib-helpers-skip-index-iterator)

```@docs
ReactiveMP.SkipIndexIterator
ReactiveMP.skipindex
```

## [FunctionalIndex](@id lib-helpers-functional-index)

```@docs
ReactiveMP.FunctionalIndex
ReactiveMP.MacroHelpers.proxy_type
ReactiveMP.MacroHelpers.ensure_symbol
ReactiveMP.MacroHelpers.@proxy_methods
ReactiveMP.MacroHelpers.upper_type
ReactiveMP.MacroHelpers.bottom_type
```
39 changes: 39 additions & 0 deletions docs/src/lib/marginal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# [Marginal implementation](@id lib-marginal)

## Marginal type

All marginals are encoded with the type `Marginal`.

```@docs
Marginal
```

From an implementation point a view the `Marginal` structure does nothing but hold some `data` object and redirects most of the statistical related functions to that `data` object. However, this object is used extensively in Julia's multiple dispatch.

```@docs
ReactiveMP.getdata(marginal::Marginal)
ReactiveMP.is_clamped(marginal::Marginal)
ReactiveMP.is_initial(marginal::Marginal)
ReactiveMP.getaddons(marginal::Marginal)
ReactiveMP.as_marginal
ReactiveMP.to_marginal
```

```@example marginal
using ReactiveMP, BayesBase, ExponentialFamily

distribution = ExponentialFamily.NormalMeanPrecision(0.0, 1.0)
marginal = Marginal(distribution, false, true, nothing)
```

```@example marginal
mean(marginal), precision(marginal)
```

```@example marginal
logpdf(marginal, 1.0)
```

```@example marginal
is_clamped(marginal), is_initial(marginal)
```
Loading
Loading