Skip to content
Discussion options

You must be logged in to vote

Hello,

Yes, you can either use the method rlberry.agents.dynprog.utils.value_iteration or the agent rlberry.agents.dynprog.ValueIterationAgent as below:

One-liner:

from rlberry.agents.dynprog import utils
env = ...
qfunc, vfunc, n_iterations = utils.value_iteration(env.R, env.P, gamma=0.99, epsilon=1e-6)

Full example:

import matplotlib.pyplot as plt
from rlberry.envs.finite import GridWorld


env = GridWorld.from_layout(
    """
IOO # OOO
OOO # OOO
OOO O OOO
OOO # OOO
OOO # OOR
"""
)

#
# Alternative 1: using dynprog.utils
#
from rlberry.agents.dynprog import utils

qfunc, vfunc, n_iterations = utils.value_iteration(
    env.R, env.P, gamma=0.99, epsilon=1e-6
)

# Visualize value function
i…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ngmq
Comment options

Answer selected by ngmq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants