예제 #1
0
def main():
    print 'main function begin.'
    path_abc = [
        'E:/1/TrainData_2015.1.1_2015.2.19.txt',
        'E:/1/input_5flavors_cpu_7days.txt', 'E:/1/result.txt'
    ]
    # if len(sys.argv) != 4:
    #     print 'parameter is incorrect!'
    #     print 'Usage: python esc.py ecsDataPath inputFilePath resultFilePath'
    #     exit(1)
    # Read the input files
    ecsDataPath = path_abc[0]
    inputFilePath = path_abc[1]
    resultFilePath = path_abc[2]

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)
    # implementation the function predictVm
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)
    # write the result to output file
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print 'main function end.'
예제 #2
0
def main():
    print 'main function begin.'
    if len(sys.argv) != 4:
        print 'parameter is incorrect!'
        print 'Usage: python esc.py ecsDataPath inputFilePath resultFilePath'
        exit(1)


#     Read the input files
    ecsDataPath = sys.argv[1]
    inputFilePath = sys.argv[2]
    resultFilePath = sys.argv[3]

    #直接输入路径参数便于调试
    #    ecsDataPath = './data/TrainData.txt'
    #    inputFilePath = './data/input_5flavors_cpu_7days.txt'
    #    resultFilePath = './data/output.txt'

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)

    # implementation the function predictVm
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)
    # write the result to output file
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print 'main function end.'
예제 #3
0
def main():
    print 'main function begin.'
    if len(sys.argv) != 4:
        print 'parameter is incorrect!'
        print 'Usage: python esc.py ecsDataPath inputFilePath resultFilePath'
        exit(1)
    # Read the input files
    time_start = time.time()
    ecsDataPath = sys.argv[1]
    inputFilePath = sys.argv[2]
    resultFilePath = sys.argv[3]

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)
    # implementation the function predictVm
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array,time_start)
    # write the result to output file
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)

    time_end = time.time()
    delta_time = time_end - time_start
    print('ECS总时间')
    print( delta_time)
    print 'main function end.'
예제 #4
0
def main():

    print 'main function begin.'
    if len(sys.argv) != 4:
        print 'parameter is incorrect!'
        print 'Usage: python esc.py ecsDataPath inputFilePath resultFilePath'
        exit(1)
    # Read the input files
    inputFilePath = sys.argv[1]
    ecsDataPath = sys.argv[2]
    resultFilePath = sys.argv[3]
    '''
    # read the path of file
    ecsDataPath = "Data/input_5flavors_cpu_7days.txt"
    inputFilePath ="Data/data_2016_1.txt"
    resultFilePath = "Data/results.txt"
    '''
    #read the file
    ecs_infor_array = read_lines(ecsDataPath)

    input_file_array = read_lines(inputFilePath)

    # implementation the function predictVm
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)

    # write the result to output file
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print 'main function end.'
예제 #5
0
def main():
    # print('main function begin.')
    # if len(sys.argv) != 4:
    #     print('parameter is incorrect!')
    #     print('Usage: python esc.py ecsDataPath inputFilePath resultFilePath')
    #     exit(1)
    # Read the input files
    # ecsDataPath = sys.argv[1]
    # inputFilePath = sys.argv[2]
    # resultFilePath = sys.argv[3]
    ecsDataPath = 'test.txt'
    inputFilePath = 'input.txt'
    resultFilePath = 'result.txt'

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)
    # implementation the function predictVm
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)
    # write the result to output file
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print('main function end.')
def main():
    # print 'main function begin.'
    if len(sys.argv) != 4:
        print 'parameter is incorrect!'
        print 'Usage: python esc.py ecsDataPath inputFilePath resultFilePath'
        exit(1)
    # Read the input files
    ecsDataPath = sys.argv[1]
    inputFilePath = sys.argv[2]
    resultFilePath = sys.argv[3]
    Physource, flavornums, flavordic, Optsource, period, time1, time2 = getSourceInfo(
        inputFilePath)
    dataset = getAndprocess_originaldata(ecsDataPath,
                                         flavordic)  # 得到的数据都是符合要求的
    # dataset, yanzh = SplitdatasetByday(dataSet, 2 * period - 1)
    ecs_infor_array = dataset
    input_file_array = [
        Physource, flavornums, flavordic, Optsource, period, time1, time2
    ]
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)  #
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print 'main function end.'
예제 #7
0
def main():
    print ('main function begin.')
    if len(sys.argv) != 4:
        print ('parameter is incorrect!')
        print ('Usage: python esc.py ecsDataPath inputFilePath resultFilePath')
        exit(1)
    # Read the input files
    ecsDataPath = sys.argv[1]
    inputFilePath = sys.argv[2]
    resultFilePath = sys.argv[3]
    # ecsDataPath = '.\初赛文档\用例示例\TrainData_2015.1.1_2015.2.19.txt'
    # inputFilePath = '.\初赛文档\用例示例\input_5flavors_cpu_7days.txt'
    # resultFilePath = 'output.txt'

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)
    # implementation the function predictVm
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)
    # write the result to output file
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print ('main function end.')
예제 #8
0
def main():
    print 'main function begin.'
    if len(sys.argv) != 4:
        print 'parameter is incorrect!'
        print 'Usage: python esc.py ecsDataPath inputFilePath resultFilePath'
        exit(1)
    # Read the input files
    ecsDataPath = sys.argv[1]
    inputFilePath = sys.argv[2]
    resultFilePath = sys.argv[3]

    ecs_infor_array = read_lines(ecsDataPath)
    #by yzw 20180316
    #print ecs_infor_array[0]
    input_file_array = read_lines(inputFilePath)
    #print(input_file_array)
    # implementation the function predictVm
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)
    # write the result to output file
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print 'main function end.'
예제 #9
0
def main(k, threshold):

    # if len(sys.argv) != 4:
    #     print 'parameter is incorrect!'
    #     print 'Usage: python esc.py ecsDataPath inputFilePath resultFilePath'
    #     exit(1)
    # Read the input files
    # ecs_infor_array = read_lines(ecsDataPath)
    # input_file_array = read_lines(inputFilePath)
    # implementation the function predictVm
    # write the result to output file
    # if len(predic_result) != 0:
    #     write_result(predic_result, resultFilePath)
    # else:
    #     predic_result.append("NA")
    #     write_result(predic_result, resultFilePath)
    # print 'main function end.'
    ecsDataPath = sys.argv[1]
    inputFilePath = sys.argv[2]
    resultFilePath = sys.argv[3]

    predictor.predict_vm(ecsDataPath, inputFilePath, resultFilePath, k,
                         threshold)
