score.py 608 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. '''
  4. 得分计算
  5. @Auther :liuyuqi.gov@msn.cn
  6. @Time :2018/7/6 1:51
  7. @File :score.py
  8. '''
  9. import math
  10. # Sjt表示j主机在t时刻的得分score。
  11. flag = True
  12. alpha = 10
  13. beta = 0.5
  14. def getScore():
  15. '''
  16. 计算得分
  17. :return:
  18. '''
  19. sum=0
  20. for j in range(0, 6000):
  21. for t in range(0,92):
  22. # c表示j主机在t时刻的CPU利用率
  23. c = (1 + 2 + 3) / 50
  24. if flag == False:
  25. Sjt = 0
  26. else:
  27. Sjt = 1 + alpha * (math.exp(max(0, c - beta)))
  28. sum=sum+Sjt