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
fa69c0d3
Commit
fa69c0d3
authored
Jan 24, 2013
by
Steven Cordwell
Browse files
moved linear algebra solver import for PolicyIteration class
parent
ff3cabc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
mdp.py
View file @
fa69c0d3
...
...
@@ -784,7 +784,8 @@ class PolicyIteration(MDP):
# initialise the policy to the one which maximises the expected
# immediate reward
self
.
value
=
matrix
(
zeros
((
self
.
S
,
1
)))
self
.
bellmanOperator
()
self
.
policy
,
null
=
self
.
bellmanOperator
()
del
null
else
:
policy0
=
array
(
policy0
)
...
...
@@ -802,6 +803,8 @@ class PolicyIteration(MDP):
self
.
value
=
matrix
(
zeros
((
self
.
S
,
1
)))
if
eval_type
in
(
0
,
"matrix"
):
from
numpy.linalg
import
solve
self
.
lin_eq
=
solve
self
.
eval_type
=
"matrix"
elif
eval_type
in
(
1
,
"iterative"
):
self
.
eval_type
=
"iterative"
...
...
@@ -890,11 +893,10 @@ class PolicyIteration(MDP):
----------
Vpolicy(S) = value function of the policy
"""
from
numpy.linalg
import
solve
as
lin_eq
Ppolicy
,
PRpolicy
=
self
.
computePpolicyPRpolicy
(
self
.
P
,
self
.
R
,
self
.
policy
)
# V = PR + gPV => (I-gP)V = PR => V = inv(I-gP)* PR
self
.
value
=
lin_eq
((
speye
(
self
.
S
,
self
.
S
)
-
self
.
discount
*
Ppolicy
)
,
PRpolicy
)
self
.
value
=
self
.
lin_eq
((
speye
(
self
.
S
,
self
.
S
)
-
self
.
discount
*
Ppolicy
)
,
PRpolicy
)
def
iterate
(
self
):
""""""
...
...
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