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
bfb2d6cb
Commit
bfb2d6cb
authored
Mar 10, 2014
by
Steven Cordwell
Browse files
allow reward to be specified as a 1-d vector
parent
e25e076b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/mdptoolbox/mdp.py
View file @
bfb2d6cb
...
...
@@ -231,15 +231,22 @@ class MDP(object):
# Set self.R as a tuple of length A, with each element storing an 1×S
# vector.
try
:
if
R
.
ndim
==
2
:
if
R
.
ndim
==
1
:
r
=
array
(
R
).
reshape
(
self
.
S
)
self
.
R
=
tuple
([
r
for
aa
in
range
(
self
.
A
)])
elif
R
.
ndim
==
2
:
self
.
R
=
tuple
([
array
(
R
[:,
aa
]).
reshape
(
self
.
S
)
for
aa
in
range
(
self
.
A
)])
else
:
self
.
R
=
tuple
([
multiply
(
P
[
aa
],
R
[
aa
]).
sum
(
1
).
reshape
(
self
.
S
)
for
aa
in
range
(
self
.
A
)])
except
AttributeError
:
self
.
R
=
tuple
([
multiply
(
P
[
aa
],
R
[
aa
]).
sum
(
1
).
reshape
(
self
.
S
)
for
aa
in
range
(
self
.
A
)])
if
len
(
R
)
==
self
.
A
:
self
.
R
=
tuple
([
multiply
(
P
[
aa
],
R
[
aa
]).
sum
(
1
).
reshape
(
self
.
S
)
for
aa
in
range
(
self
.
A
)])
else
:
r
=
array
(
R
).
reshape
(
self
.
S
)
self
.
R
=
tuple
([
r
for
aa
in
range
(
self
.
A
)])
def
run
(
self
):
# Raise error because child classes should implement this function.
...
...
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