예제 #10
0
def main():
    print 'main function begin.'
    # Read the input files
    ecsDataPath = "TrainData.txt"
    inputFilePath = "input.txt"
    resultFilePath='output.txt'
    ecs_infor_array = read_lines(ecsDataPath)
    #print(ecs_infor_array)
    input_file_array = read_lines(inputFilePath)
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)
    print predic_result
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print 'main function end.'
예제 #11
0
def main():
    # ecsDataPath = '../../data/TrainData.txt' #sys.argv[1]
    # inputFilePath = '../../data/input.txt' # sys.argv[2]
    # resultFilePath = '../../data/output.txt' # sys.argv[3]

    ecsDataPath = '../../data/TrainData_2015.1.1_2015.2.19.txt'  # sys.argv[1]
    ecsDataPath = '../../data/mynewdata4.txt'  # sys.argv[1]
    inputFilePath = '../../data/input_5flavors_cpu_7days.txt'  # sys.argv[2]
    resultFilePath = '../../data/output_result.txt'  # sys.argv[3]

    ecs_infor_array = ecs.read_lines(ecsDataPath)
    input_file_array = ecs.read_lines(inputFilePath)
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)
    if len(predic_result) != 0:
        ecs.write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        ecs.write_result(predic_result, resultFilePath)
예제 #12
0
def main():
    print('main function begin.')
    # if len(sys.argv) != 4:
    #       print ('parameter is incorrect!')
    #       print ('Usage: python esc.py ecsDataPath inputFilePath resultFilePath')
    #       exit(1)
    #Read the input files
    ecsDataPath = 'data_train.txt'  #sys.argv[1]
    inputFilePath = 'input.txt'  #sys.argv[2]
    resultFilePath = 'output.txt'  #sys.argv[3]

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)

    input_infor = getinput(input_file_array)

    predic_result = predictor.predict_vm(ecs_infor_array, input_infor)
    server, utilization = knapsack_problem.assign(predic_result,
                                                  input_infor)  # TODO 2

    result = []
    result.append(sum(predic_result))
    i = 0
    for flavor in input_infor['flavor']:
        result.append(flavor + ' ' + str(predic_result[i]))
        i += 1
    result.append('')
    result.append(len(server))
    for i in range(len(server)):
        string = str(i + 1)
        j = 1
        for value in server[i][1:]:
            if value != 0:
                string += '  ' + 'flavor' + str(j) + '  ' + str(value)
            j += 1
        result.append(string)

    # write the result to output file
    if len(result) != 0:
        write_result(result, resultFilePath)
    else:
        result.append("NA")
        write_result(result, resultFilePath)
    print('main function end.')
