# >>> code if __name__ == '__main__': # partially observable model pomdp = cs.tigerPomdp() # initial belief prior = Distribution(set(pomdp.states.keys()), lambda el,dom: \ Distribution.restrictedUniformPdf(el,dom,\ #{pomdp.inv_states['tl'],pomdp.inv_states['tr']})) {pomdp.inv_states['tl'],pomdp.inv_states['tr']})) # generate belief MDP bmdp = BeliefMarkovDecisionProcess(pomdp,10,prior) # export to PRISM e2p.mdp2sta(bmdp,'test.sta') e2p.mdp2tra(bmdp,'test.tra') e2p.mdp2lab(bmdp,bmdp.inv_states[prior],'test.lab') # compute initial, accepting and refusing states accept = [] refuse = [] for k,v in bmdp.states.iteritems(): if pomdp.inv_states['win'] in v.distr: if v.distr[pomdp.inv_states['win']] > 0.85: accept.append(k) if pomdp.inv_states['lose'] in v.distr: if v.distr[pomdp.inv_states['lose']] > 0.85: refuse.append(k) # export to DOT
if s2 not in pdf: pdf[s2] = belief.distr[s1] * prob * \ pomdp.observationFunction[s2][observation] else: pdf[s2] += belief.distr[s1] * prob * \ pomdp.observationFunction[s2][observation] Distribution.normalize(pdf) return Distribution(belief.support,\ lambda e,domain : Distribution.customPdf(e,pdf)) # >>> main test if __name__ == "__main__": pomdp = cs.tigerPomdp() prior = Distribution(pomdp.states,Distribution.uniformPdf) bmdp = BeliefMarkovDecisionProcess(pomdp,3,prior) print 'print bmdp:',bmdp import exportToPrism as exp exp.mdp2sta(bmdp,'test.sta') exp.mdp2tra(bmdp,'test.tra') # >>> authorship information __author__ = "Marco Tinacci" __copyright__ = "Copyright 2016" __credits__ = ["Marco Tinacci"] __license__ = "ASF" __version__ = "2.0" __maintainer__ = "Marco Tinacci" __email__ = "*****@*****.**" __status__ = "Production"