DamSi

Untitled

Oct 23rd, 2015
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.72 KB | None | 0 0
  1. __author__ = 'Damjan'
  2. import math
  3.  
  4.  
  5. def A1(s):
  6.     if s>=60:
  7.         return 1.0
  8.     elif s<60:
  9.         return 1.0/pow(math.e,(60-abs(s)))
  10.     else:
  11.         return -1.0
  12.  
  13. def A2(s):
  14.     if s<=10:
  15.         return 1.0
  16.     elif s>10:
  17.         return 1.0/(1+pow(math.e,abs(10-s)))
  18.     else:
  19.         return -1.0
  20.  
  21. def B1(s):
  22.     if s>=0.8:
  23.         return 1.0
  24.     elif s<0.8:
  25.         return 1.0/(1+pow(0.2+s,3))
  26.     else:
  27.         return -1/0
  28.  
  29. def B2(s):
  30.     if s<=0.1:
  31.         return 1.0
  32.     elif s>0.1:
  33.         return 1/(1+pow(0.9+s,2))
  34.     else:
  35.         return -1.0
  36.  
  37. def Rule1_min(s,e):
  38.     return min(A2(s),B2(e))
  39.  
  40. def Rule2_min(s,e):
  41.     return min(A1(s),B2(e))
  42.  
  43. def Rule3_min(s,e):
  44.     return min(A1(s),B1(e))
  45.  
  46. def COG(w,c):
  47.     broitel = 0
  48.     imenitel = 0
  49.     if len(w)!= len(c):
  50.         return -1
  51.     else:
  52.         for i in range(len(w)):
  53.             broitel+=w[i]*c[i]
  54.             imenitel+=w[i]
  55.     return broitel/imenitel
  56. def C1():
  57.     return 2000.0
  58. def C2():
  59.     return 500.0
  60. def C3():
  61.     return 100.0
  62.  
  63. def Presmetaj(h):
  64.     resenie={}
  65.     temperatura =0
  66.     for cas in range(1,25):
  67.         kluc = (cas,h)
  68.         if cas >= 6 and cas <=18:
  69.             if cas == 6:
  70.                 temperatura = 15
  71.             else:
  72.                 temperatura+=1.5
  73.         else:
  74.              temperatura-=1.5
  75.  
  76.         w1 = Rule1_min(temperatura,h)
  77.         w2 = Rule2_min(temperatura,h)
  78.         w3 = Rule3_min(temperatura,h)
  79.         c1 = C1()
  80.         c2 = C2()
  81.         c3 = C3()
  82.         w = [w1,w2,w3]
  83.         c = [c1,c2,c3]
  84.  
  85.         resenie[kluc]=(temperatura,round(COG(w,c),4))
  86.  
  87.     return resenie
  88.  
  89.  
  90.  
  91. if __name__ == "__main__":
  92.     h=input()
  93.     resenie=Presmetaj(h)
  94.     print resenie
Advertisement
Add Comment
Please, Sign In to add comment