diff --git a/MANIFEST.in b/MANIFEST.in index 7675331a..f0f5e423 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -10,9 +10,9 @@ include ./pomdp_py/representations/distribution/histogram.pxd include ./pomdp_py/framework/planner.pxd include ./pomdp_py/framework/basics.pxd include ./pomdp_py/framework/oopomdp.pxd -include ./pomdp_problems/rocksample/cythonize/rocksample_problem.pyx -include ./pomdp_problems/tiger/cythonize/tiger_problem.pyx include ./pomdp_py/utils/cython_utils.pyx +include ./pomdp_py/problems/rocksample/cythonize/rocksample_problem.pyx +include ./pomdp_py/problems/tiger/cythonize/tiger_problem.pyx include ./pomdp_py/algorithms/value_iteration.pyx include ./pomdp_py/algorithms/pomcp.pyx include ./pomdp_py/algorithms/po_rollout.pyx diff --git a/pomdp_py/problems/multi_object_search/domain/action.py b/pomdp_py/problems/multi_object_search/domain/action.py index bbb41d16..cf7bcf35 100644 --- a/pomdp_py/problems/multi_object_search/domain/action.py +++ b/pomdp_py/problems/multi_object_search/domain/action.py @@ -168,8 +168,8 @@ def __init__(self): Find = FindAction() if MOTION_SCHEME == "xy": - ALL_MOTION_ACTIONS = {MoveEast, MoveWest, MoveNorth, MoveSouth} + ALL_MOTION_ACTIONS = [MoveEast, MoveWest, MoveNorth, MoveSouth] elif MOTION_SCHEME == "vw": - ALL_MOTION_ACTIONS = {MoveForward, MoveBackward, MoveLeft, MoveRight} + ALL_MOTION_ACTIONS = [MoveForward, MoveBackward, MoveLeft, MoveRight] else: raise ValueError("motion scheme '%s' is invalid" % MOTION_SCHEME) diff --git a/pomdp_py/problems/multi_object_search/models/policy_model.py b/pomdp_py/problems/multi_object_search/models/policy_model.py index f59a0118..9baae3da 100644 --- a/pomdp_py/problems/multi_object_search/models/policy_model.py +++ b/pomdp_py/problems/multi_object_search/models/policy_model.py @@ -34,17 +34,17 @@ def get_all_actions(self, state=None, history=None): last_action = history[-1][0] if isinstance(last_action, LookAction): can_find = True - find_action = set({Find}) if can_find else set({}) + find_action = [Find] if can_find else [] if state is None: - return ALL_MOTION_ACTIONS | {Look} | find_action + return ALL_MOTION_ACTIONS + [Look] + find_action else: if self._grid_map is not None: valid_motions = self._grid_map.valid_motions( self.robot_id, state.pose(self.robot_id), ALL_MOTION_ACTIONS ) - return valid_motions | {Look} | find_action + return list(valid_motions) + [Look] + find_action else: - return ALL_MOTION_ACTIONS | {Look} | find_action + return ALL_MOTION_ACTIONS + [Look] + find_action def rollout(self, state, history=None): return random.sample(self.get_all_actions(state=state, history=history), 1)[0] diff --git a/pomdp_py/problems/multi_object_search/problem.py b/pomdp_py/problems/multi_object_search/problem.py index b3926b89..9b4aec48 100644 --- a/pomdp_py/problems/multi_object_search/problem.py +++ b/pomdp_py/problems/multi_object_search/problem.py @@ -209,7 +209,7 @@ def solve( visualize (bool) if True, show the pygame visualization. """ - random_objid = random.sample(problem.env.target_objects, 1)[0] + random_objid = random.sample(sorted(problem.env.target_objects), 1)[0] random_object_belief = problem.agent.belief.object_beliefs[random_objid] if isinstance(random_object_belief, pomdp_py.Histogram): # Use POUCT diff --git a/pomdp_py/problems/rocksample/rocksample_problem.py b/pomdp_py/problems/rocksample/rocksample_problem.py index c02d5efe..2db7e90d 100644 --- a/pomdp_py/problems/rocksample/rocksample_problem.py +++ b/pomdp_py/problems/rocksample/rocksample_problem.py @@ -345,7 +345,7 @@ def argmax(self, state, normalized=False, **kwargs): def get_all_actions(self, **kwargs): state = kwargs.get("state", None) if state is None: - return self._all_actions + return list(self._all_actions) else: motions = set(self._all_actions) rover_x, rover_y = state.position @@ -355,7 +355,7 @@ def get_all_actions(self, **kwargs): motions.remove(MoveNorth) if rover_y == self._n - 1: motions.remove(MoveSouth) - return motions | self._other_actions + return list(motions | self._other_actions) def rollout(self, state, history=None): return random.sample(self.get_all_actions(state=state), 1)[0] @@ -529,7 +529,7 @@ def main(): print("*** Testing POMCP ***") pomcp = pomdp_py.POMCP( - max_depth=20, + max_depth=12, discount_factor=0.95, num_sims=10000, exploration_const=20, diff --git a/pomdp_py/representations/distribution/gaussian.pyx b/pomdp_py/representations/distribution/gaussian.pyx index 8fd18c0d..b4cbc7a7 100644 --- a/pomdp_py/representations/distribution/gaussian.pyx +++ b/pomdp_py/representations/distribution/gaussian.pyx @@ -2,7 +2,7 @@ from pomdp_py.framework.basics cimport GenerativeDistribution import numpy as np # Check if scipy exists -import importlib +import importlib.util scipy_spec = importlib.util.find_spec("scipy") if scipy_spec is not None: from scipy.linalg import sqrtm diff --git a/tests/test_conversion_pomdp-solve.py b/tests/test_conversion_pomdp-solve.py index 4023b76b..efaf7bc9 100644 --- a/tests/test_conversion_pomdp-solve.py +++ b/tests/test_conversion_pomdp-solve.py @@ -3,6 +3,7 @@ import os import io import sys +import glob import pomdp_py import subprocess import inspect