Julia 将示例从QuantEcon.jl移植到POMDPs.jl

Julia 将示例从QuantEcon.jl移植到POMDPs.jl,julia,dynamic-programming,Julia,Dynamic Programming,我问了这个问题,但没有得到回应。我来这里是想看看我运气好不好 为了好玩(也为了学习POMDP),我将一个动态编程示例从QuantEcon.jl移植到POMDPs.jl。这个例子是可用的 我的实施代码是: using POMDPs using POMDPModels using POMDPModelTools using DiscreteValueIteration struct SimpleOG{TI <: Integer, T <: Real, TR <: Abstract

我问了这个问题,但没有得到回应。我来这里是想看看我运气好不好

为了好玩(也为了学习POMDP),我将一个动态编程示例从QuantEcon.jl移植到POMDPs.jl。这个例子是可用的

我的实施代码是:

using POMDPs
using POMDPModels
using POMDPModelTools
using DiscreteValueIteration

struct SimpleOG{TI <: Integer, T <: Real, TR <: AbstractArray{T}, TQ <: AbstractArray{T}} <: MDP{T, T}
    B :: TI
    M :: TI
    α :: T
    β :: T
    R :: TR
    Q :: TQ
end

function SimpleOG(; B::Integer = 10, M::Integer = 5, α::T = 0.5, β::T = 0.90) where {T <: Real}

    u(c) = c^α # utility function
    n = B + M + 1
    m = M + 1

    R = Matrix{T}(undef, n, m)
    Q = zeros(Float64, n, m, n)

    for a in 0:M
        Q[:, a + 1, (a:(a + B)) .+ 1] .= 1 / (B + 1)
        for s in 0:(B + M)
            R[s + 1, a + 1] = a <= s ? u(s - a) : -Inf
        end
    end

    return SimpleOG(B, M, α, β, R, Q)
end

POMDPs.states(simpleog::SimpleOG) = collect(0:(simpleog.M + simpleog.B))
POMDPs.n_states(simpleog::SimpleOG) = simpleog.B + simpleog.M + 1
POMDPs.stateindex(simpleog::SimpleOG, s) = Int(s) + 1

POMDPs.actions(simpleog::SimpleOG) = collect(0:simpleog.M)
POMDPs.n_actions(simpleog::SimpleOG) = simpleog.M + 1
POMDPs.actionindex(simpleog::SimpleOG, a) = Int(a) + 1

POMDPs.transition(simpleog::SimpleOG, s, a) = simpleog.Q[Int(a) + 1, Int(s) + 1, :]

POMDPs.reward(simpleog::SimpleOG, s, a) = simpleog.R[Int(s), Int(a)]
POMDPs.reward(simpleog::SimpleOG, s, a, sp) = reward(simpleog, s, a)

POMDPs.discount(simpleog::SimpleOG) = simpleog.β

g = SimpleOG()

你能帮我弄清楚发生了什么吗?

hckr说的:POMDP.jl定义了一个标准接口,有点像JuMP.jl

定义模型后,您需要一个解算器来解算它

是一个,是另一个,或者是普通的老人也可以工作。 你可以加入深度学习宣传,也可以尝试

有很多不同的求解算法,您也可以编写自己的算法(参见POMDP.jl和示例)

我经历了很多(充分披露,他是我的老师),很多很多人也是如此

编辑:
至于
pdf
位(这对于评论来说太长了):
不幸的是,这些套餐有很多问题。
因此,这里有几个与笔记本相关的例子,还有一个稍微相关一些。不幸的是,这两个例子都没有提到pdf,但其他例子(TMAZE和表格)也提到了pdf,其他例子也一样

隐藏潜在客户,看起来是您进行演练和文档记录的最佳选择
transition(::MDP,::State,::Action)
返回某种类型的分发对象,以馈送到
pdf

它可能是
。。。问题是?抱歉,忘了复制问题的最后一部分,现在已在中编辑。您是否检查了POMDPs';文档似乎
solve
需要一个解算器和一个问题(两个参数)。您只给出一个参数。此外,还有一些有用的命令可以告诉您,如果问题仍然存在,您会错过什么。请查看POMDPs的文档和常见问题解答。好的,谢谢。假设我使用的是
DiscreteValueIteration
@requirements\u info ValueIterationSolver()SimpleOG()
说我需要实现
pdf
,但我找不到任何定义了
pdf
的示例(还要注意,文档中指向教程的链接已断开)。您能否提供一个示例,说明如何定义
pdf
julia> POMDPs.solve(g)
MethodError: no method matching solve(::SimpleOG{Int64,Float64,Array{Float64,2},Array{Float64,3}})
Closest candidates are:
  solve(!Matched::POMDPPolicies.FunctionSolver, !Matched::Union{MDP, POMDP}) at /Users/amrods/.julia/packages/POMDPPolicies/oW6ud/src/function.jl:23
  solve(!Matched::POMDPPolicies.RandomSolver, !Matched::Union{MDP, POMDP}) at /Users/amrods/.julia/packages/POMDPPolicies/oW6ud/src/random.jl:36
  solve(!Matched::POMDPPolicies.VectorSolver{A}, !Matched::MDP{S,A}) where {S, A} at /Users/amrods/.julia/packages/POMDPPolicies/oW6ud/src/vector.jl:23
  ...

Stacktrace:
 [1] top-level scope at In[14]:1