-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Structs to define inference/generative methods (#155)
* Extend abstract types in EpiAwareBase * EpiAwareMethod structs * some optimization method structs * constructor unit tests
- Loading branch information
1 parent
43c448a
commit e68a536
Showing
16 changed files
with
130 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
module EpiInference | ||
|
||
""" | ||
Module for defining inference methods. | ||
""" | ||
module EpiInference | ||
|
||
using ..EpiAwareBase: AbstractEpiMethod, AbstractEpiOptMethod, | ||
AbstractEpiSamplingMethod | ||
using Pathfinder: pathfinder, PathfinderResult | ||
|
||
using DynamicPPL, DocStringExtensions | ||
|
||
#Export inference methods | ||
export AbstractNUTSMethod, EpiMethod, ManyPathfinder | ||
|
||
#Export functions | ||
export manypathfinder | ||
|
||
include("docstrings.jl") | ||
include("epiawaremethod.jl") | ||
include("manypathfinder.jl") | ||
include("nuts.jl") | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
""" | ||
`EpiMethod` represents a method for performing EpiAware inference and/or generative | ||
modelling, which combines a sequence of optimization steps to pass initialisation | ||
information to a sampler method. | ||
""" | ||
@kwdef struct EpiMethod{ | ||
O <: AbstractEpiOptMethod, S <: AbstractEpiSamplingMethod} <: | ||
AbstractEpiMethod | ||
pre_sampler_steps::Vector{O} | ||
sampler::S | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
""" | ||
Abstract super type for NUTS methods. | ||
""" | ||
abstract type AbstractNUTSMethod <: AbstractEpiSamplingMethod end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ware/src/epiawareproblems/epiawareprob.jl → EpiAware/src/epiawareprob.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@testitem "EpiMethod" begin | ||
@testset "Constructor" begin | ||
struct TestNUTSMethod <: AbstractNUTSMethod | ||
end | ||
|
||
pre_sampler_steps = [ManyPathfinder(), ManyPathfinder()] | ||
sampler = TestNUTSMethod() | ||
method = EpiMethod(pre_sampler_steps, sampler) | ||
@test method.pre_sampler_steps == pre_sampler_steps | ||
@test method.sampler == sampler | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@testitem "ManyPathfinder constructor" begin | ||
@testset "Default constructor" begin | ||
method = ManyPathfinder() | ||
@test method.nruns == 4 | ||
@test method.maxiters == 50 | ||
@test method.max_tries == 100 | ||
end | ||
|
||
@testset "Constructor" begin | ||
nruns = 5 | ||
maxiters = 10 | ||
max_tries = 10 | ||
method = ManyPathfinder(; nruns, maxiters, max_tries) | ||
@test method.nruns == nruns | ||
@test method.maxiters == maxiters | ||
@test method.max_tries == max_tries | ||
end | ||
end |