Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import threading
- class mf(object, threading.Thread):
- def __init__(self, p):
- self._p = p[:]
- threading.Thread.__init__(self)
- class trapecio(mf):
- def evaluate(self,x):
- if x<=self._p[0]:
- return 0
- elif self._p[0] < x <= self._p[1]:
- return (x - self._p[0])/(self._p[1] - self._p[0])
- elif self._p[1] < x <= self._p[2]:
- return 1
- elif self._p[2] < x <= self._p[3]:
- return 1 - (x - self._p[2])/(self._p[3] - self._p[2])
- else:
- return 0
- morning = trapecio([5, 7, 9, 11])
- noon = trapecio([11, 14, 16, 17])
- night = trapecio([17, 19, 21,23])
- tiempos = [0.00, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90,
- 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90,
- 2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.80, 2.90,
- 3.00, 3.10, 3.20, 3.30, 3.40, 3.50, 3.60, 3.70, 3.80, 3.90,
- 4.00, 4.10, 4.20, 4.30, 4.40, 4.50, 4.60, 4.70, 4.80, 4.90,
- 5.00, 5.10, 5.20, 5.30, 5.40, 5.50, 5.60, 5.70, 5.80, 5.90,
- 6.00, 6.10, 6.20, 6.30, 6.40, 6.50, 6.60, 6.70, 6.80, 6.90,
- 7.00, 7.10, 7.20, 7.30, 7.40, 7.50, 7.60, 7.70, 7.80, 7.90,
- 8.00, 8.10, 8.20, 8.30, 8.40, 8.50, 8.60, 8.70, 8.80, 8.90,
- 9.00, 9.10, 9.20, 9.30, 9.40, 9.50, 9.60, 9.70, 9.80, 9.90,
- 10.00, 10.10, 10.20, 10.30, 10.40, 10.50, 10.60, 10.70, 10.80, 10.90,
- 11.00, 11.10, 11.20, 11.30, 11.40, 11.50, 11.60, 11.70, 11.80, 11.90,
- 12.00, 12.10, 12.20, 12.30, 12.40, 12.50, 12.60, 12.70, 12.80, 12.90,
- 13.00, 13.10, 13.20, 13.30, 13.40, 13.50, 13.60, 13.70, 13.80, 13.90,
- 14.00, 14.10, 14.20, 14.30, 14.40, 14.50, 14.60, 14.70, 14.80, 14.90,
- 15.00, 15.10, 15.20, 15.30, 15.40, 15.50, 15.60, 15.70, 15.80, 15.90,
- 16.00, 16.10, 16.20, 16.30, 16.40, 16.50, 16.60, 16.70, 16.80, 16.90,
- 17.00, 17.10, 17.20, 17.30, 17.40, 17.50, 17.60, 17.70, 17.80, 17.90,
- 18.00, 18.10, 18.20, 18.30, 18.40, 18.50, 18.60, 18.70, 18.80, 18.90,
- 19.00, 19.10, 19.20, 19.30, 19.40, 19.50, 19.60, 19.70, 19.80, 19.90,
- 20.00, 20.10, 20.20, 20.30, 20.40, 20.50, 20.60, 20.70, 20.80, 20.90,
- 21.00, 21.10, 21.20, 21.30, 21.40, 21.50, 21.60, 21.70, 21.80, 21.90,
- 22.00, 22.10, 22.20, 22.30, 22.40, 22.50, 22.60, 22.70, 22.80, 22.90,
- 23.00, 23.10, 23.20, 23.30, 23.40, 23.50, 23.60, 23.70, 23.80, 23.90]
- for item in tiempos:
- time.sleep(6.0)
- hora = item
- morning_ratio = morning.evaluate(float(hora))
- noon_ratio = noon.evaluate(float(hora))
- night_ratio = night.evaluate(float(hora))
- if morning_ratio > noon_ratio:
- eval_ratio = morning_ratio
- elif noon_ratio > night_ratio:
- eval_ratio = noon_ratio
- else:
- eval_ratio = night_ratio
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement