PomdpX¶
- class pgmpy.readwrite.PomdpX.PomdpXReader(path=None, string=None)[source]¶
Initialize an instance of PomdpX reader class
- Parameters:
Example
reader = PomdpXReader(‘TestPomdpX.xml’)
Reference¶
http://bigbird.comp.nus.edu.sg/pmwiki/farm/appl/index.php?n=Main.PomdpXDocumentation
- get_description()[source]¶
Return the problem description
Examples
>>> reader = PomdpXReader('Test_Pomdpx.xml') >>> reader.get_description() 'RockSample problem for map size 1 x 3. Rock is at 0, Rover’s initial position is at 1. Exit is at 2.' >>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_description() 'RockSample problem for map size 1 x 3. Rock is at 0, Rover’s initial position is at 1. Exit is at 2.'
- get_discount()[source]¶
Returns the discount factor for the problem
Example
>>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_discount() 0.95
- get_initial_beliefs()[source]¶
Returns the state, action and observation variables as a dictionary in the case of table type parameter and a nested structure in case of decision diagram parameter
Examples
>>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_initial_beliefs() [{'Var': 'rover_0', 'Parent': ['null'], 'Type': 'TBL', 'Parameter': [{'Instance': ['-'], 'ProbTable': ['0.0', '1.0', '0.0']}] }, {'Var': '', '...': ...,' '...': '...', }]
- get_obs_function()[source]¶
Returns the observation function as nested dict in the case of table- type parameter and a nested structure in case of decision diagram parameter
Example
>>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_obs_function() [{'Var': 'obs_sensor', 'Parent': ['action_rover', 'rover_1', 'rock_1'], 'Type': 'TBL', 'Parameter': [{'Instance': ['amw', '*', '*', '-'], 'ProbTable': ['1.0', '0.0']}, ... ] }]
- get_parameter(var)[source]¶
This method supports the functional tags by providing the actual values in the function as list of dict in case of table type parameter or as nested dict in case of decision diagram
- get_parameter_dd(parameter)[source]¶
This method returns parameters as nested dicts in case of decision diagram parameter.
- get_parameter_tbl(parameter)[source]¶
This method returns parameters as list of dict in case of table type parameter
- get_reward_function()[source]¶
Returns the reward function as nested dict in the case of table- type parameter and a nested structure in case of decision diagram parameter
Example
>>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_reward_function() [{'Var': 'reward_rover', 'Parent': ['action_rover', 'rover_0', 'rock_0'], 'Type': 'TBL', 'Parameter': [{'Instance': ['ame', 's1', '*'], 'ValueTable': ['10']}, ... ] }]
- get_state_transition_function()[source]¶
Returns the transition of the state variables as nested dict in the case of table type parameter and a nested structure in case of decision diagram parameter
Example
>>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_state_transition_function() [{'Var': 'rover_1', 'Parent': ['action_rover', 'rover_0'], 'Type': 'TBL', 'Parameter': [{'Instance': ['amw', 's0', 's2'], 'ProbTable': ['1.0']}, {'Instance': ['amw', 's1', 's0'], 'ProbTable': ['1.0']}, ... ] }]
- get_variables()[source]¶
Returns list of variables of the network
Example
>>> reader = PomdpXReader("pomdpx.xml") >>> reader.get_variables() {'StateVar': [ {'vnamePrev': 'rover_0', 'vnameCurr': 'rover_1', 'ValueEnum': ['s0', 's1', 's2'], 'fullyObs': True}, {'vnamePrev': 'rock_0', 'vnameCurr': 'rock_1', 'fullyObs': False, 'ValueEnum': ['good', 'bad']}], 'ObsVar': [{'vname': 'obs_sensor', 'ValueEnum': ['ogood', 'obad']}], 'RewardVar': [{'vname': 'reward_rover'}], 'ActionVar': [{'vname': 'action_rover', 'ValueEnum': ['amw', 'ame', 'ac', 'as']}] }
- class pgmpy.readwrite.PomdpX.PomdpXWriter(model_data, encoding='utf-8', prettyprint=True)[source]¶
Initialise a PomdpXWriter Object
- Parameters:
model (A Bayesian of Markov Model) – The model to write
- encoding: String(optional)
Encoding for text data
- prettyprint: Bool(optional)
Indentation in output XML if true
- add_conditions(condition, condprob)[source]¶
helper function for adding probability conditions for model :param condition: contains and element of conditions list :type condition: dictionary :param condprob: the tag to which condition is added :type condprob: etree SubElement
- Return type:
None
- add_initial_belief()[source]¶
add initial belief tag to pomdpx model
- Return type:
string containing the xml for initial belief tag
- add_obs_function()[source]¶
add observation function tag to pomdpx model
- Return type:
string containing the xml for observation function tag
- add_parameter_dd(dag_tag, node_dict)[source]¶
helper function for adding parameters in condition
- Parameters:
dag_tag (etree SubElement) – the DAG tag is contained in this subelement
node_dict (dictionary) – the decision diagram dictionary
- Return type:
None
- add_reward_function()[source]¶
add reward function tag to pomdpx model
- Return type:
string containing the xml for reward function tag