Closed LorenzoBonanni closed 1 year ago
Looks like support
needs to be added in visualization.jl line 78, like this:
for (i, bᵢ) ∈ enumerate(support(b′))
Currently there is no test that visualizes a belief, so we should definitely add that.
@LorenzoBonanni do you have the expertise to submit a PR to fix it? If not, I'll try to get to it later this week.
I tried fixing, and a visualization test passes for the initial belief, but I think that is mostly just a fluke - I don't think it will pass for a generic belief like a particle collection.
Yeah, I've tried using the test you made on a ParticleCollection and it gives the above error because it can't enumerate a Particle Collection. Here is the code to try:
b0 = ParticleFilters.ParticleCollection{RSState{3}}(
RSState{3}[
RSState{3}([1, 1], Bool[0, 1, 0]),
RSState{3}([1, 1], Bool[1, 1, 1])
], nothing)
s0 = rand(b0)
c = render(pomdp, (s=s0, a=6, b=b0))
c |> SVG("rocksample.svg")
I've fixed this error by converting b′
into weighted_particles by adding the following code in visualization.jl line 75
elseif b isa ParticleCollection
b′ = weighted_particles(b)
This fixes the iterate error. But when iterating over the Belief if the rocks field of the state contains ones it gives another error:
ERROR: LoadError: MethodError: no method matching +(::Float64, ::Pair{RSState{3}, Float64})
Closest candidates are:
+(::Any, ::Any, ::Any, ::Any...) at operators.jl:560
+(::Union{Float16, Float32, Float64}, ::BigFloat) at mpfr.jl:399
+(::AbstractFloat, ::Bool) at bool.jl:102
...
Stacktrace:
[1] _broadcast_getindex_evalf
@ ./broadcast.jl:648 [inlined]
[2] _broadcast_getindex
@ ./broadcast.jl:621 [inlined]
[3] getindex
@ ./broadcast.jl:575 [inlined]
[4] macro expansion
@ ./broadcast.jl:984 [inlined]
[5] macro expansion
@ ./simdloop.jl:77 [inlined]
[6] copyto!
@ ./broadcast.jl:983 [inlined]
[7] copyto!
@ ./broadcast.jl:936 [inlined]
[8] materialize!
@ ./broadcast.jl:894 [inlined]
[9] materialize!
@ ./broadcast.jl:891 [inlined]
[10] errore()
@ Main ~/Desktop/BORSA/despot_test/src/a.jl:67
[11] top-level scope
@ ~/Desktop/BORSA/despot_test/src/a.jl:82
in expression starting at /home/lorenzobonanni/Desktop/BORSA/despot_test/src/a.jl:82
This is the code to reproduce the error: it is essentialy the inner part of the for loop at line 80 of visualization.jl
rock_beliefs = zeros(Float64, 3)
s_i = RSState{3}([1, 1], Bool[1, 0, 0])
b_i = RSState{3}([1, 1], Bool[1, 0, 0]) => 0.001
a = rock_beliefs[s_i.rocks.==1]
rock_beliefs[s_i.rocks.==1] .+= b_i
If we change the code a bit it gives no more error:
rock_beliefs = zeros(Float64, 3)
s_i = RSState{3}([1, 1], Bool[0, 0, 0])
b_i = RSState{3}([1, 1], Bool[1, 0, 0]) => 0.001
a = rock_beliefs[s_i.rocks.==1]
rock_beliefs[s_i.rocks.==1] .+= b_i
@zsunberg with the latest commit I've Fixed the errror
Thanks @LorenzoBonanni !! I will take a look later today.
@zsunberg Bump Up Version
Hi, I'm facing a problem when trying to generate a Gif of the Simulation using BasicPomcp and RockSample. The error is the following:
Here a minimal example to reproduce the Issue:
OS: Pop Os 22.04 Julia Version: 1.6 BasicPOMCP: v0.3.8 RockSample: v0.1.5 Cairo: v1.0.5 POMDPGifs: v0.1.1 POMDPs: v0.9.5