예제 #13
0
def main():
    print 'main function begin.'
    # Read the input files
    ecsDataPath = '../test_file/TrainData.txt'
    inputFilePath = '../test_file/input_15flavors_cpu_7days.txt'
    resultFilePath = '../test_file/output.txt'

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)

    # implementation the function predictVm
    predic_result = predictor.predict_vm(ecs_infor_array,
                                         input_file_array)  #调用预测函数,返回结果
    print predic_result
    # 写入结果
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print 'main function end.'
예제 #14
0
def main():
    print 'main function begin.'
    start = time.clock()

    if len(sys.argv) != 4:
        print 'parameter is incorrect!'
        print 'Usage: python esc.py ecsDataPath inputFilePath resultFilePath'
        exit(1)

    # Read the input files

    ecsDataPath = sys.argv[1]#'./TrainData_2015.1.1_2015.2.19.txt' #
    inputFilePath = sys.argv[2]#'./input_5flavors_cpu_7days.txt' #
    resultFilePath = sys.argv[3]#'./output_file.txt' #
    '''
    ecsDataPath = './data_2015_1-5.txt'#'./TrainData_2015.1.1_2015.2.19.txt' #
    #inputFilePath = './input_5flavors_cpu_7days.txt'#'./data_2015_1-5.txt'#'./TrainData_2015.1.1_2015.2.19.txt'#'./data_2015_1-5.txt' #
    inputFilePath = './input_5flavors_cpu_7days.txt'
    resultFilePath = './output_file.txt'
    testFilePath ='./test5.23-5.29.txt'#'./TestData_2015.2.20_2015.2.27.txt'#
    '''
    ecs_info_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)
    #test_array = read_lines(testFilePath)

    # implementation the function predictVm
    #predict_result = predictor.predict_vm(ecs_info_array, input_file_array, test_array)
    predict_result = predictor.predict_vm(ecs_info_array, input_file_array)
    # write the result to output file
    if len(predict_result) != 0:
        write_result(predict_result, resultFilePath)
    else:
        predict_result.append("NA")
        write_result(predict_result, resultFilePath)

    print 'main function end.'
    elapsed = (time.clock() - start)
    print 'time used :'
    print elapsed
예제 #15
0
def main():
    print 'main function begin.'
    if len(sys.argv) != 4:
        print 'parameter is incorrect!'
        print 'Usage: python esc.py ecsDataPath inputFilePath resultFilePath'
        exit(1)
    # Read the input files
    ecsDataPath = sys.argv[1]
    inputFilePath = sys.argv[2]
    resultFilePath = sys.argv[3]

    # ecsDataPath = '../../data/TrainData_2015.1.1_2015.2.19.txt'
    # inputFilePath = '../../data/input_5flavors_cpu_7days.txt'
    # resultFilePath = '../../data/result.txt'
    # testFilePath = '../../data/TestData_2015.2.20_2015.2.27.txt'

    # ecsDataPath = '../../data/train_2016_1.txt'
    # inputFilePath = '../../data/input_2.txt'
    # resultFilePath = '../../data/result.txt'
    # testFilePath = '../../data/test_2016_1.txt'

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)
    # implementation the function predictVm
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)
    # write the result to output file
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)

    # #test
    # test_infor_array = read_lines(testFilePath)
    # testresult = predictor.test_vm(test_infor_array,input_file_array,predic_result)
    # print testresult


    print 'main function end.'
예제 #16
0
def main():
    print 'main function begin.'
    # if len(sys.argv) != 4:
    #     print 'parameter is incorrect!'
    #     print 'Usage: python esc.py ecsDataPath inputFilePath resultFilePath'
    #     exit(1)
    # Read the input files
    ecsDataPath = '../../data_2015_3.txt'  #sys.argv[1]
    inputFilePath = '../../inputpar.txt'  #sys.argv[2]
    resultFilePath = '../../output.txt'  #sys.argv[3]

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)
    # implementation the function predictVm
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)
    # write the result to output file
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print 'main function end.'
예제 #17
0
def main():
    print('main function begin.')
    #f len(sys.argv) != 4:
    #print('parameter is incorrect!')
    #print('Usage: python esc.py ecsDataPath inputFilePath resultFilePath')
    #exit(1)
    # Read the input files
    ecsDataPath = 'TrainData_2015.12.txt'
    inputFilePath = 'input_3hosttypes_5flavors_1week.txt'
    resultFilePath = 'result.txt'

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)
    print(ecs_infor_array)
    print(input_file_array)
    # implementation the function predictVm
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)
    # write the result to output file
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print('main function end.')
예제 #18
0
def main():
    print 'main function begin.'
    if len(sys.argv) != 5:
        print 'parameter is incorrect!'
        print 'Usage: python esc.py ecsDataPath inputFilePath resultFilePath'
        exit(1)
    # Read the input files

    ecsDataPath = sys.argv[1]
    inputFilePath = sys.argv[2]
    resultFilePath = sys.argv[3]
    realflavorPath = sys.argv[4]

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)
    real_flavor_array = read_lines(realflavorPath)

    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array,real_flavor_array)
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)
    print 'main function end.'
        linedata = line.split()
        if int(linedata[1][6:]) > 15:
            pass
        else:
            datalist.append(int(linedata[1][6:]))
    #datalist[np.where(datalist!=3)] = 0
    plt.figure()
    plt.plot(datalist)
    plt.show()
    return datalist
'''

if __name__ == "__main__":

    ecsDataPath = 'TrainData_2015.1.1_2015.2.19.txt'
    inputFilePath = 'input_5flavors_cpu_7days.txt'
    resultFilePath = 'output1.txt'

    ecs_infor_array = read_lines(ecsDataPath)
    input_file_array = read_lines(inputFilePath)

    ## DEBUG
    # implementation the function predictVM
    predic_result = predictor.predict_vm(ecs_infor_array, input_file_array)
    # write the result to output file
    if len(predic_result) != 0:
        write_result(predic_result, resultFilePath)
    else:
        predic_result.append("NA")
        write_result(predic_result, resultFilePath)