Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
pymdptoolbox
Commits
7b0fdadf
Commit
7b0fdadf
authored
Jan 25, 2013
by
Steven Cordwell
Browse files
add a QLearning unit test
parent
448d8818
Changes
2
Hide whitespace changes
Inline
Side-by-side
mdp.py
View file @
7b0fdadf
...
@@ -1149,7 +1149,7 @@ class QLearning(MDP):
...
@@ -1149,7 +1149,7 @@ class QLearning(MDP):
self
.
discrepancy
=
[]
self
.
discrepancy
=
[]
def
iterate
(
self
):
def
iterate
(
self
):
"""
"""
Run the Q-learning algoritm.
"""
"""
self
.
time
=
time
()
self
.
time
=
time
()
...
...
test_mdptoolbox.py
View file @
7b0fdadf
...
@@ -6,8 +6,8 @@ Created on Sun May 27 23:16:57 2012
...
@@ -6,8 +6,8 @@ Created on Sun May 27 23:16:57 2012
"""
"""
from
mdp
import
check
,
checkSquareStochastic
,
exampleForest
,
exampleRand
,
MDP
from
mdp
import
check
,
checkSquareStochastic
,
exampleForest
,
exampleRand
,
MDP
from
mdp
import
PolicyIteration
,
RelativeValueIteration
,
ValueIteration
from
mdp
import
PolicyIteration
,
QLearning
,
RelativeValueIteration
from
mdp
import
ValueIterationGS
from
mdp
import
ValueIteration
,
ValueIterationGS
from
numpy
import
absolute
,
array
,
eye
,
matrix
,
zeros
from
numpy
import
absolute
,
array
,
eye
,
matrix
,
zeros
from
numpy.random
import
rand
from
numpy.random
import
rand
...
@@ -279,7 +279,18 @@ def test_PolicyIteration_matrix_exampleForest():
...
@@ -279,7 +279,18 @@ def test_PolicyIteration_matrix_exampleForest():
# QLearning
# QLearning
def
test_QLearning_exampleForest
():
def
test_QLearning_exampleForest
():
pass
a
=
QLearning
(
Pf
,
Rf
,
0.9
)
q
=
matrix
(
'26.1841860892231 18.6273657021260; '
\
'29.5880960371007 18.5901207622881; '
\
'33.3526406657418 25.2621054631519'
)
v
=
matrix
(
'26.1841860892231 29.5880960371007 33.3526406657418'
)
p
=
matrix
(
'0 0 0'
)
itr
=
0
a
.
iterate
()
assert
(
absolute
(
a
.
Q
-
q
)
<
SMALLNUM
).
all
()
assert
(
absolute
(
array
(
a
.
V
)
-
v
)
<
SMALLNUM
).
all
()
assert
(
array
(
a
.
policy
)
==
p
).
all
()
assert
a
.
iter
==
itr
# RelativeValueIteration
# RelativeValueIteration
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment