Skip to content

Commit 606fae7

Browse files
authored
Hotfix (#49)
* hotfix * hotfox (needed by python3.12) * random sample only works on sequences after >py3.9 * manifest * random sample needs sequence (in rocksample)
1 parent 767d523 commit 606fae7

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ include ./pomdp_py/representations/distribution/histogram.pxd
1010
include ./pomdp_py/framework/planner.pxd
1111
include ./pomdp_py/framework/basics.pxd
1212
include ./pomdp_py/framework/oopomdp.pxd
13-
include ./pomdp_problems/rocksample/cythonize/rocksample_problem.pyx
14-
include ./pomdp_problems/tiger/cythonize/tiger_problem.pyx
1513
include ./pomdp_py/utils/cython_utils.pyx
14+
include ./pomdp_py/problems/rocksample/cythonize/rocksample_problem.pyx
15+
include ./pomdp_py/problems/tiger/cythonize/tiger_problem.pyx
1616
include ./pomdp_py/algorithms/value_iteration.pyx
1717
include ./pomdp_py/algorithms/pomcp.pyx
1818
include ./pomdp_py/algorithms/po_rollout.pyx

pomdp_py/problems/multi_object_search/domain/action.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ def __init__(self):
168168
Find = FindAction()
169169

170170
if MOTION_SCHEME == "xy":
171-
ALL_MOTION_ACTIONS = {MoveEast, MoveWest, MoveNorth, MoveSouth}
171+
ALL_MOTION_ACTIONS = [MoveEast, MoveWest, MoveNorth, MoveSouth]
172172
elif MOTION_SCHEME == "vw":
173-
ALL_MOTION_ACTIONS = {MoveForward, MoveBackward, MoveLeft, MoveRight}
173+
ALL_MOTION_ACTIONS = [MoveForward, MoveBackward, MoveLeft, MoveRight]
174174
else:
175175
raise ValueError("motion scheme '%s' is invalid" % MOTION_SCHEME)

pomdp_py/problems/multi_object_search/models/policy_model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ def get_all_actions(self, state=None, history=None):
3434
last_action = history[-1][0]
3535
if isinstance(last_action, LookAction):
3636
can_find = True
37-
find_action = set({Find}) if can_find else set({})
37+
find_action = [Find] if can_find else []
3838
if state is None:
39-
return ALL_MOTION_ACTIONS | {Look} | find_action
39+
return ALL_MOTION_ACTIONS + [Look] + find_action
4040
else:
4141
if self._grid_map is not None:
4242
valid_motions = self._grid_map.valid_motions(
4343
self.robot_id, state.pose(self.robot_id), ALL_MOTION_ACTIONS
4444
)
45-
return valid_motions | {Look} | find_action
45+
return list(valid_motions) + [Look] + find_action
4646
else:
47-
return ALL_MOTION_ACTIONS | {Look} | find_action
47+
return ALL_MOTION_ACTIONS + [Look] + find_action
4848

4949
def rollout(self, state, history=None):
5050
return random.sample(self.get_all_actions(state=state, history=history), 1)[0]

pomdp_py/problems/multi_object_search/problem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def solve(
209209
visualize (bool) if True, show the pygame visualization.
210210
"""
211211

212-
random_objid = random.sample(problem.env.target_objects, 1)[0]
212+
random_objid = random.sample(sorted(problem.env.target_objects), 1)[0]
213213
random_object_belief = problem.agent.belief.object_beliefs[random_objid]
214214
if isinstance(random_object_belief, pomdp_py.Histogram):
215215
# Use POUCT

pomdp_py/problems/rocksample/rocksample_problem.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def argmax(self, state, normalized=False, **kwargs):
345345
def get_all_actions(self, **kwargs):
346346
state = kwargs.get("state", None)
347347
if state is None:
348-
return self._all_actions
348+
return list(self._all_actions)
349349
else:
350350
motions = set(self._all_actions)
351351
rover_x, rover_y = state.position
@@ -355,7 +355,7 @@ def get_all_actions(self, **kwargs):
355355
motions.remove(MoveNorth)
356356
if rover_y == self._n - 1:
357357
motions.remove(MoveSouth)
358-
return motions | self._other_actions
358+
return list(motions | self._other_actions)
359359

360360
def rollout(self, state, history=None):
361361
return random.sample(self.get_all_actions(state=state), 1)[0]
@@ -529,7 +529,7 @@ def main():
529529

530530
print("*** Testing POMCP ***")
531531
pomcp = pomdp_py.POMCP(
532-
max_depth=20,
532+
max_depth=12,
533533
discount_factor=0.95,
534534
num_sims=10000,
535535
exploration_const=20,

pomdp_py/representations/distribution/gaussian.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from pomdp_py.framework.basics cimport GenerativeDistribution
22
import numpy as np
33

44
# Check if scipy exists
5-
import importlib
5+
import importlib.util
66
scipy_spec = importlib.util.find_spec("scipy")
77
if scipy_spec is not None:
88
from scipy.linalg import sqrtm

tests/test_conversion_pomdp-solve.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import io
55
import sys
6+
import glob
67
import pomdp_py
78
import subprocess
89
import inspect

0 commit comments

Comments
 (0)