Q-Learning policy doesn't agree with Value/Policy Iteration
up vote
0
down vote
favorite
I am playing with pymdptoolbox. It has a built-in problem of forest management. It can generate a transition matrix P and R by specifying a state value for forest function (default value is 3). The implementation of Q-Learning, PolicyIteration and ValueIteration to find the optimal policy is straightforward. However by creating a slightly more complicated problem by changing the state to a bit larger value than 4 (from 5 onwards), only PI and VI return the same policy while QL cannot find the optimal policy. This is very surprising and puzzling. Can anyone help me understand why is this for QL in this package?
By looking at the raw code of QL (using epsilon-greedy), it seems it ties the probability with iteration number, i.e. prob = 1 - (1/log(n+2)) and the learning rate is (1/math.sqrt(n+2)). Is there any specific reason why tying probability/learning rate to the iteration number, instead of making them independent variables (the code itself can be modified easily though).
I think my biggest puzzle is to understand why QL fails to find the policy for a vanilla problem. Thanks.
from mdptoolbox.mdp import ValueIteration, QLearning, PolicyIteration
from mdptoolbox.example import forest
Gamma = 0.99
states = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 30, 50, 70, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
compare_VI_QI_policy = # True or False
compare_VI_PI_policy =
for state in states:
P, R = forest(state)
VI = ValueIteration(P, R, Gamma)
PI = PolicyIteration(P, R, Gamma)
QL = QLearning(P, R, Gamma)
## run VI
VI.run()
# run PI
PI.run()
# run QL
QL.run()
compare_VI_QI_policy.append(QL.policy == VI.policy)
compare_VI_PI_policy.append(VI.policy == PI.policy)
print compare_VI_QI_policy
print compare_VI_PI_policy
python q-learning markov
add a comment |
up vote
0
down vote
favorite
I am playing with pymdptoolbox. It has a built-in problem of forest management. It can generate a transition matrix P and R by specifying a state value for forest function (default value is 3). The implementation of Q-Learning, PolicyIteration and ValueIteration to find the optimal policy is straightforward. However by creating a slightly more complicated problem by changing the state to a bit larger value than 4 (from 5 onwards), only PI and VI return the same policy while QL cannot find the optimal policy. This is very surprising and puzzling. Can anyone help me understand why is this for QL in this package?
By looking at the raw code of QL (using epsilon-greedy), it seems it ties the probability with iteration number, i.e. prob = 1 - (1/log(n+2)) and the learning rate is (1/math.sqrt(n+2)). Is there any specific reason why tying probability/learning rate to the iteration number, instead of making them independent variables (the code itself can be modified easily though).
I think my biggest puzzle is to understand why QL fails to find the policy for a vanilla problem. Thanks.
from mdptoolbox.mdp import ValueIteration, QLearning, PolicyIteration
from mdptoolbox.example import forest
Gamma = 0.99
states = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 30, 50, 70, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
compare_VI_QI_policy = # True or False
compare_VI_PI_policy =
for state in states:
P, R = forest(state)
VI = ValueIteration(P, R, Gamma)
PI = PolicyIteration(P, R, Gamma)
QL = QLearning(P, R, Gamma)
## run VI
VI.run()
# run PI
PI.run()
# run QL
QL.run()
compare_VI_QI_policy.append(QL.policy == VI.policy)
compare_VI_PI_policy.append(VI.policy == PI.policy)
print compare_VI_QI_policy
print compare_VI_PI_policy
python q-learning markov
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am playing with pymdptoolbox. It has a built-in problem of forest management. It can generate a transition matrix P and R by specifying a state value for forest function (default value is 3). The implementation of Q-Learning, PolicyIteration and ValueIteration to find the optimal policy is straightforward. However by creating a slightly more complicated problem by changing the state to a bit larger value than 4 (from 5 onwards), only PI and VI return the same policy while QL cannot find the optimal policy. This is very surprising and puzzling. Can anyone help me understand why is this for QL in this package?
By looking at the raw code of QL (using epsilon-greedy), it seems it ties the probability with iteration number, i.e. prob = 1 - (1/log(n+2)) and the learning rate is (1/math.sqrt(n+2)). Is there any specific reason why tying probability/learning rate to the iteration number, instead of making them independent variables (the code itself can be modified easily though).
I think my biggest puzzle is to understand why QL fails to find the policy for a vanilla problem. Thanks.
from mdptoolbox.mdp import ValueIteration, QLearning, PolicyIteration
from mdptoolbox.example import forest
Gamma = 0.99
states = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 30, 50, 70, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
compare_VI_QI_policy = # True or False
compare_VI_PI_policy =
for state in states:
P, R = forest(state)
VI = ValueIteration(P, R, Gamma)
PI = PolicyIteration(P, R, Gamma)
QL = QLearning(P, R, Gamma)
## run VI
VI.run()
# run PI
PI.run()
# run QL
QL.run()
compare_VI_QI_policy.append(QL.policy == VI.policy)
compare_VI_PI_policy.append(VI.policy == PI.policy)
print compare_VI_QI_policy
print compare_VI_PI_policy
python q-learning markov
I am playing with pymdptoolbox. It has a built-in problem of forest management. It can generate a transition matrix P and R by specifying a state value for forest function (default value is 3). The implementation of Q-Learning, PolicyIteration and ValueIteration to find the optimal policy is straightforward. However by creating a slightly more complicated problem by changing the state to a bit larger value than 4 (from 5 onwards), only PI and VI return the same policy while QL cannot find the optimal policy. This is very surprising and puzzling. Can anyone help me understand why is this for QL in this package?
By looking at the raw code of QL (using epsilon-greedy), it seems it ties the probability with iteration number, i.e. prob = 1 - (1/log(n+2)) and the learning rate is (1/math.sqrt(n+2)). Is there any specific reason why tying probability/learning rate to the iteration number, instead of making them independent variables (the code itself can be modified easily though).
I think my biggest puzzle is to understand why QL fails to find the policy for a vanilla problem. Thanks.
from mdptoolbox.mdp import ValueIteration, QLearning, PolicyIteration
from mdptoolbox.example import forest
Gamma = 0.99
states = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 30, 50, 70, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
compare_VI_QI_policy = # True or False
compare_VI_PI_policy =
for state in states:
P, R = forest(state)
VI = ValueIteration(P, R, Gamma)
PI = PolicyIteration(P, R, Gamma)
QL = QLearning(P, R, Gamma)
## run VI
VI.run()
# run PI
PI.run()
# run QL
QL.run()
compare_VI_QI_policy.append(QL.policy == VI.policy)
compare_VI_PI_policy.append(VI.policy == PI.policy)
print compare_VI_QI_policy
print compare_VI_PI_policy
python q-learning markov
python q-learning markov
edited Nov 20 at 5:35
Aqueous Carlos
301213
301213
asked Nov 20 at 5:27
Chenyang
286
286
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386742%2fq-learning-policy-doesnt-agree-with-value-policy-iteration%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown