Esempio n. 1
0
def analyze(output_dir):
    dirr = output_dir + "instances/"

    t0 = ptime()
    node_info, iters, leaf_metric = read_in(dirr)
    # node_info = {'id':names, 'degree':deg, 'benefit':B, 'damage':D, 'solution':soln}
    # 'benefit' = [file#] [node#]
    t1 = ptime()
    print("\nRead_in took " + str(t1 - t0))

    #TEMP FOR HUBS:
    #leaf_metric = "RGAR"

    t0 = ptime()
    freq, maxBD = extract_freq(node_info)
    t1 = ptime()
    print("\nExtract_freq took " + str(t1 - t0))

    t0 = ptime()
    Pr = BD_probability(maxBD)
    t1 = ptime()
    print("\nProbability took " + str(t1 - t0))
    # Pr [B] [D]

    t0 = ptime()
    BD_leaf_fitness = calc_BD_leaf_fitness(
        leaf_metric, maxBD)  #derive leaf metric from file name?
    # BD_leaf_fitness [B] [D]
    t1 = ptime()
    print("\nCalc_leaf_fitness took " + str(t1 - t0))

    t0 = ptime()
    #ETB_score = derive_ETB(node_info, maxBD)
    # ETB_score [file#] [B] [D]
    t1 = ptime()
    print("\nDerive_ETB took " + str(t1 - t0))

    ####PLOTS####
    if not os.path.exists(output_dir + "/BD_plots/"):
        os.makedirs(output_dir + "/BD_plots/")
    if not os.path.exists(output_dir + "/slice_plots/"):
        os.makedirs(output_dir + "/slice_plots/")

    t0 = ptime()
    plot_dir = output_dir + "BD_plots/"
    BD_plots.freq(plot_dir, freq, iters)
    BD_plots.probability(plot_dir, Pr)
    BD_plots.leaf_fitness(plot_dir, BD_leaf_fitness)
    BD_plots.Pr_leaf_fitness(plot_dir, Pr, BD_leaf_fitness)
    #BD_plots.ETB(plot_dir, ETB_score, iters)

    plot_dir = output_dir + "slice_plots/"
    slice_plots.leaf_fitness(plot_dir, Pr, BD_leaf_fitness, None)
    #slice_plots.ETB(plot_dir, ETB_score, iters)

    t1 = ptime()
    print("\nPlots took " + str(t1 - t0))
Esempio n. 2
0
def analyze(output_dir):
    dirr = output_dir + "instances/"

    t0 = ptime()
    node_info, iters, leaf_metric = read_in(dirr)
    t1 = ptime()
    print("\nRead_in took " + str(t1 - t0))

    t0 = ptime()
    freq, maxBD = extract_freq(node_info)
    t1 = ptime()
    print("\nExtract_freq took " + str(t1 - t0))

    t0 = ptime()
    Pr = BD_probability(maxBD)
    t1 = ptime()
    print("\nProbability took " + str(t1 - t0))

    t0 = ptime()
    BD_leaf_fitness = calc_BD_leaf_fitness(
        leaf_metric, maxBD)  #derive leaf metric from file name?
    t1 = ptime()
    print("\nCalc_leaf_fitness took " + str(t1 - t0))

    t0 = ptime()
    t1 = ptime()
    print("\nDerive_ETB took " + str(t1 - t0))

    ####PLOTS####
    if not os.path.exists(output_dir + "/BD_plots/"):
        os.makedirs(output_dir + "/BD_plots/")
    if not os.path.exists(output_dir + "/slice_plots/"):
        os.makedirs(output_dir + "/slice_plots/")

    t0 = ptime()
    plot_dir = output_dir + "BD_plots/"
    BD_plots.freq(plot_dir, freq, iters)
    BD_plots.probability(plot_dir, Pr)
    BD_plots.leaf_fitness(plot_dir, BD_leaf_fitness)
    BD_plots.Pr_leaf_fitness(plot_dir, Pr, BD_leaf_fitness)
    #BD_plots.ETB(plot_dir, ETB_score, iters)

    plot_dir = output_dir + "slice_plots/"
    slice_plots.leaf_fitness(plot_dir, Pr, BD_leaf_fitness, None)
    #slice_plots.ETB(plot_dir, ETB_score, iters)

    t1 = ptime()
    print("\nPlots took " + str(t1 - t0))
Esempio n. 3
0
        'solution': soln
    }
    return node_info, iters, leaf_metric


if __name__ == "__main__":
    #first bash arg should be parent directory, then each child directory
    dirr_base = "/home/2014/choppe1/Documents/EvoNet/virt_workspace/data/output/"

    if (sys.argv[1] == 'degreeFitness'):
        if not os.path.exists(dirr_base + "/degree_fitness/"):
            os.makedirs(dirr_base + "/degree_fitness/")
        for arg in sys.argv[2:]:
            leaf_metric = arg
            Pr = BD_probability(maxBD=20)
            BD_leaf_fitness = calc_BD_leaf_fitness(leaf_metric, maxBD=20)
            slice_plots.leaf_fitness(dirr_base + "/degree_fitness/", Pr,
                                     BD_leaf_fitness, leaf_metric)

    else:
        dirr_parent = sys.argv[1]
        dirr_base += dirr_parent

        for arg in sys.argv[2:]:
            print("Plotting dirr " + str(arg))
            dirr_addon = arg
            dirr = dirr_base + dirr_addon + "/"
            analyze(dirr)

        print("Finished analyzing instances.")