Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def A1(s):
- if s<0:
- return -1
- elif s<60:
- return (1.0/(math.e**(60 - math.fabs(s))))
- else:
- return 1.0
- def A2(s):
- if s<0:
- return -1
- elif s<=10:
- return 1.0
- else:
- return (1.0/(1.0 + math.e**(math.fabs(10-s))))
- def B1(s):
- if s<0:
- return -1
- elif s >=0 and s<=0.8:
- return (1.0/(1.0+(0.2+s)**3))
- else:
- return 1.0
- def B2(s):
- if s<0:
- return -1
- elif s >=0 and s<= 0.1:
- return 1.0
- else:
- return (1.0/(1.0 + (0.9+s)**2))
- def Rule1_min(s,e):
- return min(A2(s),B2(s))
- def Rule2_min(s,e):
- return min(A1(s),B2(s))
- def Rule3_min(s,e):
- return min(A1(s),B1(s))
- def COG(w,c):
- if len(w) != len(c):
- return -1
- else:
- broitel=0
- imenitel=0
- for i in range(len(w)):
- broitel+=w[i]*c[i]
- imenitel+=w[i]
- return broitel/imenitel
- if __name__ == "__main__":
- t=input()
- h=input()
- w1,w2,w3 = Rule1_min(t,h),Rule2_min(t,h),Rule3_min(t,h)
- w = [w1,w2,w3]
- c = [2000,500,100]
- cog=COG(w,c)
- print cog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement