def my_form(): nlp.nlu_data() count_percentile = counter_list.csv_file() print("keywords matched ===>>> ", count_percentile, "%") if count_percentile >= 25: print('ok') x = similarity.main() print("similarity score ===>>> ", x, "%") v = cosine.main() val_v = v * 100 print("cosine similarity value ===>> ", val_v, "%") T = TF.main() print("Vector Model ===>>> ", T, "%") total_Score_calc = str( (count_percentile * 0.50 + (x * 0.16 + val_v * 0.17 + T * 0.16))) print("Total Score ==> ", total_Score_calc, "%") json_format_keywords = json.dumps(count_percentile) json_format_tf = json.dumps(T) json_format_cosine = json.dumps(val_v) json_format_similarity = json.dumps(x) json_format_Total = json.dumps(total_Score_calc) else: return str("fail") return jsonify(json_format_keywords, json_format_similarity, json_format_cosine, json_format_tf, json_format_Total)
#2]generation of the output with faulty circuit #3]check if outGood == outBad # yes --> detected # no --> not detected for tv in TVs: print( "\n ** ---------------- Circuit Simulation for tv= {0} -------- -------- ** " .format(tv)) #1]--- generation of the output with good circuit # --> fault="" # #sim.main( circuitTosimulate, inputVector, fault ) goodOut = sim.main(BenchMFile, tv, "") #check if the simulatore gives an error # errors: "falseFS" for an error in the fault signal # "falseTV" for an error in the tv # "falseOUT" for an error in the output if (goodOut == "falseFS") or (goodOut == "falseTV") or (goodOut == "falseOUT"): print("\n ERROR ! --> END PROGRAM \n ") exit() #2]---- generation of the output with faulty circuit # badOut = [] for f in faultLIST:
def _run_sim_thread(package_num, root, txt_receipt): """""" if Flag['update_data'] == 0: result = messagebox.askyesno("Tkmessage", "数据还未更新, 是否继续执行仿真") if result == 0: return if not package_num.get(): messagebox.showerror("Tkinter-数据更新错误", "运行错误, 请输入仿真件量!") return if Flag['run_sim'] > 0: result = messagebox.askyesno("Tkmessage", "仿真已经运行完成,是否重新执行仿真") if result == 0: return conn = Mysql().connect txt_receipt['state'] = NORMAL run_arg = Flag['run_time'] or datetime.now() if not Flag['run_time']: Flag['run_time'] = run_arg txt_receipt.insert( END, '本次运行时间:\t' + run_arg.strftime('%Y-%m-%d %H:%M:%S') + '\n') txt_receipt.insert(END, '*******************************\n') root.update_idletasks() # ======================== 插入测试数据============= txt_receipt.insert(END, '插入%s件包裹仿真数据......\n' % package_num.get()) root.update_idletasks() with conn as cur: insert_package(cur, package_num.get(), run_arg) txt_receipt.insert(END, '插入包裹仿真数据成功!\n') root.update_idletasks() time.sleep(0.5) with conn as cur: cur.execute("truncate o_machine_table;" "truncate o_pipeline_table;" "truncate o_truck_table") txt_receipt.insert(END, '*******************************\n') txt_receipt.insert(END, '开始调用仿真函数......\n') root.update_idletasks() start_time = time.time() # ================================ from sim import main main(run_arg) run_time = '%.2f' % (time.time() - start_time) txt_receipt.insert(END, '仿真执行完毕\n') root.update_idletasks() time.sleep(0.5) # ============================================== time.sleep(0.5) txt_receipt.insert(END, '开始读取仿真结果......\n') root.update_idletasks() time.sleep(0.5) root.update_idletasks() with conn as cur: result = read_result(cur) txt_receipt.insert(END, '*******************************\n') txt_receipt.insert(END, '最早到达时间:\t' + check_time(result['fast_time']) + '\n') txt_receipt.insert(END, '最晚到达时间:\t' + check_time(result['later_time']) + '\n') txt_receipt.insert( END, '最后一票处理时间:\t' + check_time(result['last_solve_time']) + '\n') txt_receipt.insert( END, '总处理时间(小时):\t' + '%.2f' % result['total_solve_time'] + '\n') txt_receipt.insert(END, '仿真运行时间(秒):\t' + check_time(run_time) + '\n') root.update_idletasks() txt_receipt.insert(END, '*******************************\n') txt_receipt.insert(END, '开始分析仿真结果......\n') root.update_idletasks() with conn as cur: average = average_time(cur) txt_receipt.insert(END, '票均时效(秒):\t' + '%.2f' % average + '\n') root.update_idletasks() with conn as cur: percent = success_percent(cur) txt_receipt.insert(END, '时效达成率:\t' + '%.2f' % percent + '\n') root.update_idletasks() with conn as cur: discharge_time = discharge(cur) txt_receipt.insert(END, '卸货等待时间(秒):\t' + '%.2f' % discharge_time + '\n') save_data(conn, root, txt_receipt) txt_receipt['state'] = DISABLED root.update_idletasks() Flag['run_sim'] += 1 conn.close()
import sim world = sim.main() from serializers import write_trial_log_csv_files, write_workers_to_csv_file write_trial_log_csv_files(world.log, 'same') write_workers_to_csv_file(world.workers, 'same/workers.csv') import sim import exp_settings world = sim.main(exp_settings.laggy_asymmetry) from serializers import write_trial_log_csv_files, write_workers_to_csv_file write_trial_log_csv_files(world.log, 'laggy') write_workers_to_csv_file(world.workers, 'laggy/workers.csv') import main import storage import trial_plots s = storage.ExperimentStorage('laggy_asymmetry') keys = main.main('exp laggy_asymmetry --concurrency Dispatcher --display-plots') a_trial = s.get(keys[0]) trial_plots.disappointment(a_trial.data) import matplotlib.pyplot as plt import main main.main('exp laggy_asymmetry ') plt.show() import matplotlib.pyplot as plt import main main.main('exp safe_workers') plt.show()
import ibm_nlu_user_data as nlp import TFvec as TF import sim as similarity import cosine import counter_list #import speech_to_text as speechtext #sp = speechtext.speech() #print(sp) nlp.nlu_data() count_percentile = counter_list.csv_file() print("keywords matched ===>>> " , count_percentile , "%") if count_percentile >= 20: print('ok') x_sim = similarity.main() print("similarity score ===>>> " , x_sim ,"%") v = cosine.main() val_v = v*100 print("cosine similarity value ===>> " , val_v,"%") Term = TF.main() print("Vector Model ===>>> " , Term , "%") total_Score_calc = (count_percentile*0.50+(x_sim*0.16+val_v*0.18+Term*0.16)) #its score multiply be weights print("Total Score ==> " , total_Score_calc,"%") else: print('fail')
def test_B_default_scenario_outcome(self): log(type(self).__name__ + '.test_B_default_scenario_outcome()') import sim reload(sim) sim.main('configs/config-%s-2-2-6-10-10-10-15-orders.py' % self.concurrency) orders = 132 # we know there are this many orders in the JSON file configured order_rate = 2.0 ca_max = 6.0 self.assertTrue(sim.cfg['order_rate'], order_rate) self.assertTrue(sim.cfg['courier_arrival_max'], ca_max) self.assertTrue(sim.ot.started is not None) self.assertTrue(not sim.ot.is_alive()) self.assertTrue(sim.ot.exception is None) self.assertTrue(sim.kt.started is not None) self.assertTrue(not sim.kt.is_alive()) self.assertTrue(sim.kt.exception is None) self.assertEqual(sim.kt.counts['event:shutdown'], 1) self.assertEqual(sim.kt.q.qsize(), 0) self.assertEqual(len(sim.kt.courier_timers), 0) self.assertEqual(len(sim.kt.shelves['hot']), 0) self.assertRange(sim.kt.peaks['hot'], 5, 7) self.assertEqual(sim.cfg['shelf_capacity']['hot'], 10) self.assertEqual(len(sim.kt.shelves['cold']), 0) self.assertRange(sim.kt.peaks['cold'], 5, 7) self.assertEqual(sim.cfg['shelf_capacity']['cold'], 10) self.assertEqual(len(sim.kt.shelves['frozen']), 0) self.assertRange(sim.kt.peaks['frozen'], 5, 7) self.assertEqual(sim.cfg['shelf_capacity']['frozen'], 10) self.assertEqual(len(sim.kt.shelves['overflow']), 0) self.assertEqual(sim.kt.peaks['overflow'], 0) self.assertEqual(sim.cfg['shelf_capacity']['overflow'], 15) self.assertEqual(sim.kt.counts['noshelf'], 0) self.assertEqual(len(sim.kt.capacity_dropped), 0) self.assertEqual(len(sim.kt.wasted), 0) self.assertEqual(sim.kt.counts['ordercheck_wasted'], 0) events = ( orders * 2 ) + 1 # should be 265. because 132 order_received, 132 courier_arrived, 1 shutdown self.assertEqual(events, 265) # can't hurt to check self.assertEqual(sim.kt.counts['events'], events) self.assertEqual(sim.kt.counts['unhand'], 0) self.assertEqual(sim.kt.counts['event:order_received'], orders) self.assertEqual(len(sim.kt.order_ready), orders) self.assertEqual(sim.kt.counts['couriers_dispatched'], orders) self.assertEqual(sim.kt.counts['event:courier_arrived'], orders) self.assertEqual(sim.kt.counts['pickupfail_capdrop'], 0) self.assertEqual(sim.kt.counts['pickupfail_wasted_prior'], 0) self.assertEqual(sim.kt.counts['pickupfail_wasted_now'], 0) self.assertEqual(sim.kt.counts['pickupfail_badloc'], 0) self.assertEqual(sim.kt.counts['orders_delivered'], orders) if self.concurrency == 'P': # because we can only guarantee this upper bound in priority mode: simu_time_span_max = ( (orders - 1) / order_rate) + ca_max # should be 71.5 self.assertEqual(simu_time_span_max, 71.5) # can't hurt to check our math self.assertLessEqual( sim.simu_time_span, simu_time_span_max ) # important for correctness of priority mode
# calls main program import sim sim.main()
def simulationLoop(): for iteration in range(RUNS): #print(iteration) sim.main()
print('wrong command, press enter to continue...') raw_input() clear() continue if com == 0: clear() break elif com == 1: clear() qr.main() print('end of task, press enter to continue...') raw_input() clear() elif com == 2: clear() sim.main() print('end of task, press enter to continue...') raw_input() clear() elif com == 3: clear() rm.main() print('end of task, press enter to continue...') raw_input() clear() elif com == 4: clear() msg.main() print('end of task, press enter to continue...') raw_input() clear()