Ejemplo n.º 1
0
def generate_final_frontier_for_gale4(problems, algorithms, Configurations, tag=""):
    if "GALE4" not in [algorithm.name for algorithm in algorithms]:
        return
    else:
        for problem in problems:
            from Graphics.PerformanceMeasures.DataFrame import ProblemFrame
            data = ProblemFrame(problem, [a for a in algorithms if a.name == "GALE4"])

            # data for all repeats
            total_data = [data.get_frontier_values(gen_no) for gen_no in
                          xrange(Configurations["Universal"]["No_of_Generations"])]

            data_for_all_generations = []
            for repeat in xrange(Configurations["Universal"]["Repeats"]):
                temp_data = []
                for gen_no in xrange(Configurations["Universal"]["No_of_Generations"]):
                    temp_data.extend(total_data[gen_no]["GALE4"][repeat])

                from jmoo_individual import jmoo_individual
                solutions = [jmoo_individual(problem, td.decisions, problem.evaluate(td.decisions)) for td in temp_data]

                # non dominated sorting
                from jmoo_algorithms import selNSGA2
                final_solutions, _ = selNSGA2(problem, [], solutions, Configurations)

                for i in xrange(Configurations["Universal"]["No_of_Generations"]):
                    filename = "./RawData/PopulationArchives/" + "GALE4" + "_" + problem.name + "/" + str(
                            repeat) + "/" + \
                               str(i + 1) + ".txt"
                    f = open(filename, "w")
                    for fs in final_solutions:
                        f.write(','.join([str(fss) for fss in fs.decisionValues]) + "," + ",".join(
                                [str(fss) for fss in fs.fitness.fitness]) + "\n")
                    f.close()
Ejemplo n.º 2
0
def generate_final_frontier_for_gale4(problems,
                                      algorithms,
                                      Configurations,
                                      tag=""):
    if "GALE4" not in [algorithm.name for algorithm in algorithms]: return
    else:
        for problem in problems:
            from Graphics.PerformanceMeasures.DataFrame import ProblemFrame
            data = ProblemFrame(problem,
                                [a for a in algorithms if a.name == "GALE4"])

            # data for all repeats
            total_data = [
                data.get_frontier_values(gen_no) for gen_no in xrange(
                    Configurations["Universal"]["No_of_Generations"])
            ]

            data_for_all_generations = []
            for repeat in xrange(Configurations["Universal"]["Repeats"]):
                temp_data = []
                for gen_no in xrange(
                        Configurations["Universal"]["No_of_Generations"]):
                    temp_data.extend(total_data[gen_no]["GALE4"][repeat])

                from jmoo_individual import jmoo_individual
                solutions = [
                    jmoo_individual(problem, td.decisions,
                                    problem.evaluate(td.decisions))
                    for td in temp_data
                ]

                # non dominated sorting
                from jmoo_algorithms import selNSGA2
                final_solutions, _ = selNSGA2(problem, [], solutions,
                                              Configurations)

                for i in xrange(
                        Configurations["Universal"]["No_of_Generations"]):
                    filename = "./RawData/PopulationArchives/" + "GALE4" + "_" + problem.name + "/" + str(repeat) + "/" + \
                               str(i+1) + ".txt"
                    f = open(filename, "w")
                    for fs in final_solutions:
                        f.write(
                            ','.join([str(fss)
                                      for fss in fs.decisionValues]) + "," +
                            ",".join([str(fss)
                                      for fss in fs.fitness.fitness]) + "\n")
                    f.close()
Ejemplo n.º 3
0
def compare_methods(problem):
    initialPopulation(problem, Configurations["Universal"]["Population_Size"] * 2, "unittesting")
    population = problem.loadInitialPopulation(Configurations["Universal"]["Population_Size"] * 2, "unittesting")
    population = add_id_to_population(population)
    approx, approx_eval = do_fastmap_domination(problem, population)

    # non dominated sorting
    from jmoo_algorithms import selNSGA2
    final_solutions, _ = selNSGA2(problem, [], population, Configurations)

    approx_id = [a.id for a in approx]
    final_id = [f.id for f in assign_ids(population, final_solutions)]

    count = 0
    for aid in approx_id:
        if aid in final_id: count += 1

    # print "Name: ",problem.name, " Match: ", round((count/len(final_id)) * 100, 2), "Approx Evals: ", approx_eval, "Total Evaluation: ", Configurations["Universal"]["Population_Size"] * 2
    return round((count/len(final_id)) * 100, 2)
Ejemplo n.º 4
0
def compare_methods(problem):
    initialPopulation(problem, Configurations["Universal"]["Population_Size"] * 2, "unittesting")
    population = problem.loadInitialPopulation(Configurations["Universal"]["Population_Size"] * 2, "unittesting")
    population = add_id_to_population(population)
    approx, approx_eval = do_fastmap_domination(problem, population)

    # non dominated sorting
    from jmoo_algorithms import selNSGA2
    final_solutions, _ = selNSGA2(problem, [], population, Configurations)

    approx_id = [a.id for a in approx]
    final_id = [f.id for f in assign_ids(population, final_solutions)]

    count = 0
    for aid in approx_id:
        if aid in final_id: count += 1

    # print "Name: ",problem.name, " Match: ", round((count/len(final_id)) * 100, 2), "Approx Evals: ", approx_eval, "Total Evaluation: ", Configurations["Universal"]["Population_Size"] * 2
    return round((count/len(final_id)) * 100, 2)