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

use empty to initialise Q in Bellman operator, and remove matrix() as it doesn't need this

parent 58335770
......@@ -96,8 +96,8 @@ from math import ceil, log, sqrt
from random import randint, random
from time import time
from numpy import absolute, array, diag, matrix, mean, mod, multiply, ndarray
from numpy import ones, zeros
from numpy import absolute, array, empty, diag, matrix, mean, mod, multiply
from numpy import ndarray, ones, zeros
from numpy.random import rand
from scipy.sparse import csr_matrix as sparse
......@@ -335,7 +335,7 @@ def checkSquareStochastic(Z):
Z : array
Z : matrix
This should be a two dimensional array with a shape of (S, S). It can
possibly be sparse.
......@@ -717,7 +717,7 @@ class MDP(object):
except AttributeError:
raise TypeError("bellman: V must be a numpy array or matrix.")
Q = matrix(zeros((self.S, self.A)))
Q = empty((self.S, self.A))
for aa in range(self.A):
Q[:, aa] = self.R[:, aa] + ( * self.P[aa] * V)
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