def __call__(self): _wf = wf(self.wf_name) rm = ExperimentResourceManager(rg.r([10, 15, 25, 30])) estimator = ModelTimeEstimator(bandwidth=10) empty_fixed_schedule_part = Schedule({node: [] for node in rm.get_nodes()}) heft_schedule = run_heft(_wf, rm, estimator) fixed_schedule = empty_fixed_schedule_part ga_functions = GAFunctions2(_wf, rm, estimator) generate = partial(ga_generate, ga_functions=ga_functions, fixed_schedule_part=fixed_schedule, current_time=0.0, init_sched_percent=0.05, initial_schedule=heft_schedule) stats = tools.Statistics(lambda ind: ind.fitness.values[0]) stats.register("avg", numpy.mean) stats.register("std", numpy.std) stats.register("min", numpy.min) stats.register("max", numpy.max) logbook = tools.Logbook() logbook.header = ["gen", "evals"] + stats.fields toolbox = Toolbox() toolbox.register("generate", generate) toolbox.register("evaluate", fit_converter(ga_functions.build_fitness(empty_fixed_schedule_part, 0.0))) toolbox.register("clone", deepcopy) toolbox.register("mate", ga_functions.crossover) toolbox.register("sweep_mutation", ga_functions.sweep_mutation) toolbox.register("mutate", ga_functions.mutation) # toolbox.register("select_parents", ) # toolbox.register("select", tools.selTournament, tournsize=4) toolbox.register("select", tools.selRoulette) pop, logbook, best = run_ga(toolbox=toolbox, logbook=logbook, stats=stats, **self.GA_PARAMS) resulted_schedule = ga_functions.build_schedule(best, empty_fixed_schedule_part, 0.0) ga_makespan = Utility.makespan(resulted_schedule) return (ga_makespan, logbook)
def _construct_environment(self, *args, **kwargs): wf_name = kwargs["wf_name"] nodes_conf = kwargs.get("nodes_conf", None) ideal_flops = kwargs.get("ideal_flops", 20) transfer_time = kwargs.get("transfer_time", 100) dax1 = '../../resources/' + wf_name + '.xml' # wf = Utility.readWorkflow(dax1, wf_name) _wf = wf(wf_name) rgen = ResourceGenerator(min_res_count=1, max_res_count=1, min_node_count=4, max_node_count=4, min_flops=5, max_flops=10) resources = rgen.generate() transferMx = rgen.generateTransferMatrix(resources) if nodes_conf is None: bundle = Utility.get_default_bundle() resources = bundle.dedicated_resources transferMx = bundle.transfer_mx ideal_flops = bundle.ideal_flops ##TODO: end else: ## TODO: refactor it later. resources = ResourceGenerator.r(nodes_conf) transferMx = rgen.generateTransferMatrix(resources) ## estimator = ExperimentEstimator(transferMx, ideal_flops, dict(), transfer_time) resource_manager = ExperimentResourceManager(resources) return (_wf, resource_manager, estimator)
import numpy from src.algs.gsa.SimpleGsaScheme import run_gsa from src.algs.gsa.operators import G, Kbest from src.algs.gsa.ordering_mapping_operators import force, mapping_update, ordering_update, CompoundParticle, generate from src.algs.heft.DSimpleHeft import run_heft from src.algs.pso.ordering_operators import fitness, build_schedule from src.core.CommonComponents.ExperimentalManagers import ExperimentResourceManager from src.core.environment.ResourceGenerator import ResourceGenerator as rg from src.core.environment.Utility import wf, Utility from src.experiments.cga.mobjective.utility import SimpleTimeCostEstimator from src.experiments.cga.utilities.common import repeat _wf = wf("Montage_50") rm = ExperimentResourceManager(rg.r([10, 15, 25, 30])) estimator = SimpleTimeCostEstimator(comp_time_cost=0, transf_time_cost=0, transferMx=None, ideal_flops=20, transfer_time=100) heft_schedule = run_heft(_wf, rm, estimator) heft_particle = generate(_wf, rm, estimator, heft_schedule) heft_gen = lambda n: [deepcopy(heft_particle) if random.random() > 1.00 else generate(_wf, rm, estimator) for _ in range(n)] # def heft_gen(n): # heft_count = int(n*0.05) # pop = [deepcopy(heft_particle) for _ in range(heft_count)] # for _ in range(n - heft_count): # variant = gen() # hp = deepcopy(heft_particle)
from src.algs.heft.DSimpleHeft import run_heft from src.core.CommonComponents.ExperimentalManager import ExperimentResourceManager, ModelTimeEstimator from src.core.environment.Utility import wf, Utility from src.core.environment.ResourceGenerator import ResourceGenerator as rg ideal_flops = 8.0 rm = ExperimentResourceManager(rg.r([4.0, 8.0, 8.0, 16.0])) estimator = ModelTimeEstimator(bandwidth=10) # скорость передачи данных 10 MB/sec def do_exp(wf_name): _wf = wf(wf_name) heft_schedule = run_heft(_wf, rm, estimator) makespan = Utility.makespan(heft_schedule) return makespan if __name__ == "__main__": result = do_exp("Montage_25") print(result)
def env(self): if not self._wf or not self._rm or not self._estimator: self._wf = wf(self.wf_name) self._rm = ExperimentResourceManager(rg.r(self._resorces_set)) self._estimator = ModelTimeEstimator(bandwidth=10) return self._wf, self._rm, self._estimator
def do_exp_heft_schedule(): res = do_exp_schedule(True) return (res[0], res[5]) def do_exp_ga_schedule(): res = do_exp_schedule(False) return (res[0], res[4]) if __name__ == '__main__': print("Population size: " + str(PARAMS["ga_params"]["population"])) _wf = wf(wf_names[0]) rm = ExperimentResourceManager(rg.r(PARAMS["nodes_conf"])) estimator = SimpleTimeCostEstimator(comp_time_cost=0, transf_time_cost=0, transferMx=None, ideal_flops=PARAMS["ideal_flops"], transfer_time=PARAMS["transfer_time"]) heft_schedule = run_heft(_wf, rm, estimator) heft_makespan = Utility.makespan(heft_schedule) overall_transfer = Utility.overall_transfer_time(heft_schedule, _wf, estimator) overall_execution = Utility.overall_execution_time(heft_schedule) print( "Heft makespan: {0}, Overall transfer time: {1}, Overall execution time: {2}" .format(heft_makespan, overall_transfer, overall_execution))