def oct_dict(cls, nxgraph, platform_model):
"""
Build optimistic cost table as an dict task->array.
Args:
nxgraph: networkx representation of task graph
platform_model: platform linear model
"""
result = dict()
for task in networkx.topological_sort(nxgraph, reverse=True):
oct_row = numpy.zeros(platform_model.host_count)
if not nxgraph[task]:
result[task] = oct_row
continue
for host, idx in platform_model.host_map.items():
child_results = []
for child, edge_dict in nxgraph[task].items():
row = result[child].copy()
row += child.amount / platform_model.speed
comm_cost = numpy.ones(platform_model.host_count) * edge_dict["weight"] / platform_model.mean_bandwidth
comm_cost += platform_model.mean_latency
comm_cost[idx] = 0
row += comm_cost
child_results.append(row.min())
oct_row[idx] = max(child_results)
result[task] = oct_row
return result
评论列表
文章目录