Я пытаюсь создать модель, которая будет предсказывать значения таймера трафика, определенные в словаре.Та же проблема уже сделана и смоделирована в MATLAB, но я получаю ниже ошибку в python при доступе к элементам из словаря.
import random
q_len = {'less': random.randrange(0,8), 'medium': random.randrange(6,14),
'long':random.randrange(12,30)}
peak_hours = {'very_light':random.randrange(0, 7.5), 'heavy_
morn':random.randrange(7,11.5), 'medium':random.randrange(11,16.5),
'heavy_eve':random.randrange(16,20.5), 'light':random.randrange(20,24.5)}
time_ext = {'more_decrease':random.randrange(-32 -8),
'decrease':random.randrange(-16 -1), 'do_not_change':random.randrange(-8
-0.5), 'increase':random.randrange(0, 16),
'more_increase':random.randrange(8, 32)}
def traffic(queue_len, peak_hours):
#entry1 = float(input('Enter the value of length of queue: '))
#entry2 = float(input('Enter the value of peak_hr: '))
#if entry1 in q_len && entry2 in peak_hours:
for i in iter.items in q_len:
for j in iter.items in peak_hours:
if queue_len is less & peak_hours is very_light:
time_ext=more_decrease
elif queue_len is less & peak_hours is heavy_morn:
time_ext=decrease
elif queue_len is less & peak_hours is medium:
time_ext=decrease
elif queue_len is less & peak_hours is heavy_eve :
time_ext=decrease
elif queue_len is less & peak_hours is light:
time_ext=more_decrease
elif queue_len is medium & peak_hours is very_light:
time_ext=increase
elif queue_len is medium & peak_hours is heavy_morn:
time_ext=increase
elif queue_len is medium & peak_hours is medium:
time_ext=do_not_change
elif queue_len is medium & peak_hours is heavy_eve:
time_ext=increase
elif queue_len is medium & peak_hours is light:
time_ext=do_not_change
elif queue_len is long & peak_hours is very_light:
time_ext=do_not_change
elif queue_len is long & peak_hours is heavy_morn:
time_ext=more_increase
elif queue_len is long & peak_hours is medium:
time_ext=increase
elif queue_len is long & peak_hours is heavy_eve:
time_ext=more_increase
else:
time_ext=increase
print(time_ext)
Он должен печатать значение расширения времени после получения ввода из функциино это не то же самое.Пожалуйста, помогите, если кто-то знает, какую ошибку я совершаю.