From e4c5382c7ed09606ad14c496da7d4d5db0b2619d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 1 Apr 2021 01:07:10 +0000 Subject: [PATCH 1/9] CompatHelper: add new compat entry for "BeliefUpdaters" at version "0.2" --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 4d65d63..eaf897a 100644 --- a/Project.toml +++ b/Project.toml @@ -11,6 +11,7 @@ POMDPs = "a93abf59-7444-517b-a68a-c42f96afdd7d" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [compat] +BeliefUpdaters = "0.2" POMDPLinter = "0.1" POMDPModelTools = "0.3" POMDPs = "0.9" From 193ff295d10e4bd7df45657b0321eb0f0102003b Mon Sep 17 00:00:00 2001 From: Tomas Omasta Date: Thu, 8 Apr 2021 19:12:53 +0200 Subject: [PATCH 2/9] POMDPs.rand added --- src/fixhorizon.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fixhorizon.jl b/src/fixhorizon.jl index 9434e18..deb6da1 100644 --- a/src/fixhorizon.jl +++ b/src/fixhorizon.jl @@ -166,6 +166,7 @@ end POMDPs.mean(d::InStageDistribution) = (mean(d.d), d.stage) POMDPs.mode(d::InStageDistribution) = (mode(d.d), d.stage) POMDPs.support(d::InStageDistribution) = Iterators.product(support(d.d), d.stage) +POMDPs.rand(r::AbstractRNG, d::FiniteHorizonPOMDPs.InStageDistribution) = (rand(r, d.d), d.stage) ordered_stage_states(w::FHWrapper, stage::Int) = POMDPModelTools.ordered_vector(statetype(typeof(w)), s->stage_stateindex(w,s), stage_states(w, stage), "stage_state") ordered_stage_observations(w::FHWrapper, stage::Int) = POMDPModelTools.ordered_vector(obstype(typeof(w)), o->stage_obsindex(w,o), stage_observations(w, stage), "stage_observation") From 595cb8c83438cd67d435edd12c6b99d2dbce39f8 Mon Sep 17 00:00:00 2001 From: Tomas Omasta Date: Mon, 19 Apr 2021 20:53:00 +0200 Subject: [PATCH 3/9] Documentation and interface methods fix --- src/FiniteHorizonPOMDPs.jl | 8 ++--- src/fixhorizon.jl | 37 ++++++++++++++++------ src/interface.jl | 65 ++++++++++++++++++++++++++------------ 3 files changed, 76 insertions(+), 34 deletions(-) diff --git a/src/FiniteHorizonPOMDPs.jl b/src/FiniteHorizonPOMDPs.jl index 114b538..78e9226 100644 --- a/src/FiniteHorizonPOMDPs.jl +++ b/src/FiniteHorizonPOMDPs.jl @@ -7,16 +7,16 @@ using BeliefUpdaters export - stage, - stage_states, - stage_stateindex, HorizonLength, FiniteHorizon, InfiniteHorizon, horizon, + stage, + stage_states, + stage_stateindex, + ordered_stage_states, stage_observations, stage_obsindex, - ordered_stage_states, ordered_stage_observations include("interface.jl") diff --git a/src/fixhorizon.jl b/src/fixhorizon.jl index deb6da1..4087c26 100644 --- a/src/fixhorizon.jl +++ b/src/fixhorizon.jl @@ -1,4 +1,3 @@ -# TODO: Docstring """ fixhorizon(m::Union{MDP,POMDP}, horizon::Int) @@ -60,6 +59,11 @@ Mark the state as terminal if its stage number if greater than horizon, else let """ POMDPs.isterminal(w::FHWrapper, ss::Tuple{<:Any,Int}) = stage(w, ss) > horizon(w) || isterminal(w.m, first(ss)) +""" + POMDPs.gen(w::FHWrapper, ss::Tuple{<:Any,Int}, a, rng::AbstractRNG) + +Implement the entire MDP/POMDP generative model by returning a NamedTuple. +""" function POMDPs.gen(w::FHWrapper, ss::Tuple{<:Any,Int}, a, rng::AbstractRNG) out = gen(w.m, first(ss), a, rng) if haskey(out, :sp) @@ -77,6 +81,12 @@ Wrap the transition result of Infinite Horizon MDP with stage number. POMDPs.transition(w::FHWrapper, ss::Tuple{<:Any,Int}, a) = InStageDistribution(transition(w.m, first(ss), a), stage(w, ss)+1) # TODO: convert_s +""" + POMDPs.actions(w::FHWrapper, ss::Tuple{<:Any,Int}) + +Return the actions of Infinite Horizon (PO)MDP. +This method assumes similar actions for all stages. +""" POMDPs.actions(w::FHWrapper, ss::Tuple{<:Any,Int}) = actions(w.m, first(ss)) """ @@ -93,12 +103,12 @@ Create a product of Infinite Horizon MDP's observations with all not-terminal st """ POMDPs.observations(w::FixedHorizonPOMDPWrapper) = Iterators.product(observations(w.m), 1:horizon(w)) -stage_observations(w::FixedHorizonPOMDPWrapper, stage::Int) = Iterators.product(observations(w.m), stage) - -stage_obsindex(w::FixedHorizonPOMDPWrapper, o::Tuple{<:Any,Int}) = obsindex(w.m, first(o)) +""" + POMDPs.obsindex(w::FixedHorizonPOMDPWrapper, o::Tuple{<:Any, Int})::Int -# TODO: Write Docstring -function POMDPs.obsindex(w::FixedHorizonPOMDPWrapper, o::Tuple{<:Any, Int}) +Compute the index of the given observation in the Finite Horizon observation space (meaning in observation space of all stages). +""" +function POMDPs.obsindex(w::FixedHorizonPOMDPWrapper, o::Tuple{<:Any, Int})::Int s, k = o return (k-1)*length(stage_observations(w, 1)) + obsindex(w.m, s) end @@ -125,6 +135,10 @@ POMDPs.initialobs(w::FixedHorizonPOMDPWrapper, ss::Tuple{<:Any,Int}) = initialob stage(w::FHWrapper, ss::Tuple{<:Any,Int}) = last(ss) stage_states(w::FHWrapper, stage::Int) = Iterators.product(states(w.m), stage) stage_stateindex(w::FHWrapper, ss::Tuple{<:Any,Int}) = stateindex(w.m, first(ss)) +stage_observations(w::FixedHorizonPOMDPWrapper, stage::Int) = Iterators.product(observations(w.m), stage) +stage_obsindex(w::FixedHorizonPOMDPWrapper, o::Tuple{<:Any,Int}) = obsindex(w.m, first(o)) +ordered_stage_states(w::FHWrapper, stage::Int) = POMDPModelTools.ordered_vector(statetype(typeof(w)), s->stage_stateindex(w,s), stage_states(w, stage), "stage_state") +ordered_stage_observations(w::FHWrapper, stage::Int) = POMDPModelTools.ordered_vector(obstype(typeof(w)), o->stage_obsindex(w,o), stage_observations(w, stage), "stage_observation") ############################### # Forwarded parts of POMDPs interface @@ -135,14 +149,17 @@ POMDPs.reward(w::FHWrapper, ss::Tuple{<:Any,Int}, a) = reward(w.m, first(ss), a) POMDPs.actions(w::FHWrapper) = actions(w.m) POMDPs.actionindex(w::FHWrapper, a) = actionindex(w.m, a) POMDPs.discount(w::FHWrapper) = discount(w.m) -POMDPModelTools.ordered_actions(w::FHWrapper) = ordered_actions(w.m) # TODO: convert_a ################################# # distribution with a fixed stage ################################# +""" + InStageDistribution{D} # TODO: Define access functions for InStageDistribution - to access with method instead of .d or .stage +Wrap given distribution with a given stage +""" struct InStageDistribution{D} d::D stage::Int @@ -168,5 +185,7 @@ POMDPs.mode(d::InStageDistribution) = (mode(d.d), d.stage) POMDPs.support(d::InStageDistribution) = Iterators.product(support(d.d), d.stage) POMDPs.rand(r::AbstractRNG, d::FiniteHorizonPOMDPs.InStageDistribution) = (rand(r, d.d), d.stage) -ordered_stage_states(w::FHWrapper, stage::Int) = POMDPModelTools.ordered_vector(statetype(typeof(w)), s->stage_stateindex(w,s), stage_states(w, stage), "stage_state") -ordered_stage_observations(w::FHWrapper, stage::Int) = POMDPModelTools.ordered_vector(obstype(typeof(w)), o->stage_obsindex(w,o), stage_observations(w, stage), "stage_observation") +################################# +# POMDPModelTools ordered actions +################################# +POMDPModelTools.ordered_actions(w::FHWrapper) = ordered_actions(w.m) diff --git a/src/interface.jl b/src/interface.jl index b6f5314..086cb0b 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -1,50 +1,73 @@ """ - stage(m::Union{MDP,POMDP}, ss::MDPState)::Int + HorizonLength(::Type{<:Union{MDP,POMDP}) + HorizonLength(::Union{MDP,POMDP}) + +Check whether MDP is Finite or Infinite Horizon and return corresponding struct (FiniteHorizon or InfiniteHorizon). +""" +abstract type HorizonLength end + +"If HorizonLength(m::Union{MDP,POMDP}) == FiniteHorizon(), horizon(m) should be implemented and return an integer" +struct FiniteHorizon <: HorizonLength end +"HorizonLength(m::Union{MDP,POMDP}) == InfiniteHorizon() indicates that horizon(m) should not be called." +struct InfiniteHorizon <: HorizonLength end + +HorizonLength(m::Union{MDP,POMDP}) = HorizonLength(typeof(m)) +HorizonLength(::Type{<:Union{MDP,POMDP}}) = InfiniteHorizon() + +""" +Return the number of *steps* that will be taken in the (PO)MDP, given it is Finite Horizon. + +A simulation of a (PO)MDP with `horizon(m) == d` should contain *d+1* states and *d* actions and rewards. +""" +function horizon end -Return number of state's stage +""" + stage(m::Union{MDP,POMDP}, ss)::Int + stage(m::Union{MDP,POMDP}, o)::Int + stage(d)::Int + +Considering a variable or distribution containing its stage assignment, return the number of its stage. """ function stage end """ stage_states(m::Union{MDP,POMDP}, stage::Int) -Create Infinite Horizon MDP's states for given stage. +Create (PO)MDP's states for given stage. """ function stage_states end """ - stage_stateindex(m::Union{MDP,POMDP}, ss::MDPState}::Int + stage_stateindex(m::Union{MDP,POMDP}, ss}::Int -Compute the index of the given state in Infinite Horizon for given stage state space. +Compute the index of the given state in the corresponding stage. """ function stage_stateindex end """ - HorizonLength(::Type{<:Union{MDP,POMDP}) - HorizonLength(::Union{MDP,POMDP}) + ordered_stage_states(w::FHWrapper, stage::Int) -Check whether MDP is Finite or Infinite Horizon and return corresponding struct (FiniteHorizon or InfiniteHorizon). +Return an AbstractVector of states from given stage ordered according to stage_stateindex(mdp, s). """ -abstract type HorizonLength end +function ordered_stage_states end -"If HorizonLength(m::Union{MDP,POMDP}) == FiniteHorizon(), horizon(m) should be implemented and return an integer" -struct FiniteHorizon <: HorizonLength end -"HorizonLength(m::Union{MDP,POMDP}) == InfiniteHorizon() indicates that horizon(m) should not be called." -struct InfiniteHorizon <: HorizonLength end +""" + stage_observations(m::Union{MDP,POMDP}, stage::Int) -HorizonLength(m::Union{MDP,POMDP}) = HorizonLength(typeof(m)) -HorizonLength(::Type{<:Union{MDP,POMDP}}) = InfiniteHorizon() +Create (PO)MDP's observations for given stage. +""" +function stage_observations end """ -Return the number of *steps* that will be taken in the (PO)MDP, given it is Finite Horizon. + stage_obsindex(m::Union{MDP,POMDP}, o::stage::Int) -A simulation of a (PO)MDP with `horizon(m) == d` should contain *d+1* states and *d* actions and rewards. +Compute the index of the given observation in the corresponding stage. """ -function horizon end +function stage_obsindex end """ - stage_observations(m::Union{MDP,POMDP}, stage::Int) + ordered_stage_observations(w::FHWrapper, stage::Int) -Infinite Horizon MDP's observation for given stage. +Return an AbstractVector of observations from given stage ordered according to stage_obsindex(w,o). """ -function stage_observations end +function ordered_stage_observations end From 846e0012c28419fd85d081f19bb1f24158cc59ec Mon Sep 17 00:00:00 2001 From: Tomas Omasta Date: Mon, 19 Apr 2021 20:53:33 +0200 Subject: [PATCH 4/9] Added access functions --- src/fixhorizon.jl | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/fixhorizon.jl b/src/fixhorizon.jl index 4087c26..46ec4f5 100644 --- a/src/fixhorizon.jl +++ b/src/fixhorizon.jl @@ -119,7 +119,7 @@ end Create a product of Infinite Horizon MDP's observations given destination state and action (and original state) with original state's stage. """ POMDPs.observation(w::FixedHorizonPOMDPWrapper, ss::Tuple{<:Any,Int}, a, ssp::Tuple{<:Any, Int}) = InStageDistribution(observation(w.m, first(ss), a, first(ssp)), stage(w, ss)) -POMDPs.observation(w::FixedHorizonPOMDPWrapper, a, ssp::Tuple{<:Any, Int}) = InStageDistribution(observation(w.m, a, first(ssp)), last(ssp)-1) +POMDPs.observation(w::FixedHorizonPOMDPWrapper, a, ssp::Tuple{<:Any, Int}) = InStageDistribution(observation(w.m, a, first(ssp)), stage(ssp)-1) """ POMDPs.initialstate(w::FHWrapper) @@ -157,7 +157,6 @@ POMDPs.discount(w::FHWrapper) = discount(w.m) """ InStageDistribution{D} -# TODO: Define access functions for InStageDistribution - to access with method instead of .d or .stage Wrap given distribution with a given stage """ struct InStageDistribution{D} @@ -165,25 +164,45 @@ struct InStageDistribution{D} stage::Int end +""" + distrib(d::InStageDistribution{D})::D + +Return distrubution wrapped in InStageDistribution without stage +""" +function distrib(d::InStageDistribution{D})::D + return d.d +end + +""" + stage(d::InStageDistribution) + +Return stage of InStageDistribution +""" +stage(d::InStageDistribution) = d.stage + + +# convert(::Type{Array{Float64, 1}}, d::FiniteHorizonPOMDPs.InStageDistribution{DiscreteUniform}, m::FiniteHorizonPOMDPs.FixedHorizonPOMDPWrapper) = vec([pdf(d, s) for s in states(m)]) +# convert(::Type{Array{Float64, 1}}, d::FiniteHorizonPOMDPs.InStageDistribution{BoolDistribution}, m::FiniteHorizonPOMDPs.FixedHorizonPOMDPWrapper) = [[distrib(d).p[1], 1 - distrib(d).p[1]]..., zeros(length(states(m)) - 2)...] + function BeliefUpdaters.DiscreteBelief(pomdp, b::InStageDistribution; check::Bool=true) - return DiscreteBelief(pomdp, b.d; check) + return DiscreteBelief(pomdp, convert(Array{Float64, 1}, b, pomdp); check) end Base.rand(rng::AbstractRNG, s::Random.SamplerTrivial{<:InStageDistribution}) = (rand(rng, s[].d), s[].stage) function POMDPs.pdf(d::InStageDistribution, ss::Tuple{<:Any, Int}) s, k = ss - if k == d.stage - return pdf(d.d, s) + if k == stage(d) + return pdf(distrib(d), s) else return 0.0 end end -POMDPs.mean(d::InStageDistribution) = (mean(d.d), d.stage) -POMDPs.mode(d::InStageDistribution) = (mode(d.d), d.stage) -POMDPs.support(d::InStageDistribution) = Iterators.product(support(d.d), d.stage) -POMDPs.rand(r::AbstractRNG, d::FiniteHorizonPOMDPs.InStageDistribution) = (rand(r, d.d), d.stage) +POMDPs.mean(d::InStageDistribution) = (mean(distrib(d)), stage(d)) +POMDPs.mode(d::InStageDistribution) = (mode(distrib(d)), stage(d)) +POMDPs.support(d::InStageDistribution) = Iterators.product(support(distrib(d)), stage(d)) +POMDPs.rand(r::AbstractRNG, d::FiniteHorizonPOMDPs.InStageDistribution) = (rand(r, distrib(d)), stage(d)) ################################# # POMDPModelTools ordered actions From 3c23a62ea793fefa716902e54bf5ea4147a77e4e Mon Sep 17 00:00:00 2001 From: Tomas Omasta Date: Mon, 19 Apr 2021 21:33:33 +0200 Subject: [PATCH 5/9] Fix named type in tests --- src/fixhorizon.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fixhorizon.jl b/src/fixhorizon.jl index 46ec4f5..81dc661 100644 --- a/src/fixhorizon.jl +++ b/src/fixhorizon.jl @@ -169,7 +169,7 @@ end Return distrubution wrapped in InStageDistribution without stage """ -function distrib(d::InStageDistribution{D})::D +function distrib(d::InStageDistribution) return d.d end From 7cdfeff31825a43e3f2ea86a725a2691ab77d95c Mon Sep 17 00:00:00 2001 From: Tomas Omasta Date: Mon, 19 Apr 2021 21:33:45 +0200 Subject: [PATCH 6/9] 0.3.1 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index eaf897a..1b25bb4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FiniteHorizonPOMDPs" uuid = "8a13bbfe-798e-11e9-2f1c-eba9ee5ef093" authors = ["Tomas Omasta and contributors"] -version = "0.3.0" +version = "0.3.1" [deps] BeliefUpdaters = "8bb6e9a1-7d73-552c-a44a-e5dc5634aac4" From bad768025aa6564fbffc96c4800cfc41e4288f85 Mon Sep 17 00:00:00 2001 From: Tomas Omasta Date: Mon, 19 Apr 2021 22:03:20 +0200 Subject: [PATCH 7/9] Readme.md update --- README.md | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1876a49..c976f57 100644 --- a/README.md +++ b/README.md @@ -15,20 +15,39 @@ The goals are to Notably, in accordance with goal (4), this package does **not** define something like `AbstractFiniteHorizonPOMDP`. -## Use +## Usage Package offers interface for finite horizon POMDPs. Solver currently supports only MDPs. User can either implement: - finite horizon MDP using both POMDPs.jl and FiniteHorizonPOMDPs.jl interface functions or - infinite horizon MDP and transform it to finite horizon one using `fixhorizon` utility + ``` + using FiniteHorizonPOMDPs + import POMDPModels + + gw = SimpleGridWorld() # initialize Infinite Horizon model + fhgw = fixhorizon(gw, 2) # use fixhorizon utility to transform it to Finite Horizon + ``` + ## Interface -- `HorizonLength(::Type{<:Union{MDP,POMDP}) = InfiniteHorizon()` - - `FiniteHorizon` - - `InfiniteHorizon` + - `HorizonLength(::Type{<:Union{MDP,POMDP})` + - Checks whether MDP is Finite or Infinite Horizon and return corresponding struct (FiniteHorizon or InfiniteHorizon). - `horizon(m::Union{MDP,POMDP})::Int` + - Returns the number of *steps* that will be taken in the (PO)MDP, given it is Finite Horizon. + - `stage(m::Union{MDP,POMDP}, ss)::Int` + - Returns the number of input variable's stage. - `stage_states(m::Union{MDP,POMDP}, stage::Int)` + - Creates (PO)MDP's states for given stage. - `stage_stateindex(m::Union{MDP,POMDP}, state)` - - `stage(m::Union{MDP,POMDP}, state)` + - Computes the index of the given state in the corresponding stage. + - `ordered_stage_states(w::FHWrapper, stage::Int)` + - Returns an `AbstractVector` of states from given stage ordered according to `stage_stateindex(mdp, s)`. + - `stage_observations(m::Union{MDP,POMDP}, stage::Int)` + - Creates (PO)MDP's observations for given stage. + - `stage_obsindex(m::Union{MDP,POMDP}, o::stage::Int)` + - Computes the index of the given observation in the corresponding stage. + - `ordered_stage_observations(w::FHWrapper, stage::Int)` + - Returns an `AbstractVector` of observations from given stage ordered according to `stage_obsindex(w,o)`. From d4d123fcff3a4618f54a57c8cdfbc6a09e070b22 Mon Sep 17 00:00:00 2001 From: Tomas Omasta Date: Mon, 19 Apr 2021 23:17:22 +0200 Subject: [PATCH 8/9] fix stage(w, ss) call --- src/fixhorizon.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fixhorizon.jl b/src/fixhorizon.jl index 81dc661..ccbc5f0 100644 --- a/src/fixhorizon.jl +++ b/src/fixhorizon.jl @@ -119,7 +119,7 @@ end Create a product of Infinite Horizon MDP's observations given destination state and action (and original state) with original state's stage. """ POMDPs.observation(w::FixedHorizonPOMDPWrapper, ss::Tuple{<:Any,Int}, a, ssp::Tuple{<:Any, Int}) = InStageDistribution(observation(w.m, first(ss), a, first(ssp)), stage(w, ss)) -POMDPs.observation(w::FixedHorizonPOMDPWrapper, a, ssp::Tuple{<:Any, Int}) = InStageDistribution(observation(w.m, a, first(ssp)), stage(ssp)-1) +POMDPs.observation(w::FixedHorizonPOMDPWrapper, a, ssp::Tuple{<:Any, Int}) = InStageDistribution(observation(w.m, a, first(ssp)), stage(w, ssp)-1) """ POMDPs.initialstate(w::FHWrapper) From 5a30cbc249b9718d4dc76cc9ba0a6f60dd07a172 Mon Sep 17 00:00:00 2001 From: Tomas Omasta Date: Wed, 21 Apr 2021 20:01:41 +0200 Subject: [PATCH 9/9] Erased Discrete Belief constructor --- Project.toml | 2 -- src/FiniteHorizonPOMDPs.jl | 1 - src/fixhorizon.jl | 8 -------- 3 files changed, 11 deletions(-) diff --git a/Project.toml b/Project.toml index 1b25bb4..cb94a8e 100644 --- a/Project.toml +++ b/Project.toml @@ -4,14 +4,12 @@ authors = ["Tomas Omasta and contributors"] version = "0.3.1" [deps] -BeliefUpdaters = "8bb6e9a1-7d73-552c-a44a-e5dc5634aac4" POMDPLinter = "f3bd98c0-eb40-45e2-9eb1-f2763262d755" POMDPModelTools = "08074719-1b2a-587c-a292-00f91cc44415" POMDPs = "a93abf59-7444-517b-a68a-c42f96afdd7d" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [compat] -BeliefUpdaters = "0.2" POMDPLinter = "0.1" POMDPModelTools = "0.3" POMDPs = "0.9" diff --git a/src/FiniteHorizonPOMDPs.jl b/src/FiniteHorizonPOMDPs.jl index 78e9226..3fb5662 100644 --- a/src/FiniteHorizonPOMDPs.jl +++ b/src/FiniteHorizonPOMDPs.jl @@ -3,7 +3,6 @@ module FiniteHorizonPOMDPs using POMDPs using POMDPModelTools using Random: Random, AbstractRNG -using BeliefUpdaters export diff --git a/src/fixhorizon.jl b/src/fixhorizon.jl index ccbc5f0..f6e37df 100644 --- a/src/fixhorizon.jl +++ b/src/fixhorizon.jl @@ -180,14 +180,6 @@ Return stage of InStageDistribution """ stage(d::InStageDistribution) = d.stage - -# convert(::Type{Array{Float64, 1}}, d::FiniteHorizonPOMDPs.InStageDistribution{DiscreteUniform}, m::FiniteHorizonPOMDPs.FixedHorizonPOMDPWrapper) = vec([pdf(d, s) for s in states(m)]) -# convert(::Type{Array{Float64, 1}}, d::FiniteHorizonPOMDPs.InStageDistribution{BoolDistribution}, m::FiniteHorizonPOMDPs.FixedHorizonPOMDPWrapper) = [[distrib(d).p[1], 1 - distrib(d).p[1]]..., zeros(length(states(m)) - 2)...] - -function BeliefUpdaters.DiscreteBelief(pomdp, b::InStageDistribution; check::Bool=true) - return DiscreteBelief(pomdp, convert(Array{Float64, 1}, b, pomdp); check) -end - Base.rand(rng::AbstractRNG, s::Random.SamplerTrivial{<:InStageDistribution}) = (rand(rng, s[].d), s[].stage) function POMDPs.pdf(d::InStageDistribution, ss::Tuple{<:Any, Int})