Skip to content

Commit

Permalink
better qvalue
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Petrik committed Jan 3, 2024
1 parent c4d3dec commit c58c930
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MDPs"
uuid = "faa839ec-fb2b-412e-b807-f8b3264e2d6a"
authors = ["Marek Petrik <[email protected]>"]
version = "0.1.3"
version = "0.1.4"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
5 changes: 3 additions & 2 deletions src/valuefunction/bellman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ value function `v` for an `objective`.
There is no set representation for the value function.
"""
@inline function qvalue(model::MDP{S,A}, objective::Objective, s::S, a::A, v) where {S,A}
function qvalue(model::MDP{S,A}, objective::Union{FiniteH, InfiniteH},
s::S, a::A, v) where {S,A}
val :: Float64 = 0.0
# much much faster than sum( ... for)
for (sn, p, r) transition(model, s, a)
Expand All @@ -74,7 +75,7 @@ value function `v` for a discount factor `γ`.
This function is just a more efficient version of the standard definition.
"""
@inline function qvalue(model::IntMDP, objective::Objective,
function qvalue(model::IntMDP, objective::Union{FiniteH, InfiniteH},
s::Int, a::Int, v::AbstractVector{<:Real})
x = model.states[s].actions[a]
val = 0.0
Expand Down

0 comments on commit c58c930

Please sign in to comment.