hcpt.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:pysimgrid 作者: alexmnazarenko 项目源码 文件源码
def get_tasks_aest_alst(cls, nxgraph, platform_model):
    """
    Return AEST and ALST of tasks.

    Args:
      nxgraph: full task graph as networkx.DiGraph
      platform_model: cscheduling.PlatformModel object

    Returns:
      tuple containg 2 dictionaries
        aest: task->aest_value
        alst: task->alst_value
    """
    mean_speed = platform_model.mean_speed
    mean_bandwidth = platform_model.mean_bandwidth
    mean_latency = platform_model.mean_latency
    topological_order = networkx.topological_sort(nxgraph)

    # Average execution cost
    aec = {task: float(task.amount) / mean_speed for task in nxgraph}

    # Average earliest start time
    aest = {}
    # TODO: Check several roots and ends!
    root = topological_order[0]
    end = topological_order[-1]
    aest[root] = 0.
    for task in topological_order:
      parents = nxgraph.pred[task]
      if not parents:
        aest[task] = 0
        continue
      aest[task] = max([
        aest[parent] + aec[parent] + (nxgraph[parent][task]["weight"] / mean_bandwidth + mean_latency)
        for parent in parents
      ])

    topological_order.reverse()

    # Average latest start time
    alst = {}
    alst[end] = aest[end]
    for task in topological_order:
      if not nxgraph[task]:
        alst[task] = aest[task]
        continue
      alst[task] = min([
        alst[child] - (edge["weight"] / mean_bandwidth + mean_latency)
        for child, edge in nxgraph[task].items()
      ]) - aec[task]

    return aest, alst
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号