Skip to content

Commit

Permalink
moved a few things around
Browse files Browse the repository at this point in the history
  • Loading branch information
zsunberg committed Jan 24, 2017
1 parent 13835d0 commit a88b254
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
15 changes: 10 additions & 5 deletions src/domain_knowledge.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
estimate_value(policy, state, depth)
estimate_value(estimator, mdp, state, depth)
Return an estimate of the value.
Expand Down Expand Up @@ -33,6 +33,15 @@ type SolvedRolloutEstimator
rng::AbstractRNG
end

convert_estimator(ev::Any, solver::AbstractMCTSSolver, mdp::Union{POMDP,MDP}) = ev
function convert_estimator(ev::RolloutEstimator, solver::AbstractMCTSSolver, mdp::Union{POMDP,MDP})
return SolvedRolloutEstimator(convert_to_policy(ev.solver, mdp), solver.rng)
end
convert_to_policy(p::Policy, mdp::Union{POMDP,MDP}) = p
convert_to_policy(s::Solver, mdp::Union{POMDP,MDP}) = solve(s, mdp)
convert_to_policy(f::Function, mdp::Union{POMDP,MDP}) = FunctionPolicy(f)


@POMDP_require estimate_value(estimator::SolvedRolloutEstimator, mdp::MDP, state, depth::Int) begin
@subreq rollout(estimator, mdp, state, depth)
end
Expand All @@ -54,8 +63,6 @@ end
init_Q(initializer, mdp, s, a)
Return a value to initialize Q(s,a) to based on domain knowledge.
By default, returns 0.0.
"""
function init_Q end
init_Q(f::Function, mdp::Union{MDP,POMDP}, s, a) = f(mdp, s, a)
Expand All @@ -65,8 +72,6 @@ init_Q(n::Number, mdp::Union{MDP,POMDP}, s, a) = convert(Float64, n)
init_N(initializer, mdp, s, a)
Return a value to initialize N(s,a) to based on domain knowledge.
By default, returns 0.
"""
function init_N end
init_N(f::Function, mdp::Union{MDP,POMDP}, s, a) = f(mdp, s, a)
Expand Down
8 changes: 0 additions & 8 deletions src/vanilla.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,6 @@ function fill_defaults!{S,A}(p::MCTSPolicy{S,A}, solver::MCTSSolver=p.solver, md
return p
end

convert_estimator(ev::Any, solver::AbstractMCTSSolver, mdp::Union{POMDP,MDP}) = ev
function convert_estimator(ev::RolloutEstimator, solver::AbstractMCTSSolver, mdp::Union{POMDP,MDP})
return SolvedRolloutEstimator(convert_to_policy(ev.solver, mdp), solver.rng)
end
convert_to_policy(p::Policy, mdp::Union{POMDP,MDP}) = p
convert_to_policy(s::Solver, mdp::Union{POMDP,MDP}) = solve(s, mdp)
convert_to_policy(f::Function, mdp::Union{POMDP,MDP}) = FunctionPolicy(f)


"""
Delete existing decision tree.
Expand Down

0 comments on commit a88b254

Please sign in to comment.