Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ MGVI = "fdae7790-d271-4276-880d-f72bbddf129c"
NestedSamplers = "41ceaf6f-1696-4a54-9b49-2e7a9ec3782e"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
OptimizationBase = "bca83a33-5cc9-4baa-983d-23429ab6bcbb"
OptimizationLBFGSB = "22f7324a-a79d-40f2-bebe-3af60c77bd15"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PropertyFunctions = "09e99361-2bb8-48a2-a80f-de58f0739eb4"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
Expand All @@ -91,6 +92,7 @@ BATMGVIExt = "MGVI"
BATNestedSamplersExt = "NestedSamplers"
BATOptimExt = "Optim"
BATOptimizationBaseExt = ["OptimizationBase"]
BATOptimizationLBFGSBExt = "OptimizationLBFGSB"
BATPlotsExt = "Plots"
BATPropertyFunctionsExt = "PropertyFunctions"
BATSliceSamplingExt = "SliceSampling"
Expand Down Expand Up @@ -147,6 +149,7 @@ NestedSamplers = "0.8, 0.9"
OneTwoMany = "0.1.2"
Optim = "1.12, 2"
OptimizationBase = "3.3, 4, 5"
OptimizationLBFGSB = "1.5"
PDMats = "0.9, 0.10, 0.11"
ParallelProcessingTools = "0.4"
Parameters = "0.12, 0.13"
Expand Down
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ makedocs(
"Home" => "index.md",
"Installation" => "installation.md",
"List of algorithms" => "list_of_algorithms.md",
"Molewhacker importance sampling" => "molewhacker.md",
"Tutorial" => "tutorial.md",
"API Documentation" => "stable_api.md",
"Plotting" => "plotting.md",
Expand Down
2 changes: 2 additions & 0 deletions docs/src/experimental_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ EllipticalSliceMCMCSampling
GridSampler
HierarchicalDistribution
PriorImportanceSampler
MolewhackerRefit
MolewhackerSampling
ReactiveNestedSampling
SliceMCMCSampling
SobolSampler
Expand Down
1 change: 1 addition & 0 deletions docs/src/internal_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ BAT.LogDVal
BAT.MCMCSampleGenerator
BAT.MCMCStepInfo
BAT.MeasureLike
BAT.MultiThreadedExec
BAT.NoWhitening
BAT.OnlineMvCov
BAT.OnlineMvMean
Expand Down
16 changes: 16 additions & 0 deletions docs/src/list_of_algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ bat_sample(target, PriorImportanceSampler(nsamples=10^5))
```


## Molewhacker importance sampler (experimental)

BAT sampling algorithm type: [`MolewhackerSampling`](@ref)

```julia
import ForwardDiff, OptimizationLBFGSB
context = BATContext(ad = ForwardDiff)
bat_sample(target, MolewhackerSampling(nsamples = 10^4), context)
```

Fits a defensive Gaussian mixture with local Fisher geometry. Returns fresh
importance samples from the fitted proposal. No MGVI dependency is required.
See [Molewhacker importance sampling](molewhacker.md) for supported models,
the sampling law, tuning, and diagnostics.


## Integration algorithms

BAT function: [`bat_integrate`](@ref)
Expand Down
266 changes: 266 additions & 0 deletions docs/src/molewhacker.md

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions ext/BATOptimizationLBFGSBExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is a part of BAT.jl, licensed under the MIT License (MIT).

module BATOptimizationLBFGSBExt

using BAT
import OptimizationLBFGSB

BAT.pkgext(::Val{:OptimizationLBFGSB}) = BAT.PackageExtension{:OptimizationLBFGSB}()
BAT.ext_default(::BAT.PackageExtension{:OptimizationLBFGSB}, ::Val{:LBFGSB_ALG}) = OptimizationLBFGSB.LBFGSB()

# The Fortran backend requires Float64 input. The sampler converts fitted
# centers back to the context precision before forming proposal geometry.
function BAT._mw_mode(center::AbstractVector{Float32}, logtarget,
mode::BAT.OptimizationAlg{<:OptimizationLBFGSB.LBFGSB}, remaining, context)
return BAT._mw_mode(Float64.(center), logtarget, mode, remaining, context)
end

end
Loading