Skip to content

Commit

Permalink
Release 0.17.5.
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelsonric committed Sep 27, 2023
1 parent 8058489 commit 3bf90b8
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AlgebraicInference"
uuid = "0f243b7c-5df9-4f7c-98ce-987ef7223a7f"
authors = ["Richard Samuelson"]
version = "0.17.4"
version = "0.17.5"

[deps]
AMD = "14f7f29c-3bd6-536c-9a0b-7339e30b5a3e"
Expand Down
3 changes: 3 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ ChordalGraph
CuthillMcKeeJL_RCM
AMDJL_AMD
MetisJL_ND
```

## Supernodes
```@docs
SupernodeType
Node
MaximalSupernode
Expand Down
4 changes: 2 additions & 2 deletions docs/src/generated/pixel.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ For plotting:

````@example pixel
function Base.isless(x::Int, y::BoolRig)
y == true ? x < 1 : x < 0
x < y.value
end;
nothing #hide
````

Example 2.4.1 in Spivak et. al.
Example 2.4.1 in Spivak et al.
```math
\begin{align*}
& \text{Solve relations:} && \cos(\ln(z^2 + 10^{-3}x)) - x + 10^{-5}z^{-1} = 0 && \text{(Equation 1)} \\
Expand Down
2 changes: 1 addition & 1 deletion src/architectures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A message-passing algorithm. The options are
- [`Idempotent`](@ref)
There is one additional type, which you can use for sampling from a graphical model:
- [`AncestralSamper`](@ref)
- [`AncestralSampler`](@ref)
"""
abstract type ArchitectureType end

Expand Down
1 change: 1 addition & 0 deletions src/elimination.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ struct MetisJL_ND <: EliminationAlgorithm end
A type of supernode. The options are
- [`Node`](@ref)
- [`MaximalSupernode`](@ref)
- [`FundamentalSupernode`](@ref)
"""
abstract type SupernodeType end

Expand Down
19 changes: 12 additions & 7 deletions src/problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,19 @@ end
Solve an inference problem. This involves several steps:
```
interaction graph
↓ elimination algorithm
elimination tree
↓ supernode type
join tree
↓ architecture type
solution
interaction graph
↓ elimination algorithm
elimination tree
↓ supernode type
join tree
↓ architecture type
solution
```
First an elimination agorithm is used to construct an elimination tree from the model's
interaction graph. Then, nodes of the elimination tree are merged into supernodes, forming
a join (or junction) tree. Finally, a message passing algorithm is used to compute a
solution.
"""
CommonSolve.solve(
problem::InferenceProblem,
Expand Down
24 changes: 12 additions & 12 deletions src/solvers.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
"""
InferenceSolver{T₁, T₂, T₃, T₄, T₅}
A solver for an inference problem. A solver can use one of four message-passing algorithms:
- The Shenoy-Shafer architecture
- The Lauritzen-Spiegelhalter architecture
- The HUGIN architecture
- The idempotent architecture
A solver for an inference problem.
"""
mutable struct InferenceSolver{T₁, T₂, T₃, T₄, T₅}
architecture::Architecture{T₁, T₂, T₃, T₄, T₅}
Expand Down Expand Up @@ -68,15 +64,19 @@ end
Construct a solver for an inference problem. This involves several steps:
```
interaction graph
↓ elimination algorithm
elimination tree
↓ supernode type
join tree
interaction graph
↓ elimination algorithm
elimination tree
↓ supernode type
join tree
```
The argument `architecture_type` deterimines which message-passing algorithm is used to
solve the inference problem.
First an elimination agorithm is used to construct an elimination tree from the model's
interaction graph. Then, nodes of the elimination tree are merged into supernodes, forming
a join (or junction) tree.
When [`solve!`](@ref) is called on the solver, a message passing algorithm is used to compute
the solution.
"""
function CommonSolve.init(
problem::InferenceProblem,
Expand Down
23 changes: 15 additions & 8 deletions src/systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ end
s::AbstractVector,
σ::Real)
Construct a Gaussian system by specifying its energy function.
You should set `σ` equal to ``s^\\mathsf{T} S^+ s``, where ``S^+`` is the Moore-Penrose
psuedoinverse of ``S``.
Construct a Gaussian system by specifying its energy function. You should set
```julia
σ = dot(s, pinv(S) * s)
```
"""
function GaussianSystem(P::T₁, S::T₂, p::T₃, s::T₄, σ::T₅) where {
T₁ <: AbstractMatrix,
Expand Down Expand Up @@ -172,8 +172,11 @@ end
"""
CanonicalForm(K::AbstractMatrix, h::AbstractVector)
Construct the canonical form ``\\mathcal{C}(K, h, g)``, where the normalization constant
``g`` is inferred from ``K`` and ``h``.
Construct the canonical form
```math
\\mathcal{C}(K, h, g),
```
where the normalization constant ``g`` is inferred from ``K`` and ``h``.
"""
function CanonicalForm(K::T₁, h::T₂) where {T₁ <: AbstractMatrix, T₂ <: AbstractVector}
CanonicalForm{T₁, T₂}(K, h)
Expand Down Expand Up @@ -269,7 +272,9 @@ end
kernel(L::AbstractMatrix, μ::AbstractVector, Σ::AbstractMatrix)
Construct a conditional distribution of the form
``p(Y \\mid X = x) = \\mathcal{N}(Lx + \\mu, \\Sigma).``
```math
p(Y \\mid X = x) = \\mathcal{N}(Lx + \\mu, \\Sigma).
```
"""
function kernel(L::AbstractMatrix, μ::AbstractVector, Σ::AbstractMatrix)
normal(μ, Σ) * [-L I]
Expand All @@ -280,7 +285,9 @@ end
kernel(l::AbstractVector, μ::Real, σ::Real)
Construct a conditional distribution of the form
``p(Y \\mid X = x) = \\mathcal{N}(l^\\mathsf{T}x + \\mu, \\sigma^2).``
```math
p(Y \\mid X = x) = \\mathcal{N}(l^\\mathsf{T}x + \\mu, \\sigma^2).
```
"""
function kernel(l::AbstractVector, μ::Real, σ::Real)
normal(μ, σ) * [-l' I]
Expand Down

0 comments on commit 3bf90b8

Please sign in to comment.