def default_config(wf, rm, estimator): selector = lambda env, pop: tools.selTournament(pop, len(pop), 4) return { "interact_individuals_count": 22, "generations": 5, "env": Env(wf, rm, estimator), "species": [ Specie(name=MAPPING_SPECIE, pop_size=10, cxb=0.8, mb=0.5, mate=lambda env, child1, child2: tools.cxOnePoint( child1, child2), mutate=mapping_default_mutate, select=selector, initialize=mapping_default_initialize), Specie( name=ORDERING_SPECIE, pop_size=10, cxb=0.8, mb=0.5, mate=ordering_default_crossover, mutate=ordering_default_mutate, select=selector, initialize=ordering_default_initialize, ) ], "operators": { # "choose": default_choose, "build_solutions": default_build_solutions, "fitness": fitness_mapping_and_ordering, "assign_credits": default_assign_credits } }
def test_fixed_specie(self): wf_name = "Montage_25" wf = WF(wf_name) manager = ExperimentResourceManager( ResourceGenerator.r([10, 15, 15, 25])) estimator = ExperimentEstimator(None, 20, 1.0, transfer_time=100) config = default_config(wf, manager, estimator) ms_ideal_ind = build_ms_ideal_ind(wf, manager) config["species"][0] = Specie( name=MAPPING_SPECIE, fixed=True, representative_individual=ListBasedIndividual(ms_ideal_ind)) solution, pops, logbook, initial_pops = run_cooperative_ga(**config) schedule = build_schedule(wf, estimator, manager, solution) for k, items in schedule.mapping.items(): for item in items: item.state = ScheduleItem.FINISHED ## TODO: refactor this ExecutorRunner.extract_result(schedule, True, wf) pass
Env(_wf, rm, estimator), "species": [ Specie( name=MAPPING_SPECIE, pop_size=50, cxb=0.9, mb=0.9, mate=lambda env, child1, child2: tools.cxOnePoint(child1, child2), # mutate=mapping_all_mutate, # mutate=mapping_all_mutate_variable, mutate=mapping_mut_reg(mapping_all_mutate_configurable), # mutate=mapping_all_mutate_variable2, # mutate=mapping_improving_mutation, # mutate=mapping_default_mutate, # mutate=MappingArchiveMutate(), select=mapping_selector, # initialize=mapping_default_initialize, initialize=lambda ctx, pop: mapping_heft_based_initialize( ctx, pop, heft_mapping, 3), stat=lambda pop: { "hamming_distances": hamming_distances([to_seq(p) for p in pop], to_seq(ms_ideal_ind)), "unique_inds_count": unique_individuals(pop), "pcm": pcm(pop), "gdm": gdm(pop) }), Specie( name=ORDERING_SPECIE,
def do_exp(): config = { "interact_individuals_count": 100, "generations": 300, "env": Env(_wf, rm, estimator), "species": [ Specie( name=MAPPING_SPECIE, pop_size=50, cxb=0.9, mb=0.9, mate=lambda env, child1, child2: tools.cxOnePoint( child1, child2), # mutate=mapping_default_mutate, # mutate=lambda ctx, mutant: mapping_k_mutate(ctx, 3, mutant) mutate=mapping_all_mutate, # mutate=OnlyUniqueMutant()(mapping_all_mutate), select=selector, # initialize=mapping_default_initialize, initialize=lambda ctx, pop: mapping_heft_based_initialize( ctx, pop, heft_mapping, 3), stat=lambda pop: { "hamming_distances": hamming_distances([to_seq(p) for p in pop], to_seq(ms_ideal_ind)), "unique_inds_count": unique_individuals(pop), "pcm": pcm(pop), "gdm": gdm(pop) }), Specie(name=ORDERING_SPECIE, fixed=True, representative_individual=ListBasedIndividual( os_representative)) ], "solstat": lambda sols: { "best_components": hamming_for_best_components(sols, ms_ideal_ind, os_ideal_ind), "best_components_itself": best_components_itself(sols), "best": -1 * Utility.makespan( build_schedule(_wf, estimator, rm, max(sols, key=lambda x: x.fitness))) }, "operators": { # "choose": default_choose, "build_solutions": default_build_solutions, "fitness": fitness_mapping_and_ordering, # "fitness": overhead_fitness_mapping_and_ordering, # "assign_credits": default_assign_credits # "assign_credits": max_assign_credits "assign_credits": assign_from_transfer_overhead } } return do_experiment(saver, config, _wf, rm, estimator)
heft_mapping = extract_mapping_from_ga_file( "{0}/temp/heft_etalon_full_tr100_m50.json".format(__root_path__), rm) os_ideal_ind = build_os_ideal_ind(_wf) ms_ideal_ind = heft_mapping config = { "interact_individuals_count": 200, "generations": 300, "env": Env(_wf, rm, estimator), "species": [ Specie( name=MAPPING_SPECIE, fixed=True, representative_individual=ListBasedIndividual(ms_representative)), Specie( name=ORDERING_SPECIE, pop_size=50, cxb=0.8, mb=0.5, mate=ordering_default_crossover, mutate=ordering_default_mutate, select=selector, # initialize=ordering_default_initialize, initialize=lambda ctx, pop: ordering_heft_based_initialize( ctx, pop, heft_ordering, 3), stat=lambda pop: {"hamming_distances": hamming_distances(pop, os_ideal_ind)}) ],