コード例 #1
0
    def __init__(self, workflow, resource_manager, estimator):

        self.counter = 0
        self.workflow = workflow

        ##interface Estimator

        self.estimator = estimator
        self.resource_manager = resource_manager

        nodes = resource_manager.get_nodes(
        )  #list(HeftHelper.to_nodes(resource_manager.get_resources()))
        ranking = HeftHelper.build_ranking_func(
            nodes, lambda job, agent: estimator.estimate_runtime(job, agent),
            lambda ni, nj, A, B: estimator.estimate_transfer_time(
                A, B, ni, nj))
        sorted_tasks = ranking(self.workflow)

        self.nodes = nodes
        self.sorted_tasks = sorted_tasks
        self.workflow_size = len(sorted_tasks)

        self.task_map = {task.id: task for task in sorted_tasks}
        self.node_map = {node.name: node for node in nodes}

        self.initializing_alg = SimpleRandomizedHeuristic(
            self.workflow, self.nodes, self.estimator)

        self.initial_chromosome = None  ##GAFunctions.schedule_to_chromosome(initial_schedule)
        pass
コード例 #2
0
def generate(wf, rm, estimator, n):
    pop = []
    for i in range(n):
        sched = SimpleRandomizedHeuristic(wf, rm.get_nodes(), estimator).schedule()
        particle = schedule_to_position(sched)
        particle.velocity = MappingParticle.Velocity({})
        pop.append(particle)
    return pop
コード例 #3
0
def generate(n):
    schedules = [SimpleRandomizedHeuristic(_wf, rm.get_nodes(), estimator).schedule() for _ in range(n)]
    mapping_positions = [schedule_to_position(s).entity for s in schedules]
    ordering_individuals = [ordering_from_schedule(s) for s in schedules]
    pop = []
    for mp, os in zip(mapping_positions, ordering_individuals):
        p = ParticleIndividual(Position(mp))
        p.ordering = os
        pop.append(p)
    return pop
コード例 #4
0
def generate(wf, rm, estimator, schedule=None, fixed_schedule_part=None, current_time=0.0):
    sched = schedule if schedule is not None else SimpleRandomizedHeuristic(wf, rm.get_nodes(), estimator).schedule(fixed_schedule_part, current_time)

    if fixed_schedule_part is not None:
        un_tasks = unmoveable_tasks(fixed_schedule_part)
        clean_sched = Schedule({node: [item for item in items if item.job.id not in un_tasks and item.state != ScheduleItem.FAILED]
                          for node, items in sched.mapping.items()})
    else:
        clean_sched = sched

    mapping, ordering = ord_and_map(clean_sched)
    ordering_numseq = ordering_to_numseq(ordering)
    ordering_map = {task_id: val for task_id, val in zip(ordering, ordering_numseq)}
    ord_p, map_p = OrderingParticle(ordering_map), MappingParticle(mapping)
    ord_p.velocity = OrderingParticle.Velocity({})
    map_p.velocity = MappingParticle.Velocity({})

    result = CompoundParticle(map_p, ord_p)
    if schedule is None and not validate_mapping_with_alive_nodes(result.mapping.entity, rm):
        raise Exception("found invalid solution in generated array")
    return result
コード例 #5
0
def generate(wf, rm, estimator):
    sched = SimpleRandomizedHeuristic(wf, rm.get_nodes(), estimator).schedule()
    return schedule_to_position(sched)