forked from zsunberg/LightDarkPOMDPs.jl
/
runtests.jl
45 lines (36 loc) · 798 Bytes
/
runtests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using LightDarkPOMDPs
using Base.Test
using POMDPs
using POMDPToolbox
using StaticArrays
using Plots
using ParticleFilters
#### LightDark2D Problem ####
p = LightDark2D()
# simulate with a policy that moves -0.01 times the observation
hr = HistoryRecorder(max_steps=10)
h = sim(p, simulator=hr) do o
@show o
return -0.01*o
end
@show p.count
# simulate with a kalman filter
bpol = FunctionPolicy(b -> -0.5*mean(b))
up = LightDark2DKalman(p)
h = simulate(hr, p, bpol, up)
plotly()
plot(p)
plot!(h)
# gui()
#### LightDark2DTarget Problem ####
p = LightDark2DTarget()
plot(p)
up = SIRParticleFilter(p, 1000)
b = initialize_belief(up, initial_state_distribution(p))
plot!(b)
# gui()
hist = simulate(hr, p, bpol, up)
println("state trajectory")
for s in state_hist(hist)
@show s
end