Advertisement
simov

Lab2_SnZ

Nov 3rd, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | None | 0 0
  1. import math
  2.  
  3. def A1(s):
  4.     if s >= 60:
  5.         return 1.0
  6.     else:
  7.         return (1/(math.exp(60-(abs(s)))))
  8.  
  9. def A2(s):
  10.     if s <= 10:
  11.         return 1.0
  12.     else:
  13.         return 1 / (1 + (math.exp((abs(10 - s)))))
  14.  
  15. def B1(s):
  16.     if 0 <= s < 0.8:
  17.         return 1/(1 + ((0.2 + s)**3))
  18.  
  19.     elif s >= 0.8:
  20.         return 1.0
  21.  
  22. def B2(s):
  23.     if s > 0.1:
  24.         return 1/(1 + ((0.9 + s)**2))
  25.     elif 0 <= s <= 0.1:
  26.         return 1.0
  27.  
  28. def Rule1_min(s,e):
  29.     return min(A2(s),B2(e))
  30.  
  31. def Rule2_min(s,e):
  32.     return min(A1(s),B2(e))
  33.  
  34. def Rule3_min(s,e):
  35.     return min(A1(s),B1(e))
  36.  
  37. def COG(w1,w2,w3,c1,c2,c3):
  38.     return (w1*c1 + w2*c2 + w3*c3)/(w1+w2+w3)
  39.  
  40. def Presmetaj(h, c1, c2, c3):
  41.     resenie={}
  42.     temp = 15
  43.  
  44.     resenie[(6, h)] = (temp, COG(Rule1_min(temp, h), Rule2_min(temp, h), Rule3_min(temp, h), c1, c2, c3))
  45.  
  46.     for i in range(7, 19):
  47.         temp += 1.5
  48.  
  49.         resenie[(i, h)] = (temp, COG(Rule1_min(temp, h), Rule2_min(temp, h), Rule3_min(temp, h), c1, c2, c3))
  50.  
  51.     for i in range(19, 25):
  52.         temp -= 1.5
  53.  
  54.         resenie[(i, h)] = (temp, COG(Rule1_min(temp, h), Rule2_min(temp, h), Rule3_min(temp, h), c1, c2, c3))
  55.  
  56.     for i in range(1, 6):
  57.         temp -= 1.5
  58.  
  59.         resenie[(i, h)] = (temp, COG(Rule1_min(temp, h), Rule2_min(temp, h), Rule3_min(temp, h), c1, c2, c3))
  60.  
  61.     return resenie
  62.  
  63.  
  64. if __name__ == "__main__":
  65.     h=input()
  66.     c1 = 2000
  67.     c2 = 500
  68.     c3 = 100
  69.     rez =  Presmetaj(h, c1, c2, c3)
  70.     for p in rez:
  71.         rez[p] = (rez[p][0], round(rez[p][1], 4))
  72.     print rez
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement