Reinforce.jl is discontinued. Please reference CommonRLInterface.
This package wraps POMDPs.jl problems into reinforcement learning environments with Reinforce.jl interface. This allows POMDP problems to be used with a variety of deep reinforcement learning algorithms.
We will use the Episode
type from Reinforce
to run a quick simulation.
using POMDPReinforce
using Reinforce
import POMDPModels: GridWorld, LightDark1D
# Create a random Reinforce.jl policy
type RandomPolicy <: AbstractPolicy end
Reinforce.action(policy::RandomPolicy, r, s, A) = rand(A)
policy = RandomPolicy()
# Simulating an grid world MDP environment
env = MDPEnv(GridWorld())
ep = Episode(env, policy)
for (s, a, r, sp) in ep
# do some custom pre-processing if needed
info("State $s, action $a, reward $r")
end
# Simulating a light dark POMDP environment
env = POMDPEnv(LightDark1D(), MersenneTwister(1))
ep = Episode(env, policy)
for (o, a, r, op) in ep
# do some custom pre-processing if needed
info("Observation $o, action $a, reward $r")
end
You can also simulate wrapped POMDPs
problems in a similar way to OpenAI Gym.
using POMDPReinforce
import POMDPModels: GridWorld
env = MDPEnv(GridWorld())
s = reset!(env)
while !finished(env, s)
a = rand(actions(env, s))
r, sp = step!(env, s, a)
info("State $s, action $a, reward $r")
s = sp
end