Source code for pomdp_py.problems.tag.models.observation_model
import pomdp_py
from pomdp_py.problems.tag.domain.observation import *
import pomdp_py.problems.tag.constants as constants
[docs]
class TagObservationModel(pomdp_py.ObservationModel):
"""In this observation model, the robot deterministically
observes the target location when it is in the same grid cell
as the target. Ohterwise the robot does not observe anything."""
[docs]
def probability(self, observation, next_state, action, **kwargs):
if next_state.robot_position == next_state.target_position:
if observation.target_position is None:
return constants.EPSILON
else:
if observation.target_position == next_state.target_position:
return 1.0 - constants.EPSILON
else:
return constants.EPSILON
else:
if observation.target_position is None:
return 1.0 - constants.EPSILON
else:
return constants.EPSILON
[docs]
def sample(self, next_state, action):
"""There is no stochaisticity in the observation model"""
if next_state.robot_position == next_state.target_position:
return TagObservation(next_state.target_position)
else:
return TagObservation(None)
[docs]
def argmax(self, next_state, action):
return self.sample(next_state, action)