Пример #1
0
    #     arr = [[0] * 4] * 10
    #     for i in range(len(temp)):
    #         if(temp[i]=='0'):
    #             arr[i][0]=1
    #         elif(temp[i]=='1'):
    #             arr[i][1] = 1
    #         elif(temp[i]=='2'):
    #             arr[i][2] = 1
    #         elif(temp[i] == '3'):
    #             arr[i][3] = 1
    #     newarr.append(arr)
    # print(newarr)
    # Utils.save("bianli.npy",newarr) #三维数组

    newarr = np.matrix.tolist(Utils.load("bianli.npy"))
    data = inputdata.get_data()
    xunlianflag = []
    xunliantime = []
    rand_match = []
    num = 0
    len = len(data)
    for adata in data[int(len * 16 / 40):int(len * 17 / 40)]:
        origin_adata = []
        origin_adata.append(adata)
        mintime = 1000000
        favjuece = None
        i = 0
        num = num + 1
        for juece in newarr:
            if (i % 1000 == 0):
                print(juece, num, "->", i)
Пример #2
0
import random
import matplotlib.pyplot as plt
import math, random
import numpy as np
import inputdata
import Utils

ar = [[0, 0, 0, 0] for i in range(10)]
for i in range(10):
    index = random.randint(2, 4)
    ar[i][index - 1] = 1
arr = []
arr.append(ar)
origin_data = inputdata.get_data()
train_data = inputdata.get_input_data(origin_data)
split = int(len(origin_data) * 0.8)
xunlian_data = origin_data[0:split]
pre_data = origin_data[split:len(origin_data)]

pre_time = []
xunlian_time = []
#训练组80%的数据
for i in range(len(xunlian_data)):
    xunlian_adata = []
    xunlian_adata.append(np.array(xunlian_data[i]))
    pici = inputdata.cul_pici(arr, 1)
    dic, b_dic = inputdata.daikuan(xunlian_adata, pici)
    # print("每个批次任务的带宽分配情况:", b_dic)
    time_ = inputdata.jisuan(xunlian_adata, dic, b_dic)
    xunlian_time.append(time_)
print("随机匹配的训练80%任务的时间列表长度", len(xunlian_time))