Commit e8854225 authored by Steven Cordwell's avatar Steven Cordwell
Browse files

use a try-execpt clause to allow sparse matrices to be used with PolicyIteration

parent c5adb9ea
......@@ -606,7 +606,10 @@ class PolicyIteration(MDP):
ind = (self.policy == aa).nonzero()[0]
# if no rows use action a, then no need to assign this
if ind.size > 0:
Ppolicy[ind, :] = self.P[aa][ind, :]
try:
Ppolicy[ind, :] = self.P[aa][ind, :]
except ValueError:
Ppolicy[ind, :] = self.P[aa][ind, :].todense()
#PR = self._computePR() # an apparently uneeded line, and
# perhaps harmful in this implementation c.f.
# mdp_computePpolicyPRpolicy.m
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment