def pre_optimal_ass(pool_of_tasks, v, pos): """ 生成pre_scheduling assignment :param pool_of_tasks: 任务池 :param v:虚拟机列表 :return: pre_opt_ass """ pre_opt_ass = [] for l in range(10000): if not pool_of_tasks.empty(): tl1 = pool_of_tasks.get() # print(pool_of_tasks.empty(), len(tl1), tl1) et1 = t.test_et(v, tl1, pos) ass1, f1, delays1 = t.ass1(v, tl1, et1, pos) pre_opt_ass += delays1 else: break if not pool_of_tasks.empty(): tl2 = pool_of_tasks.get() # print (pool_of_tasks.empty (), len(tl2), tl2) et2 = t.test_et(v, tl2, pos) wl = t.rand_wl(v, tl2, 3, 6) ass2, f2, delays2 = t.ass2(v, tl2, wl, et2, pos) pre_opt_ass += delays2 else: break if not pool_of_tasks.empty(): tl3 = pool_of_tasks.get() # print(pool_of_tasks.empty(), len(tl3), tl3) et3 = t.test_et(v, tl3, pos) unit_price = t.unit_price(v) pt3 = t.rand_pt(v, tl3, et3, unit_price, pos) ass3, f3, delays3 = t.ass3(v, tl3, et3, pt3, pos) pre_opt_ass += delays3 else: break taskNum = len(pre_opt_ass) gameSta = round(taskNum / 8) print('预分配结束', taskNum, gameSta, pre_opt_ass) return pre_opt_ass, taskNum, gameSta
exec_pro1 = [7.1, 5.8, 4.8] exec_pro2 = [7.4, 6.2, 5.1] exec_pro3 = [6.7, 5.5, 4.3] exec_v = exec_pro1 + exec_pro2 + exec_pro3 pri_pro1 = [0.023, 0.0464, 0.0928] pri_pro2 = [0.0246, 0.0493, 0.0739] pri_pro3 = [0.1053, 0.1244, 0.1373] price = pri_pro1 + pri_pro2 + pri_pro3 Tn = w1 + w2 + w3 + w4 + w5 Vn = p1 + p2 + p3 V = t.rand_v('v', Vn) vm_price = t.unit_price(V) task_pool = t.t_pool(Tn, 10000) # 层级上限是10000 print('round ' + pos) pre_optimal_ass_fifoi, task_number, game_stage = pre_optimal_ass_fifo( task_pool, V, pos) use_submit(pre_optimal_ass_fifoi, V, pos) # 后续采集task number, game stage, makespan, workload, profit数据 print('采集数据') csv_file = '.\\datafile\\' + pos + '\\res.csv' ass1_file = '.\\datafile\\' + pos + '\\ass1.in' ass2_file = '.\\datafile\\' + pos + '\\ass2.in' ass3_file = '.\\datafile\\' + pos + '\\ass3.in' pid_nums = g.pid_num(csv_file) task_nums = g.task_num(csv_file) tasks = g.task(csv_file)