#---- ordered_reach = '& F G base3 & F base1 & F base2 & F base3 G ! obstacle' all_base = '& G F base1 & G F base2 G F base3' order1 = 'G i supply X U ! supply base' order2 = 'G i base X U ! base supply' order = '& %s %s' %(order1, order2) task1 = '& %s & G ! obstacle %s' %(all_base, order2) task2 = '& %s G F supply' %all_base task3 = '& %s %s' %(all_base, order2) dra = Dra(task1) t3 = time.time() print '------------------------------' print 'DRA done, time: %s' %str(t3-t2) #---- prod_dra = Product_Dra(motion_mdp, dra) #prod_dra.dotify() t41 = time.time() print '------------------------------' print 'Product DRA done, time: %s' %str(t41-t3) #---- prod_dra.compute_S_f() t42 = time.time() print '------------------------------' print 'Compute MEC done, time: %s' %str(t42-t41) #------ gamma = 0.0 # 0.3 best_all_plan = syn_full_plan(prod_dra, gamma) t5 = time.time() print '------------------------------'
pickle.dump(networkx.get_edge_attributes(motion_mdp, 'prop'), open('v_rep/motion_mdp_edges.p', "wb")) #---- all_base = '& G F base1 & G F base2 & G F base3 G ! obstacle' order1 = 'G i supply X U ! supply base' order2 = 'G i base X U ! base supply' order = '& %s %s' %(order1, order2) task1 = '& %s & G ! obstacle %s' %(all_base, order2) task2 = '& %s G F supply' %all_base task3 = '& %s %s' %(all_base, order2) task = '& F G base3 & F base1 & F base2 & F base3 G ! obstacle' dra = Dra(all_base) t3 = time.time() print 'DRA done, time: %s' %str(t3-t2) #---- prod_dra = Product_Dra(motion_mdp, dra) #prod_dra.dotify() t41 = time.time() print 'Product DRA done, time: %s' %str(t41-t3) pickle.dump((networkx.get_edge_attributes(prod_dra, 'prop'), prod_dra.graph['initial']), open('v_rep/prod_dra_edges.p', "wb")) #---- prod_dra.compute_S_f_rex() t42 = time.time() print 'Compute ASCC done, time: %s' %str(t42-t41) #------ gamma = 0.3 # 0.3 d = 100 best_all_plan = syn_full_plan_rex(prod_dra, gamma, d)
#---- all_base = '& G F base1 & G F base2 G F base3' order1 = 'G i supply X U ! supply base' order2 = 'G i base X U ! base supply' order = '& %s %s' %(order1, order2) task1 = '& %s & G ! obstacle %s' %(all_base, order2) task2 = '& %s G F supply' %all_base task3 = '& %s %s' %(all_base, order2) dra = Dra(all_base) t3 = time.time() print '------------------------------' print 'DRA done, time: %s' %str(t3-t2) #---- prod_dra = Product_Dra(motion_mdp, dra) t41 = time.time() print '------------------------------' print 'Product DRA done, time: %s' %str(t41-t3) #---- prod_dra.compute_S_f() t42 = time.time() print '------------------------------' print 'Compute MEC done, time: %s' %str(t42-t41) print '------------------------------' t43 = time.time() clean_prod_dra = dict() clean_prod_dra['name'] = 'size%d_all_base' %N clean_prod_dra['init'] = prod_dra.graph['initial'] clean_prod_dra['states'] = prod_dra.nodes()
#---- ordered_reach = '& F G base3 & F base1 & F base2 & F base3 G ! obstacle' all_base = '& G F base1 & G F base2 & G F base3 G ! obstacle' order1 = 'G i supply X U ! supply base' order2 = 'G i base X U ! base supply' order = '& %s %s' %(order1, order2) task1 = '& %s & G ! obstacle %s' %(all_base, order2) task2 = '& %s G F supply' %all_base task3 = '& %s %s' %(all_base, order2) dra = Dra(task1) t3 = time.time() print 'DRA done, time: %s' %str(t3-t2) #---- prod_dra = Product_Dra(motion_mdp, dra) #prod_dra.dotify() t41 = time.time() print 'Product DRA done, time: %s' %str(t41-t3) #---- prod_dra.compute_S_f() t42 = time.time() print 'Compute accepting MEC done, time: %s' %str(t42-t41) #------ gamma = 0.0 alpha=0.0 best_all_plan = syn_full_plan_comb(prod_dra, gamma,alpha) t5 = time.time() print 'Plan synthesis done, time: %s' %str(t5-t42)
start = time.time() node_dict, edge_dict, U, initial_node, initial_label = pickle.load( open('./mdp.p', 'rb')) #---- motion_mdp = Motion_MDP(node_dict, edge_dict, U, initial_node, initial_label) print 'motion_mdp done by time %s' % str(time.time() - start) #---- # task_formula = "& G F & r1 g1 & G F & r2 g2 G F & r4 g3" task_formula = "& G F & r1 g1 & G F & r2 g2 & G F & r3 F & r4 g3 G F & r2 g1" dra = Dra(task_formula) print 'dra done by time %s' % str(time.time() - start) #---- prod_dra = Product_Dra(motion_mdp, dra) prod_dra.compute_S_f() #prod_dra.dotify() print 'prod_dra done by time %s' % str(time.time() - start) clambda = 0.98 # a_c algorithm parameters gamma = 1.0 beta = 1.0 D = 0.5 actor_critic_learner = ac_learn(prod_dra, clambda, gamma, beta, D) repeat_times = 50 theta0 = [0.01, 1.0] gamma_seq = [gamma / (k + 1) for k in range(repeat_times)]
#---- ordered_reach = '& F G base3 & F base1 & F base2 & F base3 G ! obstacle' all_base = '& G F base1 & G F base2 & G F base3 G ! obstacle' order1 = 'G i supply X U ! supply base' order2 = 'G i base X U ! base supply' order = '& %s %s' % (order1, order2) task1 = '& %s & G ! obstacle %s' % (all_base, order2) task2 = '& %s G F supply' % all_base task3 = '& %s %s' % (all_base, order2) dra = Dra(all_base) t3 = time.time() print 'DRA done, time: %s' % str(t3 - t2) #---- prod_dra = Product_Dra(motion_mdp, dra) #prod_dra.dotify() t41 = time.time() print 'Product DRA done, time: %s' % str(t41 - t3) #---- prod_dra.compute_S_f() t42 = time.time() print 'Compute accepting MEC done, time: %s' % str(t42 - t41) #------ gamma = 0.3 best_all_plan = syn_full_plan(prod_dra, gamma) t5 = time.time() print 'Plan synthesis done, time: %s' % str(t5 - t42) #----------------------------------------
base = '& G F b G F w' #order = 'G i h X U ! w b' order = 'G F h' safe = 'G ! o' task = '& %s & %s %s' % (base, order, safe) #task = '& G F b G F h' print 'Formula received: %s' % str(task) dra = Dra(task) t3 = time.time() print 'DRA done, time: %s' % str(t3 - t2) #---- print '------------------------------' gamma = [0.8, 0.5] # gamma_o, gamma_r prod_dra = Product_Dra(mdp=robot_mdp, dra=dra, gamma=gamma) #prod_dra.dotify() t41 = time.time() print 'Product DRA constructed, time: %s' % str(t41 - t3) #prod_dra.verify() #---- prod_dra.init_dirichlet() t42 = time.time() print 'Compute init_dirichlet done, time: %s' % str(t42 - t41) #---- prod_dra.compute_init_mean_sigma() t43 = time.time() print 'Compute init_mean_sigma done, time: %s' % str(t43 - t42) #prod_dra.verify() #---- prod_dra.compute_S_f()