POMDPPlanners 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. POMDPPlanners/__init__.py +3 -0
  2. POMDPPlanners/configs/__init__.py +4 -0
  3. POMDPPlanners/configs/environment_configs.py +532 -0
  4. POMDPPlanners/configs/experiment_configs.py +474 -0
  5. POMDPPlanners/configs/planners_hyperparam_configs.py +343 -0
  6. POMDPPlanners/core/__init__.py +1 -0
  7. POMDPPlanners/core/belief/__init__.py +56 -0
  8. POMDPPlanners/core/belief/base_belief.py +145 -0
  9. POMDPPlanners/core/belief/belief_utils.py +118 -0
  10. POMDPPlanners/core/belief/gaussian_belief.py +182 -0
  11. POMDPPlanners/core/belief/gaussian_belief_updaters.py +347 -0
  12. POMDPPlanners/core/belief/gaussian_mixture_belief.py +287 -0
  13. POMDPPlanners/core/belief/particle_beliefs.py +830 -0
  14. POMDPPlanners/core/belief/vectorized_particle_belief_updater.py +59 -0
  15. POMDPPlanners/core/belief/vectorized_weighted_particle_belief.py +225 -0
  16. POMDPPlanners/core/config_types.py +117 -0
  17. POMDPPlanners/core/cost.py +247 -0
  18. POMDPPlanners/core/distributions.py +150 -0
  19. POMDPPlanners/core/environment.py +946 -0
  20. POMDPPlanners/core/policy.py +681 -0
  21. POMDPPlanners/core/serialization.py +385 -0
  22. POMDPPlanners/core/simulation/__init__.py +38 -0
  23. POMDPPlanners/core/simulation/history.py +204 -0
  24. POMDPPlanners/core/simulation/hyperparameter_tuning.py +479 -0
  25. POMDPPlanners/core/simulation/metrics.py +8 -0
  26. POMDPPlanners/core/simulation/simulation_configs.py +158 -0
  27. POMDPPlanners/core/simulation/tasks.py +343 -0
  28. POMDPPlanners/core/tree.py +170 -0
  29. POMDPPlanners/environments/__init__.py +134 -0
  30. POMDPPlanners/environments/cartpole_pomdp.py +445 -0
  31. POMDPPlanners/environments/cartpole_pomdp_beliefs.py +291 -0
  32. POMDPPlanners/environments/cartpole_pomdp_gaussian_beliefs.py +255 -0
  33. POMDPPlanners/environments/laser_tag_pomdp/__init__.py +27 -0
  34. POMDPPlanners/environments/laser_tag_pomdp/continuous_laser_tag_geometry.py +439 -0
  35. POMDPPlanners/environments/laser_tag_pomdp/continuous_laser_tag_pomdp.py +861 -0
  36. POMDPPlanners/environments/laser_tag_pomdp/continuous_laser_tag_visualizer.py +565 -0
  37. POMDPPlanners/environments/laser_tag_pomdp/laser_tag_pomdp.py +1176 -0
  38. POMDPPlanners/environments/laser_tag_pomdp/laser_tag_pomdp_beliefs/__init__.py +19 -0
  39. POMDPPlanners/environments/laser_tag_pomdp/laser_tag_pomdp_beliefs/continuous_laser_tag_belief_factory.py +76 -0
  40. POMDPPlanners/environments/laser_tag_pomdp/laser_tag_pomdp_beliefs/continuous_laser_tag_vectorized_updater.py +309 -0
  41. POMDPPlanners/environments/laser_tag_pomdp/laser_tag_pomdp_beliefs/laser_tag_belief_factory.py +68 -0
  42. POMDPPlanners/environments/laser_tag_pomdp/laser_tag_pomdp_beliefs/laser_tag_vectorized_updater.py +440 -0
  43. POMDPPlanners/environments/laser_tag_pomdp/laser_tag_visualizer.py +549 -0
  44. POMDPPlanners/environments/light_dark_pomdp/__init__.py +0 -0
  45. POMDPPlanners/environments/light_dark_pomdp/continuous_light_dark_pomdp.py +687 -0
  46. POMDPPlanners/environments/light_dark_pomdp/discrete_light_dark_pomdp.py +367 -0
  47. POMDPPlanners/environments/light_dark_pomdp/light_dark_pomdp_beliefs/__init__.py +17 -0
  48. POMDPPlanners/environments/light_dark_pomdp/light_dark_pomdp_beliefs/continuous_light_dark_belief_factory.py +104 -0
  49. POMDPPlanners/environments/light_dark_pomdp/light_dark_pomdp_beliefs/continuous_light_dark_gaussian_beliefs.py +141 -0
  50. POMDPPlanners/environments/light_dark_pomdp/light_dark_pomdp_beliefs/continuous_light_dark_vectorized_updater.py +242 -0
  51. POMDPPlanners/environments/light_dark_pomdp/light_dark_pomdp_utils/__init__.py +0 -0
  52. POMDPPlanners/environments/light_dark_pomdp/light_dark_pomdp_utils/base_light_dark_pomdp.py +441 -0
  53. POMDPPlanners/environments/light_dark_pomdp/light_dark_pomdp_utils/light_dark_observation_models.py +582 -0
  54. POMDPPlanners/environments/light_dark_pomdp/light_dark_pomdp_utils/light_dark_reward_models.py +188 -0
  55. POMDPPlanners/environments/light_dark_pomdp/light_dark_pomdp_utils/light_dark_visualizer.py +327 -0
  56. POMDPPlanners/environments/mountain_car_pomdp.py +388 -0
  57. POMDPPlanners/environments/mountain_car_pomdp_beliefs.py +254 -0
  58. POMDPPlanners/environments/mountain_car_pomdp_gaussian_beliefs.py +205 -0
  59. POMDPPlanners/environments/pacman_pomdp/__init__.py +17 -0
  60. POMDPPlanners/environments/pacman_pomdp/pacman_pomdp.py +1356 -0
  61. POMDPPlanners/environments/pacman_pomdp/pacman_visualizer.py +304 -0
  62. POMDPPlanners/environments/push_pomdp/__init__.py +43 -0
  63. POMDPPlanners/environments/push_pomdp/continuous_push_geometry.py +307 -0
  64. POMDPPlanners/environments/push_pomdp/continuous_push_pomdp.py +688 -0
  65. POMDPPlanners/environments/push_pomdp/continuous_push_pomdp_visualizer.py +567 -0
  66. POMDPPlanners/environments/push_pomdp/push_pomdp.py +777 -0
  67. POMDPPlanners/environments/push_pomdp/push_pomdp_beliefs/__init__.py +19 -0
  68. POMDPPlanners/environments/push_pomdp/push_pomdp_beliefs/continuous_push_belief_factory.py +69 -0
  69. POMDPPlanners/environments/push_pomdp/push_pomdp_beliefs/continuous_push_vectorized_updater.py +237 -0
  70. POMDPPlanners/environments/push_pomdp/push_pomdp_beliefs/push_belief_factory.py +66 -0
  71. POMDPPlanners/environments/push_pomdp/push_pomdp_beliefs/push_vectorized_updater.py +216 -0
  72. POMDPPlanners/environments/push_pomdp/push_pomdp_visualizer.py +486 -0
  73. POMDPPlanners/environments/rock_sample_pomdp/__init__.py +40 -0
  74. POMDPPlanners/environments/rock_sample_pomdp/rock_sample_pomdp.py +649 -0
  75. POMDPPlanners/environments/rock_sample_pomdp/rock_sample_visualizer.py +383 -0
  76. POMDPPlanners/environments/safety_ant_velocity_pomdp/__init__.py +21 -0
  77. POMDPPlanners/environments/safety_ant_velocity_pomdp/safety_ant_velocity_pomdp.py +590 -0
  78. POMDPPlanners/environments/safety_ant_velocity_pomdp/safety_ant_velocity_pomdp_beliefs/__init__.py +11 -0
  79. POMDPPlanners/environments/safety_ant_velocity_pomdp/safety_ant_velocity_pomdp_beliefs/safety_ant_velocity_belief_factory.py +70 -0
  80. POMDPPlanners/environments/safety_ant_velocity_pomdp/safety_ant_velocity_pomdp_beliefs/safety_ant_velocity_vectorized_updater.py +172 -0
  81. POMDPPlanners/environments/safety_ant_velocity_pomdp/safety_ant_velocity_visualizer.py +364 -0
  82. POMDPPlanners/environments/sanity_pomdp.py +354 -0
  83. POMDPPlanners/environments/tiger_pomdp.py +362 -0
  84. POMDPPlanners/planners/__init__.py +85 -0
  85. POMDPPlanners/planners/mcts_planners/__init__.py +1 -0
  86. POMDPPlanners/planners/mcts_planners/beta_zero/__init__.py +48 -0
  87. POMDPPlanners/planners/mcts_planners/beta_zero/belief_representation.py +156 -0
  88. POMDPPlanners/planners/mcts_planners/beta_zero/beta_zero.py +795 -0
  89. POMDPPlanners/planners/mcts_planners/beta_zero/beta_zero_action_sampler.py +150 -0
  90. POMDPPlanners/planners/mcts_planners/beta_zero/beta_zero_network.py +332 -0
  91. POMDPPlanners/planners/mcts_planners/beta_zero/puct.py +128 -0
  92. POMDPPlanners/planners/mcts_planners/beta_zero/training.py +212 -0
  93. POMDPPlanners/planners/mcts_planners/beta_zero/training_buffer.py +143 -0
  94. POMDPPlanners/planners/mcts_planners/constrained_zero/__init__.py +37 -0
  95. POMDPPlanners/planners/mcts_planners/constrained_zero/constrained_puct.py +138 -0
  96. POMDPPlanners/planners/mcts_planners/constrained_zero/constrained_training.py +213 -0
  97. POMDPPlanners/planners/mcts_planners/constrained_zero/constrained_training_buffer.py +102 -0
  98. POMDPPlanners/planners/mcts_planners/constrained_zero/constrained_zero.py +533 -0
  99. POMDPPlanners/planners/mcts_planners/constrained_zero/constrained_zero_network.py +182 -0
  100. POMDPPlanners/planners/mcts_planners/icvar_pft_dpw.py +230 -0
  101. POMDPPlanners/planners/mcts_planners/icvar_pomcpow.py +361 -0
  102. POMDPPlanners/planners/mcts_planners/pft_dpw.py +310 -0
  103. POMDPPlanners/planners/mcts_planners/pomcp.py +247 -0
  104. POMDPPlanners/planners/mcts_planners/pomcp_dpw.py +299 -0
  105. POMDPPlanners/planners/mcts_planners/pomcpow.py +296 -0
  106. POMDPPlanners/planners/mcts_planners/sparse_pft.py +273 -0
  107. POMDPPlanners/planners/open_loop_planners/__init__.py +0 -0
  108. POMDPPlanners/planners/open_loop_planners/discrete_action_sequences_planner.py +149 -0
  109. POMDPPlanners/planners/planners_utils/__init__.py +0 -0
  110. POMDPPlanners/planners/planners_utils/cvar_exploration.py +94 -0
  111. POMDPPlanners/planners/planners_utils/cvar_progressive_widening.py +47 -0
  112. POMDPPlanners/planners/planners_utils/dpw.py +553 -0
  113. POMDPPlanners/planners/planners_utils/path_simulations_policy.py +407 -0
  114. POMDPPlanners/planners/planners_utils/rollout.py +78 -0
  115. POMDPPlanners/planners/sparse_sampling_planners/__init__.py +0 -0
  116. POMDPPlanners/planners/sparse_sampling_planners/icvar_sparse_sampling.py +132 -0
  117. POMDPPlanners/planners/sparse_sampling_planners/sparse_sampling.py +267 -0
  118. POMDPPlanners/simulations/__init__.py +31 -0
  119. POMDPPlanners/simulations/episodes.py +333 -0
  120. POMDPPlanners/simulations/hyper_parameter_tuning_simulations.py +844 -0
  121. POMDPPlanners/simulations/simulation_apis/__init__.py +0 -0
  122. POMDPPlanners/simulations/simulation_apis/dask_simulations_api.py +686 -0
  123. POMDPPlanners/simulations/simulation_apis/local_simulations_api.py +927 -0
  124. POMDPPlanners/simulations/simulation_apis/pbs_simulations_api.py +740 -0
  125. POMDPPlanners/simulations/simulation_apis/simulations_api_interface.py +364 -0
  126. POMDPPlanners/simulations/simulation_statistics.py +611 -0
  127. POMDPPlanners/simulations/simulations_deployment/__init__.py +152 -0
  128. POMDPPlanners/simulations/simulations_deployment/cache_dbs.py +93 -0
  129. POMDPPlanners/simulations/simulations_deployment/task_manager_configs.py +93 -0
  130. POMDPPlanners/simulations/simulations_deployment/task_managers.py +743 -0
  131. POMDPPlanners/simulations/simulations_deployment/tasks/__init__.py +13 -0
  132. POMDPPlanners/simulations/simulations_deployment/tasks/episode_simulation_task.py +586 -0
  133. POMDPPlanners/simulations/simulations_deployment/tasks/hyper_parameter_tuning_simulation_task.py +1050 -0
  134. POMDPPlanners/simulations/simulator.py +1218 -0
  135. POMDPPlanners/simulations/workflows/__init__.py +33 -0
  136. POMDPPlanners/simulations/workflows/evaluation.py +299 -0
  137. POMDPPlanners/simulations/workflows/hyperparameter_tuning_evaluation_workflows.py +516 -0
  138. POMDPPlanners/simulations/workflows/integrated.py +321 -0
  139. POMDPPlanners/simulations/workflows/optimization.py +458 -0
  140. POMDPPlanners/simulations/workflows/planner_evaluation_workflow.py +299 -0
  141. POMDPPlanners/tests/__init__.py +1 -0
  142. POMDPPlanners/tests/conftest.py +110 -0
  143. POMDPPlanners/tests/test_configs/__init__.py +0 -0
  144. POMDPPlanners/tests/test_configs/test_environment_configs.py +597 -0
  145. POMDPPlanners/tests/test_configs/test_experiment_configs.py +1756 -0
  146. POMDPPlanners/tests/test_configs/test_planners_hyperparam_configs.py +741 -0
  147. POMDPPlanners/tests/test_core/__init__.py +0 -0
  148. POMDPPlanners/tests/test_core/test_belief/__init__.py +0 -0
  149. POMDPPlanners/tests/test_core/test_belief/test_base.py +384 -0
  150. POMDPPlanners/tests/test_core/test_belief/test_belief_environment_integration.py +652 -0
  151. POMDPPlanners/tests/test_core/test_belief/test_belief_utils.py +417 -0
  152. POMDPPlanners/tests/test_core/test_belief/test_gaussian_belief.py +630 -0
  153. POMDPPlanners/tests/test_core/test_belief/test_gaussian_belief_updaters.py +692 -0
  154. POMDPPlanners/tests/test_core/test_belief/test_gaussian_mixture_belief.py +712 -0
  155. POMDPPlanners/tests/test_core/test_belief/test_particle_beliefs.py +2772 -0
  156. POMDPPlanners/tests/test_core/test_belief/test_vectorized_weighted_particle_belief.py +397 -0
  157. POMDPPlanners/tests/test_core/test_cost.py +731 -0
  158. POMDPPlanners/tests/test_core/test_distributions.py +188 -0
  159. POMDPPlanners/tests/test_core/test_environment.py +478 -0
  160. POMDPPlanners/tests/test_core/test_hyper_parameter_tuning.py +1753 -0
  161. POMDPPlanners/tests/test_core/test_policy.py +356 -0
  162. POMDPPlanners/tests/test_core/test_serialization.py +956 -0
  163. POMDPPlanners/tests/test_core/test_simulation.py +341 -0
  164. POMDPPlanners/tests/test_core/test_simulation_configs.py +706 -0
  165. POMDPPlanners/tests/test_core/test_tree.py +706 -0
  166. POMDPPlanners/tests/test_environments/__init__.py +0 -0
  167. POMDPPlanners/tests/test_environments/test_cartpole_pomdp.py +755 -0
  168. POMDPPlanners/tests/test_environments/test_cartpole_pomdp_belief_factory.py +111 -0
  169. POMDPPlanners/tests/test_environments/test_cartpole_pomdp_beliefs.py +310 -0
  170. POMDPPlanners/tests/test_environments/test_cartpole_pomdp_gaussian_beliefs.py +617 -0
  171. POMDPPlanners/tests/test_environments/test_environment_serialization.py +754 -0
  172. POMDPPlanners/tests/test_environments/test_environment_visualizations_golden_files.py +958 -0
  173. POMDPPlanners/tests/test_environments/test_laser_tag_pomdp/__init__.py +6 -0
  174. POMDPPlanners/tests/test_environments/test_laser_tag_pomdp/test_continuous_laser_tag_geometry.py +342 -0
  175. POMDPPlanners/tests/test_environments/test_laser_tag_pomdp/test_continuous_laser_tag_pomdp.py +1002 -0
  176. POMDPPlanners/tests/test_environments/test_laser_tag_pomdp/test_continuous_laser_tag_visualizer.py +136 -0
  177. POMDPPlanners/tests/test_environments/test_laser_tag_pomdp/test_laser_tag_pomdp.py +2054 -0
  178. POMDPPlanners/tests/test_environments/test_laser_tag_pomdp/test_laser_tag_pomdp_beliefs/__init__.py +0 -0
  179. POMDPPlanners/tests/test_environments/test_laser_tag_pomdp/test_laser_tag_pomdp_beliefs/test_continuous_laser_tag_belief_factory.py +140 -0
  180. POMDPPlanners/tests/test_environments/test_laser_tag_pomdp/test_laser_tag_pomdp_beliefs/test_continuous_laser_tag_vectorized_updater.py +296 -0
  181. POMDPPlanners/tests/test_environments/test_laser_tag_pomdp/test_laser_tag_pomdp_beliefs/test_laser_tag_belief_factory.py +97 -0
  182. POMDPPlanners/tests/test_environments/test_laser_tag_pomdp/test_laser_tag_pomdp_beliefs/test_laser_tag_vectorized_updater.py +603 -0
  183. POMDPPlanners/tests/test_environments/test_laser_tag_pomdp/test_laser_tag_visualizer.py +179 -0
  184. POMDPPlanners/tests/test_environments/test_light_dark_pomdp/__init__.py +0 -0
  185. POMDPPlanners/tests/test_environments/test_light_dark_pomdp/light_dark_pomdp_utils/__init__.py +0 -0
  186. POMDPPlanners/tests/test_environments/test_light_dark_pomdp/light_dark_pomdp_utils/test_light_dark_observation_models.py +2149 -0
  187. POMDPPlanners/tests/test_environments/test_light_dark_pomdp/light_dark_pomdp_utils/test_light_dark_reward_models.py +857 -0
  188. POMDPPlanners/tests/test_environments/test_light_dark_pomdp/test_continuous_light_dark_pomdp.py +2231 -0
  189. POMDPPlanners/tests/test_environments/test_light_dark_pomdp/test_discrete_light_dark_pomdp.py +1579 -0
  190. POMDPPlanners/tests/test_environments/test_light_dark_pomdp/test_light_dark_pomdp_beliefs/__init__.py +0 -0
  191. POMDPPlanners/tests/test_environments/test_light_dark_pomdp/test_light_dark_pomdp_beliefs/test_continuous_light_dark_belief_factory.py +188 -0
  192. POMDPPlanners/tests/test_environments/test_light_dark_pomdp/test_light_dark_pomdp_beliefs/test_continuous_light_dark_gaussian_beliefs.py +412 -0
  193. POMDPPlanners/tests/test_environments/test_light_dark_pomdp/test_light_dark_pomdp_beliefs/test_continuous_light_dark_vectorized_updater.py +506 -0
  194. POMDPPlanners/tests/test_environments/test_mountain_car_pomdp.py +1045 -0
  195. POMDPPlanners/tests/test_environments/test_mountain_car_pomdp_belief_factory.py +97 -0
  196. POMDPPlanners/tests/test_environments/test_mountain_car_pomdp_beliefs.py +345 -0
  197. POMDPPlanners/tests/test_environments/test_mountain_car_pomdp_gaussian_beliefs.py +623 -0
  198. POMDPPlanners/tests/test_environments/test_pacman_pomdp.py +1885 -0
  199. POMDPPlanners/tests/test_environments/test_push_pomdp/__init__.py +8 -0
  200. POMDPPlanners/tests/test_environments/test_push_pomdp/test_continuous_push_geometry.py +217 -0
  201. POMDPPlanners/tests/test_environments/test_push_pomdp/test_continuous_push_pomdp.py +648 -0
  202. POMDPPlanners/tests/test_environments/test_push_pomdp/test_push_pomdp.py +1249 -0
  203. POMDPPlanners/tests/test_environments/test_push_pomdp/test_push_pomdp_beliefs/__init__.py +0 -0
  204. POMDPPlanners/tests/test_environments/test_push_pomdp/test_push_pomdp_beliefs/test_continuous_push_belief_factory.py +111 -0
  205. POMDPPlanners/tests/test_environments/test_push_pomdp/test_push_pomdp_beliefs/test_continuous_push_vectorized_updater.py +157 -0
  206. POMDPPlanners/tests/test_environments/test_push_pomdp/test_push_pomdp_beliefs/test_push_belief_factory.py +97 -0
  207. POMDPPlanners/tests/test_environments/test_push_pomdp/test_push_pomdp_beliefs/test_push_vectorized_updater.py +548 -0
  208. POMDPPlanners/tests/test_environments/test_rock_sample_pomdp/__init__.py +6 -0
  209. POMDPPlanners/tests/test_environments/test_rock_sample_pomdp/test_rock_sample_pomdp.py +1282 -0
  210. POMDPPlanners/tests/test_environments/test_rock_sample_pomdp/test_rock_sample_visualizer.py +137 -0
  211. POMDPPlanners/tests/test_environments/test_safety_ant_velocity_pomdp/__init__.py +1 -0
  212. POMDPPlanners/tests/test_environments/test_safety_ant_velocity_pomdp/test_safety_ant_velocity_pomdp.py +954 -0
  213. POMDPPlanners/tests/test_environments/test_safety_ant_velocity_pomdp/test_safety_ant_velocity_pomdp_beliefs/__init__.py +1 -0
  214. POMDPPlanners/tests/test_environments/test_safety_ant_velocity_pomdp/test_safety_ant_velocity_pomdp_beliefs/test_safety_ant_velocity_belief_factory.py +101 -0
  215. POMDPPlanners/tests/test_environments/test_safety_ant_velocity_pomdp/test_safety_ant_velocity_pomdp_beliefs/test_safety_ant_velocity_vectorized_updater.py +368 -0
  216. POMDPPlanners/tests/test_environments/test_sanity_pomdp.py +853 -0
  217. POMDPPlanners/tests/test_environments/test_tiger_pomdp.py +696 -0
  218. POMDPPlanners/tests/test_examples/__init__.py +6 -0
  219. POMDPPlanners/tests/test_examples/test_notebook_examples.py +346 -0
  220. POMDPPlanners/tests/test_interfaces/__init__.py +6 -0
  221. POMDPPlanners/tests/test_interfaces/fixtures/__init__.py +5 -0
  222. POMDPPlanners/tests/test_interfaces/test_distributions.py +256 -0
  223. POMDPPlanners/tests/test_interfaces/test_observation_models.py +854 -0
  224. POMDPPlanners/tests/test_interfaces/test_state_transition_models.py +582 -0
  225. POMDPPlanners/tests/test_metric_consistency.py +238 -0
  226. POMDPPlanners/tests/test_metric_consistency_utils.py +178 -0
  227. POMDPPlanners/tests/test_planners/__init__.py +0 -0
  228. POMDPPlanners/tests/test_planners/test_mcts_planners/__init__.py +0 -0
  229. POMDPPlanners/tests/test_planners/test_mcts_planners/test_beta_zero/__init__.py +0 -0
  230. POMDPPlanners/tests/test_planners/test_mcts_planners/test_beta_zero/test_belief_representation.py +210 -0
  231. POMDPPlanners/tests/test_planners/test_mcts_planners/test_beta_zero/test_beta_zero.py +537 -0
  232. POMDPPlanners/tests/test_planners/test_mcts_planners/test_beta_zero/test_beta_zero_action_sampler.py +380 -0
  233. POMDPPlanners/tests/test_planners/test_mcts_planners/test_beta_zero/test_beta_zero_network.py +270 -0
  234. POMDPPlanners/tests/test_planners/test_mcts_planners/test_beta_zero/test_puct.py +265 -0
  235. POMDPPlanners/tests/test_planners/test_mcts_planners/test_beta_zero/test_training.py +229 -0
  236. POMDPPlanners/tests/test_planners/test_mcts_planners/test_beta_zero/test_training_buffer.py +245 -0
  237. POMDPPlanners/tests/test_planners/test_mcts_planners/test_constrained_zero/__init__.py +0 -0
  238. POMDPPlanners/tests/test_planners/test_mcts_planners/test_constrained_zero/test_constrained_puct.py +312 -0
  239. POMDPPlanners/tests/test_planners/test_mcts_planners/test_constrained_zero/test_constrained_training.py +322 -0
  240. POMDPPlanners/tests/test_planners/test_mcts_planners/test_constrained_zero/test_constrained_training_buffer.py +212 -0
  241. POMDPPlanners/tests/test_planners/test_mcts_planners/test_constrained_zero/test_constrained_zero.py +544 -0
  242. POMDPPlanners/tests/test_planners/test_mcts_planners/test_constrained_zero/test_constrained_zero_network.py +360 -0
  243. POMDPPlanners/tests/test_planners/test_mcts_planners/test_icvar_pft_dpw.py +636 -0
  244. POMDPPlanners/tests/test_planners/test_mcts_planners/test_icvar_pomcpow.py +1386 -0
  245. POMDPPlanners/tests/test_planners/test_mcts_planners/test_path_simulation_policy.py +643 -0
  246. POMDPPlanners/tests/test_planners/test_mcts_planners/test_pft_dpw.py +706 -0
  247. POMDPPlanners/tests/test_planners/test_mcts_planners/test_pomcp.py +702 -0
  248. POMDPPlanners/tests/test_planners/test_mcts_planners/test_pomcp_dpw.py +1211 -0
  249. POMDPPlanners/tests/test_planners/test_mcts_planners/test_pomcpow.py +1286 -0
  250. POMDPPlanners/tests/test_planners/test_mcts_planners/test_sparse_pft.py +708 -0
  251. POMDPPlanners/tests/test_planners/test_mcts_planners/test_utils.py +203 -0
  252. POMDPPlanners/tests/test_planners/test_open_loop_planners/__init__.py +0 -0
  253. POMDPPlanners/tests/test_planners/test_open_loop_planners/test_discrete_action_sequences_planner.py +403 -0
  254. POMDPPlanners/tests/test_planners/test_planner_save_load_interface.py +361 -0
  255. POMDPPlanners/tests/test_planners/test_planner_serialization.py +781 -0
  256. POMDPPlanners/tests/test_planners/test_planners_utils/__init__.py +0 -0
  257. POMDPPlanners/tests/test_planners/test_planners_utils/test_dpw.py +1303 -0
  258. POMDPPlanners/tests/test_planners/test_planners_utils/test_rollout.py +762 -0
  259. POMDPPlanners/tests/test_planners/test_sparse_sampling_planners/__init__.py +0 -0
  260. POMDPPlanners/tests/test_planners/test_sparse_sampling_planners/test_icvar_sparse_sampling.py +323 -0
  261. POMDPPlanners/tests/test_planners/test_sparse_sampling_planners/test_sparse_sampling.py +469 -0
  262. POMDPPlanners/tests/test_setup.py +98 -0
  263. POMDPPlanners/tests/test_simulations/__init__.py +0 -0
  264. POMDPPlanners/tests/test_simulations/conftest.py +35 -0
  265. POMDPPlanners/tests/test_simulations/test_hyper_parameter_tuning_simulations.py +2814 -0
  266. POMDPPlanners/tests/test_simulations/test_simulation_statistics.py +829 -0
  267. POMDPPlanners/tests/test_simulations/test_simulations_apis/__init__.py +10 -0
  268. POMDPPlanners/tests/test_simulations/test_simulations_apis/api_test_fixtures.py +189 -0
  269. POMDPPlanners/tests/test_simulations/test_simulations_apis/api_test_mixins.py +769 -0
  270. POMDPPlanners/tests/test_simulations/test_simulations_apis/test_dask_simulations_api.py +341 -0
  271. POMDPPlanners/tests/test_simulations/test_simulations_apis/test_local_simulations_api.py +776 -0
  272. POMDPPlanners/tests/test_simulations/test_simulations_apis/test_pbs_simulations_api.py +284 -0
  273. POMDPPlanners/tests/test_simulations/test_simulations_deployment/__init__.py +0 -0
  274. POMDPPlanners/tests/test_simulations/test_simulations_deployment/test_cache_dbs.py +244 -0
  275. POMDPPlanners/tests/test_simulations/test_simulations_deployment/test_task_manager_configs.py +613 -0
  276. POMDPPlanners/tests/test_simulations/test_simulations_deployment/test_task_managers.py +2803 -0
  277. POMDPPlanners/tests/test_simulations/test_simulations_deployment/test_tasks/__init__.py +0 -0
  278. POMDPPlanners/tests/test_simulations/test_simulations_deployment/test_tasks/test_episode_simulation_task.py +1533 -0
  279. POMDPPlanners/tests/test_simulations/test_simulations_deployment/test_tasks/test_hyper_parameter_tuning_simulation_task.py +1835 -0
  280. POMDPPlanners/tests/test_simulations/test_simulations_deployment/test_tasks/test_task_serialization.py +904 -0
  281. POMDPPlanners/tests/test_simulations/test_simulator.py +3790 -0
  282. POMDPPlanners/tests/test_simulations/test_simulator_serialization.py +334 -0
  283. POMDPPlanners/tests/test_simulations/test_workflows/__init__.py +0 -0
  284. POMDPPlanners/tests/test_simulations/test_workflows/test_hyperparameter_tuning_evaluation_workflows.py +952 -0
  285. POMDPPlanners/tests/test_simulations/test_workflows/test_planner_evaluation_workflow.py +1476 -0
  286. POMDPPlanners/tests/test_training/__init__.py +0 -0
  287. POMDPPlanners/tests/test_training/test_callbacks.py +416 -0
  288. POMDPPlanners/tests/test_training/test_policy_trainer.py +266 -0
  289. POMDPPlanners/tests/test_utils/__init__.py +0 -0
  290. POMDPPlanners/tests/test_utils/confidence_interval_utils.py +69 -0
  291. POMDPPlanners/tests/test_utils/history_builders.py +73 -0
  292. POMDPPlanners/tests/test_utils/test_action_samplers.py +1061 -0
  293. POMDPPlanners/tests/test_utils/test_belief_factory.py +338 -0
  294. POMDPPlanners/tests/test_utils/test_confidence_interval_utils.py +146 -0
  295. POMDPPlanners/tests/test_utils/test_config_loader.py +196 -0
  296. POMDPPlanners/tests/test_utils/test_config_to_id.py +866 -0
  297. POMDPPlanners/tests/test_utils/test_hyperparameter_tuning_and_eval.py +3163 -0
  298. POMDPPlanners/tests/test_utils/test_logger.py +1032 -0
  299. POMDPPlanners/tests/test_utils/test_memory_tracker.py +592 -0
  300. POMDPPlanners/tests/test_utils/test_multivariate_normal.py +586 -0
  301. POMDPPlanners/tests/test_utils/test_planner_episode_visualization.py +995 -0
  302. POMDPPlanners/tests/test_utils/test_probability_utils.py +652 -0
  303. POMDPPlanners/tests/test_utils/test_simulations_caching.py +641 -0
  304. POMDPPlanners/tests/test_utils/test_statistics_utils.py +983 -0
  305. POMDPPlanners/tests/test_utils/test_tree_statistics.py +109 -0
  306. POMDPPlanners/tests/test_utils/test_visualization/__init__.py +11 -0
  307. POMDPPlanners/tests/test_utils/test_visualization/test_metrics_plots.py +544 -0
  308. POMDPPlanners/tests/test_utils/test_visualization/test_policy_simulation_plots.py +308 -0
  309. POMDPPlanners/tests/test_utils/test_visualization/test_returns_plots.py +449 -0
  310. POMDPPlanners/tests/test_utils/test_visualization/test_tree_plots.py +201 -0
  311. POMDPPlanners/tests/test_utils/test_weighted_particle_belief.py +606 -0
  312. POMDPPlanners/training/__init__.py +32 -0
  313. POMDPPlanners/training/callbacks.py +299 -0
  314. POMDPPlanners/training/policy_trainer.py +214 -0
  315. POMDPPlanners/utils/__init__.py +0 -0
  316. POMDPPlanners/utils/action_samplers.py +108 -0
  317. POMDPPlanners/utils/belief_factory.py +188 -0
  318. POMDPPlanners/utils/config_loader.py +177 -0
  319. POMDPPlanners/utils/config_to_id.py +74 -0
  320. POMDPPlanners/utils/distributed_computing.py +112 -0
  321. POMDPPlanners/utils/hyperparameter_tuning_and_eval.py +2079 -0
  322. POMDPPlanners/utils/logger.py +837 -0
  323. POMDPPlanners/utils/memory_tracker.py +445 -0
  324. POMDPPlanners/utils/multivariate_normal.py +179 -0
  325. POMDPPlanners/utils/planner_episode_visualization.py +69 -0
  326. POMDPPlanners/utils/simulations_caching.py +71 -0
  327. POMDPPlanners/utils/statistics_utils.py +799 -0
  328. POMDPPlanners/utils/tree_statistics.py +191 -0
  329. POMDPPlanners/utils/visualization/__init__.py +49 -0
  330. POMDPPlanners/utils/visualization/metrics_plots.py +331 -0
  331. POMDPPlanners/utils/visualization/plot_utils.py +83 -0
  332. POMDPPlanners/utils/visualization/policy_simulation_plots.py +293 -0
  333. POMDPPlanners/utils/visualization/returns_plots.py +176 -0
  334. POMDPPlanners/utils/visualization/tree_plots.py +290 -0
  335. POMDPPlanners/utils/weighted_particle_beliefs.py +256 -0
  336. pomdpplanners-0.1.0.dist-info/METADATA +378 -0
  337. pomdpplanners-0.1.0.dist-info/RECORD +340 -0
  338. pomdpplanners-0.1.0.dist-info/WHEEL +5 -0
  339. pomdpplanners-0.1.0.dist-info/licenses/LICENSE.md +7 -0
  340. pomdpplanners-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,3 @@
1
+ """POMDPPlanners - A Python package for POMDP planning algorithms and environments."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,4 @@
1
+ from POMDPPlanners.configs.environment_configs import EnvironmentConfigsAPI
2
+ from POMDPPlanners.configs.planners_hyperparam_configs import PlannersHyperparamConfigs
3
+
4
+ __all__ = ["PlannersHyperparamConfigs", "EnvironmentConfigsAPI"]
@@ -0,0 +1,532 @@
1
+ from typing import List, Tuple
2
+
3
+ import numpy as np
4
+
5
+ from POMDPPlanners.core.belief import Belief, WeightedParticleBelief, get_initial_belief
6
+ from POMDPPlanners.utils.belief_factory import create_environment_belief
7
+ from POMDPPlanners.core.environment import Environment, DiscreteActionsEnvironment, SpaceType
8
+ from POMDPPlanners.core.policy import PolicySpaceInfo
9
+ from POMDPPlanners.environments.cartpole_pomdp import CartPolePOMDP
10
+ from POMDPPlanners.environments.laser_tag_pomdp import (
11
+ LaserTagPOMDP,
12
+ ContinuousLaserTagPOMDP,
13
+ ContinuousLaserTagPOMDPDiscreteActions,
14
+ )
15
+ from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_pomdp import (
16
+ ContinuousLightDarkPOMDP,
17
+ ContinuousLightDarkPOMDPDiscreteActions,
18
+ RewardModelType,
19
+ )
20
+ from POMDPPlanners.environments.mountain_car_pomdp import MountainCarPOMDP
21
+ from POMDPPlanners.environments.pacman_pomdp import PacManPOMDP
22
+ from POMDPPlanners.environments.push_pomdp import PushPOMDP
23
+ from POMDPPlanners.environments.rock_sample_pomdp import RockSamplePOMDP
24
+ from POMDPPlanners.environments.safety_ant_velocity_pomdp import SafeAntVelocityPOMDP
25
+ from POMDPPlanners.environments.tiger_pomdp import TigerPOMDP
26
+
27
+
28
+ def get_compatible_environments(
29
+ config_api_instance, policy_space_info: PolicySpaceInfo, n_particles: int = 20, seed: int = 42
30
+ ) -> List[Tuple[Environment, Belief]]:
31
+ """Get list of environments compatible with the given policy space info.
32
+
33
+ Args:
34
+ config_api_instance: Instance of EnvironmentConfigsAPI or its subclass
35
+ policy_space_info: Policy space information containing action and observation space types
36
+ n_particles: Number of particles for belief initialization
37
+ seed: Random seed for reproducible belief initialization
38
+
39
+ Returns:
40
+ List of tuples containing (environment, belief) pairs that are compatible with the policy
41
+ """
42
+ np.random.seed(seed)
43
+ compatible_envs = []
44
+ seen_env_names = set()
45
+
46
+ # Get all config methods (methods ending with '_config')
47
+ config_methods = [
48
+ method_name
49
+ for method_name in dir(config_api_instance)
50
+ if method_name.endswith("_config") and callable(getattr(config_api_instance, method_name))
51
+ ]
52
+
53
+ for method_name in config_methods:
54
+ # Get environment instance by calling the config method
55
+ env, belief = getattr(config_api_instance, method_name)(n_particles=n_particles)
56
+
57
+ # Check compatibility and avoid duplicates
58
+ if _is_compatible(policy_space_info, env.space_info) and env.name not in seen_env_names:
59
+ compatible_envs.append((env, belief))
60
+ seen_env_names.add(env.name)
61
+
62
+ return compatible_envs
63
+
64
+
65
+ def _is_compatible(policy_space_info: PolicySpaceInfo, env_space_info) -> bool:
66
+ """Check if policy and environment space types are compatible."""
67
+ # Check action space compatibility
68
+ if policy_space_info.action_space == SpaceType.DISCRETE and env_space_info.action_space in [
69
+ SpaceType.CONTINUOUS,
70
+ SpaceType.MIXED,
71
+ ]:
72
+ return False
73
+
74
+ # Check observation space compatibility
75
+ if (
76
+ policy_space_info.observation_space == SpaceType.DISCRETE
77
+ and env_space_info.observation_space in [SpaceType.CONTINUOUS, SpaceType.MIXED]
78
+ ):
79
+ return False
80
+
81
+ return True
82
+
83
+
84
+ def get_all_environments(
85
+ n_particles: int = 20, include_risk_averse: bool = True
86
+ ) -> List[Tuple[Environment, Belief]]:
87
+ """Get all environments from both standard and risk-averse API classes.
88
+
89
+ Args:
90
+ n_particles: Number of particles for belief initialization
91
+ include_risk_averse: Whether to include environments from RiskAverseEnvironmentConfigsAPI
92
+
93
+ Returns:
94
+ List of tuples containing (environment, belief) pairs from all available configurations
95
+ """
96
+ all_environments = []
97
+
98
+ # Get environments from standard API
99
+ standard_api = EnvironmentConfigsAPI()
100
+ config_methods = [
101
+ method_name
102
+ for method_name in dir(standard_api)
103
+ if method_name.endswith("_config") and callable(getattr(standard_api, method_name))
104
+ ]
105
+
106
+ for method_name in config_methods:
107
+ env, belief = getattr(standard_api, method_name)(n_particles=n_particles)
108
+ all_environments.append((env, belief))
109
+
110
+ # Get environments from risk-averse API if requested
111
+ if include_risk_averse:
112
+ risk_averse_api = RiskAverseEnvironmentConfigsAPI()
113
+ risk_averse_config_methods = [
114
+ method_name
115
+ for method_name in dir(risk_averse_api)
116
+ if method_name.endswith("_config") and callable(getattr(risk_averse_api, method_name))
117
+ ]
118
+
119
+ for method_name in risk_averse_config_methods:
120
+ env, belief = getattr(risk_averse_api, method_name)(n_particles=n_particles)
121
+ all_environments.append((env, belief))
122
+
123
+ return all_environments
124
+
125
+
126
+ class EnvironmentConfigsAPI:
127
+ def __init__(self, discount_factor: float = 0.95, debug: bool = False):
128
+ self.debug = debug
129
+ self.discount_factor = discount_factor
130
+
131
+ def get_compatible_environments(
132
+ self, policy_space_info: PolicySpaceInfo, n_particles: int = 20, seed: int = 42
133
+ ) -> List[Tuple[Environment, Belief]]:
134
+ """Get list of environments compatible with the given policy space info.
135
+
136
+ Args:
137
+ policy_space_info: Policy space information containing action and observation space types
138
+ n_particles: Number of particles for belief initialization
139
+ seed: Random seed for reproducible belief initialization
140
+
141
+ Returns:
142
+ List of tuples containing (environment, belief) pairs that are compatible with the policy
143
+ """
144
+ return get_compatible_environments(self, policy_space_info, n_particles, seed)
145
+
146
+ def tiger_pomdp_config(
147
+ self, n_particles: int = 20
148
+ ) -> Tuple[DiscreteActionsEnvironment, WeightedParticleBelief]:
149
+ pomdp = TigerPOMDP(
150
+ discount_factor=self.discount_factor, name="TigerPOMDP", debug=self.debug
151
+ )
152
+ belief = get_initial_belief(pomdp=pomdp, n_particles=n_particles, resampling=True)
153
+
154
+ return pomdp, belief
155
+
156
+ def cartpole_pomdp_config(
157
+ self, n_particles: int = 20
158
+ ) -> Tuple[DiscreteActionsEnvironment, Belief]:
159
+ # Create noise covariance matrix for CartPole observations
160
+ noise_cov = np.diag(
161
+ [0.1, 0.1, 0.1, 0.1]
162
+ ) # Noise for [cart_pos, cart_vel, pole_angle, pole_vel]
163
+ pomdp = CartPolePOMDP(
164
+ discount_factor=self.discount_factor,
165
+ noise_cov=noise_cov,
166
+ name="CartPolePOMDP",
167
+ )
168
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
169
+ return pomdp, belief
170
+
171
+ def mountain_car_pomdp_config(
172
+ self, n_particles: int = 20
173
+ ) -> Tuple[DiscreteActionsEnvironment, Belief]:
174
+ pomdp = MountainCarPOMDP(discount_factor=self.discount_factor, name="MountainCarPOMDP")
175
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
176
+ return pomdp, belief
177
+
178
+ def push_pomdp_config(
179
+ self, n_particles: int = 20
180
+ ) -> Tuple[DiscreteActionsEnvironment, WeightedParticleBelief]:
181
+ pomdp = PushPOMDP(discount_factor=self.discount_factor, name="PushPOMDP")
182
+ belief = get_initial_belief(pomdp=pomdp, n_particles=n_particles, resampling=True)
183
+ return pomdp, belief
184
+
185
+ def continuous_observations_discrete_actions_light_dark_pomdp_config(
186
+ self, n_particles: int = 20
187
+ ) -> Tuple[DiscreteActionsEnvironment, Belief]:
188
+ DISCOUNT_FACTOR = self.discount_factor
189
+ STATE_TRANSITION_COV_MATRIX = np.eye(2) * 0.075 # Identity matrix for state transitions
190
+ OBSERVATION_COV_MATRIX = np.array(
191
+ [[0.075, 0.01], [0.01, 0.075]]
192
+ ) # Anisotropic observation noise
193
+ BEACONS = [(1.0, 1.0), (1.0, 4.0), (4.0, 4.0), (4.0, 1.0)] # Grid pattern as list of tuples
194
+ GOAL_STATE = np.array([4, 4]) # Goal at (4,4)
195
+ START_STATE = np.array([1, 1]) # Start at (1,1)
196
+ OBSTACLES = [(3.0, 1.0), (3.0, 2.0), (4.0, 1.0)] # Two obstacles as list of tuples
197
+ OBSTACLE_HIT_PROBABILITY = 0.2 # 20% chance of hitting obstacle
198
+ OBSTACLE_REWARD = -10.0 # Penalty for hitting obstacle
199
+ GOAL_REWARD = 10.0 # Reward for reaching goal
200
+ FUEL_COST = 2.0 # Cost per action
201
+ GRID_SIZE = 5 # Size of the grid
202
+ GOAL_STATE_RADIUS = 1.5 # Radius around goal to consider as reached
203
+ BEACON_RADIUS = 1.0 # Radius around beacons for observations
204
+ OBSTACLE_RADIUS = 1.5 # Radius around obstacles for collision
205
+ REWARD_MODEL_TYPE = RewardModelType.STANDARD # Standard reward model
206
+ PENALTY_DECAY = 1.0 # No decay in penalty
207
+
208
+ pomdp = ContinuousLightDarkPOMDPDiscreteActions(
209
+ discount_factor=DISCOUNT_FACTOR,
210
+ state_transition_cov_matrix=STATE_TRANSITION_COV_MATRIX,
211
+ observation_cov_matrix=OBSERVATION_COV_MATRIX,
212
+ beacons=BEACONS,
213
+ goal_state=GOAL_STATE,
214
+ start_state=START_STATE,
215
+ obstacles=OBSTACLES,
216
+ obstacle_hit_probability=OBSTACLE_HIT_PROBABILITY,
217
+ obstacle_reward=OBSTACLE_REWARD,
218
+ goal_reward=GOAL_REWARD,
219
+ fuel_cost=FUEL_COST,
220
+ grid_size=GRID_SIZE,
221
+ goal_state_radius=GOAL_STATE_RADIUS,
222
+ beacon_radius=BEACON_RADIUS,
223
+ obstacle_radius=OBSTACLE_RADIUS,
224
+ reward_model_type=REWARD_MODEL_TYPE,
225
+ penalty_decay=PENALTY_DECAY,
226
+ name="ContinuousLightDarkPOMDPDiscreteActions",
227
+ )
228
+
229
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
230
+ return pomdp, belief
231
+
232
+ def continuous_observations_continuous_actions_light_dark_pomdp_config(
233
+ self, n_particles: int = 20
234
+ ) -> Tuple[Environment, Belief]:
235
+ DISCOUNT_FACTOR = self.discount_factor
236
+ STATE_TRANSITION_COV_MATRIX = np.eye(2) * 0.075 # Identity matrix for state transitions
237
+ OBSERVATION_COV_MATRIX = np.array(
238
+ [[0.075, 0.01], [0.01, 0.075]]
239
+ ) # Anisotropic observation noise
240
+ BEACONS = [(1.0, 1.0), (1.0, 4.0), (4.0, 4.0), (4.0, 1.0)] # Grid pattern as list of tuples
241
+ GOAL_STATE = np.array([4, 4]) # Goal at (4,4)
242
+ START_STATE = np.array([1, 1]) # Start at (1,1)
243
+ OBSTACLES = [(3.0, 1.0), (3.0, 2.0), (4.0, 1.0)] # Two obstacles as list of tuples
244
+ OBSTACLE_HIT_PROBABILITY = 0.2 # 20% chance of hitting obstacle
245
+ OBSTACLE_REWARD = -10.0 # Penalty for hitting obstacle
246
+ GOAL_REWARD = 10.0 # Reward for reaching goal
247
+ FUEL_COST = 2.0 # Cost per action
248
+ GRID_SIZE = 5 # Size of the grid
249
+ GOAL_STATE_RADIUS = 1.5 # Radius around goal to consider as reached
250
+ BEACON_RADIUS = 1.0 # Radius around beacons for observations
251
+ OBSTACLE_RADIUS = 1.5 # Radius around obstacles for collision
252
+ REWARD_MODEL_TYPE = RewardModelType.STANDARD # Standard reward model
253
+ PENALTY_DECAY = 1.0 # No decay in penalty
254
+
255
+ pomdp = ContinuousLightDarkPOMDP(
256
+ discount_factor=DISCOUNT_FACTOR,
257
+ name="ContinuousLightDarkPOMDP",
258
+ state_transition_cov_matrix=STATE_TRANSITION_COV_MATRIX,
259
+ observation_cov_matrix=OBSERVATION_COV_MATRIX,
260
+ beacons=BEACONS,
261
+ goal_state=GOAL_STATE,
262
+ start_state=START_STATE,
263
+ obstacles=OBSTACLES,
264
+ obstacle_hit_probability=OBSTACLE_HIT_PROBABILITY,
265
+ obstacle_reward=OBSTACLE_REWARD,
266
+ goal_reward=GOAL_REWARD,
267
+ fuel_cost=FUEL_COST,
268
+ grid_size=GRID_SIZE,
269
+ goal_state_radius=GOAL_STATE_RADIUS,
270
+ beacon_radius=BEACON_RADIUS,
271
+ obstacle_radius=OBSTACLE_RADIUS,
272
+ reward_model_type=REWARD_MODEL_TYPE,
273
+ penalty_decay=PENALTY_DECAY,
274
+ is_obstacle_hit_terminal=True,
275
+ )
276
+
277
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
278
+ return pomdp, belief
279
+
280
+ def rock_sample_pomdp_config(
281
+ self, n_particles: int = 20
282
+ ) -> Tuple[Environment, WeightedParticleBelief]:
283
+ pomdp = RockSamplePOMDP(
284
+ discount_factor=self.discount_factor,
285
+ name="RockSamplePOMDP",
286
+ dangerous_areas=None,
287
+ )
288
+ belief = get_initial_belief(pomdp=pomdp, n_particles=n_particles, resampling=True)
289
+ return pomdp, belief
290
+
291
+ def pacman_pomdp_config(
292
+ self, n_particles: int = 20
293
+ ) -> Tuple[DiscreteActionsEnvironment, WeightedParticleBelief]:
294
+ pomdp = PacManPOMDP(discount_factor=self.discount_factor, name="PacManPOMDP")
295
+ belief = get_initial_belief(pomdp=pomdp, n_particles=n_particles, resampling=True)
296
+ return pomdp, belief
297
+
298
+ def laser_tag_pomdp_config(self, n_particles: int = 20) -> Tuple[Environment, Belief]:
299
+ pomdp = LaserTagPOMDP(discount_factor=self.discount_factor, name="LaserTagPOMDP")
300
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
301
+ return pomdp, belief
302
+
303
+ def continuous_laser_tag_pomdp_config(
304
+ self, n_particles: int = 20
305
+ ) -> Tuple[Environment, Belief]:
306
+ pomdp = ContinuousLaserTagPOMDP(
307
+ discount_factor=self.discount_factor,
308
+ name="ContinuousLaserTagPOMDP",
309
+ )
310
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
311
+ return pomdp, belief
312
+
313
+ def continuous_laser_tag_pomdp_discrete_actions_config(
314
+ self, n_particles: int = 20
315
+ ) -> Tuple[DiscreteActionsEnvironment, Belief]:
316
+ pomdp = ContinuousLaserTagPOMDPDiscreteActions(
317
+ discount_factor=self.discount_factor,
318
+ name="ContinuousLaserTagPOMDPDiscreteActions",
319
+ )
320
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
321
+ return pomdp, belief
322
+
323
+ def safety_ant_velocity_pomdp_config(self, n_particles: int = 20) -> Tuple[Environment, Belief]:
324
+ pomdp = SafeAntVelocityPOMDP(
325
+ discount_factor=self.discount_factor, name="SafeAntVelocityPOMDP"
326
+ )
327
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
328
+ return pomdp, belief
329
+
330
+
331
+ class RiskAverseEnvironmentConfigsAPI:
332
+ def __init__(self, discount_factor: float = 0.95, debug: bool = False):
333
+ self.discount_factor = discount_factor
334
+ self.debug = debug
335
+
336
+ def get_compatible_environments(
337
+ self, policy_space_info: PolicySpaceInfo, n_particles: int = 20, seed: int = 42
338
+ ) -> List[Tuple[Environment, Belief]]:
339
+ """Get list of environments compatible with the given policy space info.
340
+
341
+ Args:
342
+ policy_space_info: Policy space information containing action and observation space types
343
+ n_particles: Number of particles for belief initialization
344
+ seed: Random seed for reproducible belief initialization
345
+
346
+ Returns:
347
+ List of tuples containing (environment, belief) pairs that are compatible with the policy
348
+ """
349
+ return get_compatible_environments(self, policy_space_info, n_particles, seed)
350
+
351
+ def continuous_observations_discrete_actions_light_dark_pomdp_config(
352
+ self, n_particles: int = 20
353
+ ) -> Tuple[DiscreteActionsEnvironment, Belief]:
354
+ DISCOUNT_FACTOR = self.discount_factor
355
+ STATE_TRANSITION_COV_MATRIX = np.eye(2) * 0.075 # Identity matrix for state transitions
356
+ OBSERVATION_COV_MATRIX = np.array(
357
+ [[0.075, 0.01], [0.01, 0.075]]
358
+ ) # Anisotropic observation noise
359
+ BEACONS = [(1.0, 1.0), (4.0, 4.0), (4.0, 1.0), (1.0, 4.0)] # Grid pattern as list of tuples
360
+ GOAL_STATE = np.array([4, 4]) # Goal at (4,4)
361
+ START_STATE = np.array([1, 1]) # Start at (1,1)
362
+ OBSTACLES = [
363
+ (3.0, 1.0),
364
+ (3.0, 2.0),
365
+ (4.0, 1.0),
366
+ ] # Two obstacles as list of tuples - moved away from start
367
+ OBSTACLE_HIT_PROBABILITY = 0.2 # 20% chance of hitting obstacle
368
+ OBSTACLE_REWARD = -10.0 # Penalty for hitting obstacle
369
+ GOAL_REWARD = 10.0 # Reward for reaching goal
370
+ FUEL_COST = 2.0 # Cost per action
371
+ GRID_SIZE = 5 # Size of the grid
372
+ GOAL_STATE_RADIUS = 1.5 # Radius around goal to consider as reached
373
+ BEACON_RADIUS = 1.0 # Radius around beacons for observations
374
+ OBSTACLE_RADIUS = 1.2 # Radius around obstacles for collision
375
+ REWARD_MODEL_TYPE = RewardModelType.DANGEROUS_STATES # Standard reward model
376
+ PENALTY_DECAY = 1.0 # No decay in penalty
377
+
378
+ pomdp = ContinuousLightDarkPOMDPDiscreteActions(
379
+ discount_factor=DISCOUNT_FACTOR,
380
+ state_transition_cov_matrix=STATE_TRANSITION_COV_MATRIX,
381
+ observation_cov_matrix=OBSERVATION_COV_MATRIX,
382
+ beacons=BEACONS,
383
+ goal_state=GOAL_STATE,
384
+ start_state=START_STATE,
385
+ obstacles=OBSTACLES,
386
+ obstacle_hit_probability=OBSTACLE_HIT_PROBABILITY,
387
+ obstacle_reward=OBSTACLE_REWARD,
388
+ goal_reward=GOAL_REWARD,
389
+ fuel_cost=FUEL_COST,
390
+ grid_size=GRID_SIZE,
391
+ goal_state_radius=GOAL_STATE_RADIUS,
392
+ beacon_radius=BEACON_RADIUS,
393
+ obstacle_radius=OBSTACLE_RADIUS,
394
+ reward_model_type=REWARD_MODEL_TYPE,
395
+ penalty_decay=PENALTY_DECAY,
396
+ name="ContinuousLightDarkPOMDPDiscreteActions",
397
+ )
398
+
399
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
400
+ return pomdp, belief
401
+
402
+ def continuous_observations_continuous_actions_light_dark_pomdp_config(
403
+ self, n_particles: int = 20
404
+ ) -> Tuple[Environment, Belief]:
405
+ DISCOUNT_FACTOR = self.discount_factor
406
+ STATE_TRANSITION_COV_MATRIX = np.eye(2) * 0.075 # Identity matrix for state transitions
407
+ OBSERVATION_COV_MATRIX = np.array(
408
+ [[0.075, 0.01], [0.01, 0.075]]
409
+ ) # Anisotropic observation noise
410
+ BEACONS = [(1.0, 1.0), (4.0, 4.0), (4.0, 1.0), (1.0, 4.0)] # Grid pattern as list of tuples
411
+ GOAL_STATE = np.array([4, 4]) # Goal at (4,4)
412
+ START_STATE = np.array([1, 1]) # Start at (1,1)
413
+ OBSTACLES = [
414
+ (3.0, 1.0),
415
+ (3.0, 2.0),
416
+ (4.0, 1.0),
417
+ ] # Two obstacles as list of tuples - moved away from start
418
+ OBSTACLE_HIT_PROBABILITY = 0.2 # 20% chance of hitting obstacle
419
+ OBSTACLE_REWARD = -10.0 # Penalty for hitting obstacle
420
+ GOAL_REWARD = 10.0 # Reward for reaching goal
421
+ FUEL_COST = 2.0 # Cost per action
422
+ GRID_SIZE = 5 # Size of the grid
423
+ GOAL_STATE_RADIUS = 1.5 # Radius around goal to consider as reached
424
+ BEACON_RADIUS = 1.0 # Radius around beacons for observations
425
+ OBSTACLE_RADIUS = 1.2 # Radius around obstacles for collision
426
+ REWARD_MODEL_TYPE = RewardModelType.DANGEROUS_STATES # Standard reward model
427
+ PENALTY_DECAY = 1.0 # No decay in penalty
428
+
429
+ pomdp = ContinuousLightDarkPOMDP(
430
+ discount_factor=DISCOUNT_FACTOR,
431
+ name="ContinuousLightDarkPOMDP",
432
+ state_transition_cov_matrix=STATE_TRANSITION_COV_MATRIX,
433
+ observation_cov_matrix=OBSERVATION_COV_MATRIX,
434
+ beacons=BEACONS,
435
+ goal_state=GOAL_STATE,
436
+ start_state=START_STATE,
437
+ obstacles=OBSTACLES,
438
+ obstacle_hit_probability=OBSTACLE_HIT_PROBABILITY,
439
+ obstacle_reward=OBSTACLE_REWARD,
440
+ goal_reward=GOAL_REWARD,
441
+ fuel_cost=FUEL_COST,
442
+ grid_size=GRID_SIZE,
443
+ goal_state_radius=GOAL_STATE_RADIUS,
444
+ beacon_radius=BEACON_RADIUS,
445
+ obstacle_radius=OBSTACLE_RADIUS,
446
+ reward_model_type=REWARD_MODEL_TYPE,
447
+ penalty_decay=PENALTY_DECAY,
448
+ is_obstacle_hit_terminal=True,
449
+ )
450
+
451
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
452
+ return pomdp, belief
453
+
454
+ def rock_sample_pomdp_config(
455
+ self, n_particles: int = 20
456
+ ) -> Tuple[Environment, WeightedParticleBelief]:
457
+ pomdp = RockSamplePOMDP(
458
+ discount_factor=self.discount_factor,
459
+ map_size=(5, 5),
460
+ rock_positions=[(1, 1), (3, 2), (2, 4)],
461
+ dangerous_areas=[(2, 2), (4, 1)],
462
+ dangerous_area_radius=1.0,
463
+ dangerous_area_penalty=5.0,
464
+ )
465
+
466
+ belief = get_initial_belief(pomdp=pomdp, n_particles=n_particles, resampling=True)
467
+ return pomdp, belief
468
+
469
+ def push_pomdp_config(
470
+ self, n_particles: int = 20
471
+ ) -> Tuple[DiscreteActionsEnvironment, WeightedParticleBelief]:
472
+ pomdp = PushPOMDP(
473
+ discount_factor=self.discount_factor,
474
+ grid_size=10,
475
+ push_threshold=1.0,
476
+ friction_coefficient=0.3,
477
+ observation_noise=0.1,
478
+ obstacles=[(3.0, 4.0), (6.0, 7.0), (2.0, 8.0)],
479
+ obstacle_radius=1,
480
+ obstacle_penalty=-10.0,
481
+ name="PushPOMDP",
482
+ )
483
+ belief = get_initial_belief(pomdp=pomdp, n_particles=n_particles, resampling=True)
484
+ return pomdp, belief
485
+
486
+ def pacman_pomdp_config(
487
+ self, n_particles: int = 20
488
+ ) -> Tuple[DiscreteActionsEnvironment, WeightedParticleBelief]:
489
+ pomdp = PacManPOMDP(
490
+ discount_factor=self.discount_factor,
491
+ name="PacManPOMDP",
492
+ max_observation_noise=0.5,
493
+ ghost_collision_penalty=-50.0,
494
+ pellet_reward=50.0,
495
+ observation_noise_factor=0.1,
496
+ win_reward=100.0,
497
+ num_ghosts=2,
498
+ )
499
+ belief = get_initial_belief(pomdp=pomdp, n_particles=n_particles, resampling=True)
500
+ return pomdp, belief
501
+
502
+ def laser_tag_pomdp_config(self, n_particles: int = 20) -> Tuple[Environment, Belief]:
503
+ pomdp = LaserTagPOMDP(discount_factor=self.discount_factor, name="LaserTagPOMDP")
504
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
505
+ return pomdp, belief
506
+
507
+ def continuous_laser_tag_pomdp_config(
508
+ self, n_particles: int = 20
509
+ ) -> Tuple[Environment, Belief]:
510
+ pomdp = ContinuousLaserTagPOMDP(
511
+ discount_factor=self.discount_factor,
512
+ name="ContinuousLaserTagPOMDP",
513
+ )
514
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
515
+ return pomdp, belief
516
+
517
+ def continuous_laser_tag_pomdp_discrete_actions_config(
518
+ self, n_particles: int = 20
519
+ ) -> Tuple[DiscreteActionsEnvironment, Belief]:
520
+ pomdp = ContinuousLaserTagPOMDPDiscreteActions(
521
+ discount_factor=self.discount_factor,
522
+ name="ContinuousLaserTagPOMDPDiscreteActions",
523
+ )
524
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
525
+ return pomdp, belief
526
+
527
+ def safety_ant_velocity_pomdp_config(self, n_particles: int = 20) -> Tuple[Environment, Belief]:
528
+ pomdp = SafeAntVelocityPOMDP(
529
+ discount_factor=self.discount_factor, name="SafeAntVelocityPOMDP"
530
+ )
531
+ belief = create_environment_belief(pomdp, n_particles=n_particles)
532
+ return pomdp, belief