Skip to content

Commit

Permalink
fixed error with undef for terminal POMDP states
Browse files Browse the repository at this point in the history
  • Loading branch information
zsunberg committed Dec 6, 2018
1 parent 6c9c2a9 commit 824f32d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/pomdps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ function predict!(pm, m::POMDP, b, a, rng)
all_terminal = true
for i in 1:n_particles(b)
s = particle(b, i)
if isterminal(m, s)
pm[i] = undef
else
if !isterminal(m, s)
all_terminal = false
sp = generate_s(m, s, a, rng)
pm[i] = sp
Expand Down
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using POMDPModels
using Test
using POMDPPolicies
using POMDPSimulators
using POMDPModelTools
using Random
using Distributions
using NBInclude
Expand Down Expand Up @@ -77,6 +78,17 @@ struct ContinuousPOMDP <: POMDP{Float64, Float64, Float64} end
end
end

struct TerminalPOMDP <: POMDP{Int, Int, Float64} end
POMDPs.isterminal(::TerminalPOMDP, s) = s == 1
POMDPs.observation(::TerminalPOMDP, a, sp) = Normal(sp)
POMDPs.transition(::TerminalPOMDP, s, a) = Deterministic(s+a)
@testset "pomdp terminal" begin
pomdp = TerminalPOMDP()
pf = SIRParticleFilter(pomdp, 100)
bp = update(pf, initialize_belief(pf, Categorical([0.5, 0.5])), -1, 1.0)
@test all(particles(bp) .== 1)
end

@testset "alpha" begin
# test specific method for alpha vector policies and particle beliefs
pomdp = BabyPOMDP()
Expand Down

0 comments on commit 824f32d

Please sign in to comment.