我在下面有以下伪代码,procedure optimal(): for each i in 1 · · · N do TMi ← fmobile(i) TCi ← fcloud(i) TUi ← Di/B return [psuedocode][1]我正在尝试在 python 中转换它。我写了下面的代码 def optimal(): B=20 for i in range(1, 10): latency_m=[] latency_c=[] transfer_latency=[] total_latency_m = 0 total_latency_c=0 latency_m[i]=estimate_m(i) latency_c[i]=estimate_c(i) transfer_latency[i]=estimate_output(i)/B for j in range (1, 10): for i in range(1,j): total_latency_e+=latency_e[i] for k in range(j+1,10): total_latency_c+=latency_c[k]感谢您的帮助。
1 回答
炎炎设计
TA贡献1808条经验 获得超4个赞
根据所附公式:
N = 50
TM = [] # External source
TC = [] # External source
TU = [] # External source
SUMS = [0] * N
for j in range(N):
for i in range(1, j+1):
SUMS[j] += TM[i]
for k in range(j-1, N+1):
SUMS[j] += TC[k]
SUMS[j] += TU[j]
return min(SUMS)
添加回答
举报
0/150
提交
取消