File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -343,18 +343,14 @@ def getPower(chanlist):
343
343
for j in xrange (len (chanlist [i ])):
344
344
k = len (chanlist [i ]) - chanlist [i ].count (- 1 )##此基站分配的信道数量
345
345
##为存在信道分配的位置随机分配一个随机功率值
346
- if chanlist [i ][j ]!= - 1 :
347
- wp = uniform (0.001 , ptotal * 1.0 / k )
348
-
349
- # while(sum(p[i]) + wp > ptotal):
350
- # # wp = uniform(0.001,ptotal/k)##每个信道功率最多分配ptotal/k,这样有点不合理
351
- # print sum(p[i])+wp
352
- # wp = uniform(0.001,ptotal)
353
- p [i ][j ] = wp
346
+ if chanlist [i ][j ]!= - 1 : ##如果当前信道已分配
347
+ s = sum (p [i ])##求当前的基站的的功率和
348
+ #print "ptotal = %s"%ptotal
349
+ wp = uniform (0.001 , (ptotal - s )* 0.8 ) ##在0.001和剩余功率之间随机产生一个功率值
350
+ p [i ][j ] = wp * (1.0 / channelnum )##不至于随机数极差太大
351
+
354
352
return p
355
353
356
-
357
-
358
354
#------------------------------主 函 数 ---------------------------------------
359
355
if __name__ == "__main__" :
360
356
You can’t perform that action at this time.
0 commit comments