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
1ffe678e
Commit
1ffe678e
authored
May 17, 2013
by
Steven Cordwell
Browse files
create reward arrays in the sqlite database
parent
9149df88
Changes
1
Hide whitespace changes
Inline
Side-by-side
mdp.py
View file @
1ffe678e
...
...
@@ -548,13 +548,20 @@ def exampleRand(S, A, is_sparse=False, is_sqlite=False, mask=None):
conn
=
sqlite3
.
connect
(
"transition.db"
)
with
conn
:
c
=
conn
.
cursor
()
c
.
executescript
(
'''
c
md
=
'''
CREATE TABLE info (name TEXT, value INTEGER);
INSERT INTO info VALUES('states', %s);
INSERT INTO info VALUES('actions', %s);'''
%
(
S
,
A
))
INSERT INTO info VALUES('actions', %s);'''
%
(
S
,
A
)
c
.
executescript
(
cmd
)
for
a
in
range
(
A
):
c
.
execute
(
"CREATE TABLE transition%s (row INTEGER, col "
\
"INTEGER, val REAL)"
%
a
)
cmd
=
'''
CREATE TABLE transition%s (row INTEGER, "col INTEGER,
val REAL);
CREATE TABLE reward%s (val REAL);'''
%
(
a
,
a
)
c
.
executescript
(
cmd
)
reward
=
rand
(
S
).
tolist
()
cmd
=
"INSERT INTO reward%s VALUES(?)"
%
a
c
.
executemany
(
cmd
,
reward
)
for
s
in
xrange
(
S
):
n
=
randint
(
1
,
S
//
3
)
row
=
(
s
*
ones
(
n
,
dtype
=
int
)).
tolist
()
...
...
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