Example #1
0
 def apply_cfs(self, df):
     y = df.Bugs.values
     X = df.drop(labels=['Bugs'], axis=1)
     X = X.values
     selected_cols = CFS.cfs(X, y)
     cols = df.columns[[selected_cols]].tolist()
     cols.append('Bugs')
     return df[cols], cols
Example #2
0
def apply_cfs(df):
    _cols = df.columns
    y = df.Bugs.values
    X = df.drop(labels=['Bugs'], axis=1)
    X = X.values
    selected_cols = CFS.cfs(X, y)
    fss = []
    cols = df.columns[[selected_cols]].tolist()
    cols.append('Bugs')
    for col in _cols:
        if col in cols:
            fss.append(1)
        else:
            fss.append(0)
    return df[cols], cols, fss
Example #3
0
 def apply_cfs(self, df):
     _cols = df.columns
     y = df.Buggy.values
     X = df.drop(labels=['Buggy'], axis=1)
     X = X.values
     selected_cols = CFS.cfs(X, y)
     fss = []
     imp_fss = []
     cols = df.columns[[selected_cols]].tolist()
     cols.append('Buggy')
     for col in _cols:
         _pos = cols.index(col) if col in cols else 0
         if col in cols:
             fss.append(1)
             imp_fss.append(_pos)
         else:
             fss.append(0)
             imp_fss.append(0)
     return df[cols], cols, fss, imp_fss
def run_all_simulations(numCoresList, numProcessesList):
    """
    sets up and runs all the simulations
    :return:
    """

    # open all statistics file, appending to the end of it
    dirName = gWorkloadType + "_all"
    fileName = gWorkloadType + "_all_statistics_table"
    csvAllStatsTableFile = ScheduleUtilities.open_output_file(
        dirName, fileName, "csv", "a")

    # write the header for the all statistics file
    temp = MachineFCFS.MachineFCFS()
    temp.csv_all_statistics_table_write_header(csvAllStatsTableFile)

    # the type of schedule algorithms
    typeMachinesList = ["fcfs", "roundrobin", "spf", "srtf", "CFS", "FPPQ"]
    numTypeMachines = len(typeMachinesList)

    # 3 dimensional array
    machineMatrix = [[[None for k in range(len(numProcessesList))]
                      for j in range(len(numCoresList))]
                     for i in range(len(typeMachinesList))]

    # print(machineMatrix)
    """
    for i in range(len(typeMachinesList)):
        for j in range(len(numCoresList)):
            for k in range(len(numProcessesList)):
                print(machineMatrix[i][j][k])
    """

    #
    # create all the machines and add them to the matrix
    #
    for j in range(0, len(numCoresList)):
        for k in range(0, len(numProcessesList)):

            # add machines of each type to the matrix

            # FCFS
            machineMatrix[0][j][k] = MachineFCFS.MachineFCFS(numCoresList[j])

            # Round Robin
            machineMatrix[1][j][k] = MachineRoundRobin.MachineRoundRobin(
                numCoresList[j])

            # SPF
            machineMatrix[2][j][
                k] = MachineShortestProcessFirst.MachineShortestProcessFirst(
                    numCoresList[j])

            # SRTF
            machineMatrix[3][j][
                k] = MachineShortestRemainingTimeFirst.MachineShortestRemainingTimeFirst(
                    numCoresList[j])

            # CFS
            machineMatrix[4][j][k] = PreemptiveMachine.PreemptiveMachine(
                CFS.CFS(20, 16), numCoresList[j])

            # FPPQ
            machineMatrix[5][j][k] = FPPQMachine.FPPQMachine(numCoresList[j])

    # print(machineMatrix)

    #
    # create process test cases
    #
    for j in range(0, len(numCoresList)):
        for k in range(0, len(numProcessesList)):

            if gWorkloadType == "lecture":
                for i in range(0, len(typeMachinesList)):
                    ScheduleTests.create_lecture_example(
                        machineMatrix[i][j][k], 3)

            if gWorkloadType == "balanced":
                for i in range(0, len(typeMachinesList)):
                    ScheduleTests.create_balanced_statistical_test(
                        machineMatrix[i][j][k], numProcessesList[k])

            if gWorkloadType == "cpu_heavy":
                for i in range(0, len(typeMachinesList)):
                    ScheduleTests.create_cpu_heavy_statistical_test(
                        machineMatrix[i][j][k], numProcessesList[k])

            if gWorkloadType == "io_heavy":
                for i in range(0, len(typeMachinesList)):
                    ScheduleTests.create_io_heavy_statistical_test(
                        machineMatrix[i][j][k], numProcessesList[k])

            if gWorkloadType == "cpu_only":
                for i in range(0, len(typeMachinesList)):
                    ScheduleTests.create_cpu_only_statistical_test(
                        machineMatrix[i][j][k], numProcessesList[k])

    #
    # run all the simulations
    #
    for i in range(len(typeMachinesList)):
        for j in range(len(numCoresList)):
            for k in range(len(numProcessesList)):

                simName = ""
                simName += "Running simulation: "
                simName += gWorkloadType + "_"
                simName += typeMachinesList[i]
                simName += " with # of cores = " + str(numCoresList[j])
                simName += " and # of processes  = " + str(numProcessesList[k])
                print(simName)

                algorithmName = gWorkloadType + "_" + typeMachinesList[i]
                numCores = numCoresList[j]
                numProcesses = numProcessesList[k]

                # run the simulation
                run_simulation(machineMatrix[i][j][k], algorithmName, numCores,
                               numProcesses)

                # write out the all statistics file, append the final statistics to the all statistics table
                machineMatrix[i][j][k].csv_all_statistics_table_write(
                    csvAllStatsTableFile, algorithmName, numCores,
                    numProcesses)

    # close the all statistics file
    csvAllStatsTableFile.close()