Stochastic Tunneling
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- julia
- Domain
- documentation
Research direction
Start from the embedded Julia implementation of ObjDist and STUN, and read the surrounding documentation structure in the repository to find the appropriate tutorial or example location. Done means adding a clear write-up of stochastic tunneling that explains the shown usage and integrates it into the documentation.
Written by the indexing model from the issue text.
Description
@mohamed82008 wrote a nifty thing to do stochastic tunneling and it might be nice to do a little write up on it.
using Distributions, LinearAlgebra
mutable struct ObjDist{F, Tobj, Tsol, Tstep, Tbound} <: Distribution{Multivariate, Continuous}
f::F
best_obj::Tobj
best_sol::Tsol
step::Tstep
lb::Tbound
ub::Tbound
end
function ObjDist(f, N=1; step = 1.0, lb=-Inf, ub=Inf)
x0 = rand.(TruncatedNormal.(zeros(N), step, lb, ub))
obj = f(x0)
return ObjDist(f, obj, x0, step, lb, ub)
end
function Base.rand(dist::ObjDist)
N = length(dist.best_sol)
r = rand.(TruncatedNormal.(dist.best_sol, dist.step, dist.lb, dist.ub))
return r
end
function Distributions.logpdf(dist::ObjDist, x::AbstractVector)
obj = dist.f(x)
if obj > dist.best_obj || isnan(dist.best_obj)
dist.best_obj = obj
dist.best_sol .= x
end
return obj
end
using Turing
function STUN(f, N, alg = MH(10000))
dist = ObjDist(f, N)
@model obj_model() = begin
obj ~ dist
end
sample(obj_model(), alg)
return dist.best_sol, dist.best_obj
end
STUN(x->-norm(x .- 20), 3)
- Dominant language
- Markdown
- Stars
- 238
- Forks
- 107
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TuringLang/docs
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
TuringLang/docs#699 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
TuringLang/docs#700 ·
-
TuringLang/docs#686 · 1 assignee ·
-
TuringLang/docs#684 · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
TuringLang/docs#681 · 7 comments ·
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·