if MODELCHECKING: if os.path.isfile(PRISMFILENAME): print "WARNING: Probability file already exists, delete it to generate it again" else: command = PRISMPATH + " -importmodel " + EXPORTFILENAME + \ ".all -mdp " + FORMULAFILENAME + ".props -prop " + \ PROPNAME + " > " + PRISMFILENAME print "-> EXECUTING: " + command start = time.time() os.system(command) end = time.time() print "-> DONE (time: "+ str(end-start) + ")" if SIMULATION: Prob = imp.importProb(PRISMFILENAME,NPAR) for run in range(RUNS): #sim((run, Prob, P)) print "-> RUN "+str(run) # controller initial state ci = L.names[random.choice(L.S)] # environment initial state (not observable) ei = 'tl' #M.names[random.choice([M.inv_names['tl'],M.inv_names['tr']])] init = { s for s in P.S if P.L.names[s[0]] == ci } distr = {(0,M.inv_names['tl']):0.5, (0,M.inv_names['tr']):0.5} # initialize belief state b = belief.belief(P,P.Z,init=distr) # first observation o = func.weighted_choice(
if MODELCHECKING: print "-> MODEL CHECKING" command = PRISMPATH + " -importmodel " + filename + \ ".all -mdp " + formulaeFileName + ".props -prop " + \ propName + " > " + tempFileName print "--> EXECUTING: " + command start = time.time() os.system(command) end = time.time() print "--> DONE (time: "+ str(end-start) + ")" # === ONLINE === if SIMULATION: Prob = imp.importProb(tempFileName,NPAR) # controller initial state ci = (1,1) # environment initial state (non observable) ei = M.names[random.choice(M.S)] # initialize belief state b = belief.belief(P,P.Z) #print "ci:"+str(ci),"ei:" + str(ei) rob.print_grid(ci,ei,DIM,pause=PAUSE) for i in range(MAXITER): # scheduled choice #a = random.choice(cs.L.A) maximum = -1 act_max = None for a in L.A: