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
评论列表
文章目录