Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. import math
  2.  
  3. def A1(s):
  4. if s<0:
  5. return -1
  6. elif s<60:
  7. return (1.0/(math.e**(60 - math.fabs(s))))
  8. else:
  9. return 1.0
  10.  
  11.  
  12. def A2(s):
  13. if s<0:
  14. return -1
  15. elif s<=10:
  16. return 1.0
  17. else:
  18. return (1.0/(1.0 + math.e**(math.fabs(10-s))))
  19.  
  20.  
  21. def B1(s):
  22. if s<0:
  23. return -1
  24. elif s >=0 and s<=0.8:
  25. return (1.0/(1.0+(0.2+s)**3))
  26. else:
  27. return 1.0
  28.  
  29.  
  30. def B2(s):
  31. if s<0:
  32. return -1
  33. elif s >=0 and s<= 0.1:
  34. return 1.0
  35. else:
  36. return (1.0/(1.0 + (0.9+s)**2))
  37.  
  38. def Rule1_min(s,e):
  39. return min(A2(s),B2(s))
  40.  
  41. def Rule2_min(s,e):
  42. return min(A1(s),B2(s))
  43.  
  44. def Rule3_min(s,e):
  45. return min(A1(s),B1(s))
  46.  
  47.  
  48. def COG(w,c):
  49. if len(w) != len(c):
  50. return -1
  51. else:
  52. broitel=0
  53. imenitel=0
  54. for i in range(len(w)):
  55. broitel+=w[i]*c[i]
  56. imenitel+=w[i]
  57.  
  58. return broitel/imenitel
  59.  
  60.  
  61.  
  62. if __name__ == "__main__":
  63. t=input()
  64. h=input()
  65. w1,w2,w3 = Rule1_min(t,h),Rule2_min(t,h),Rule3_min(t,h)
  66. w = [w1,w2,w3]
  67. c = [2000,500,100]
  68. cog=COG(w,c)
  69. print cog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement