I have three lists (the container*) and they need to pop one(the first) element at a time. Which list will pop the element depends on a value (tF*), the smallest value sends first, but if the values are equal then it goes in the alphabetical order by the names of list(container1 sends first), the list that go into the sending are the ones that have elements in it. Also, the tF* are calculatet per element, so if there are two elements "1" than first pops one, and in the next round(when the "2's" arrive) it pop the other one.
It's in fact a simulation on fair queuing that routers use when they have more flows incoming... I just can't figure out that popping(sending) part, any help is appreciated.
here is the code I got so far (python)
flow1 = [1,2,4,6]
flow2 = [2,6]
flow3 = [1,2,3,5,6]
container1 = []
container2 = []
container3 = []
t = 1
tA=1
tF1 = 0
tF2 = 0
tF3 = 0
counter_tA = 0
while flow1[0] or flow2[0] or flow3[0] or container1[0] or container2[0] or container3[0]:
#from flow to the container
if flow1[0] == t:
container1.append(flow1.pop(0))
tF1 = max(tF1, tA)+1
counter_tA += 1
if flow2[0] == t:
container2.append(flow2.pop(0))
tF2 = max(tF2, tA)+1
counter_tA += 1
if flow3[0] == t:
container3.append(flow3.pop(0))
tF3 = max(tF3, tA)+1
counter_tA += 1
#sending
send = min(tF1, min(tF2, tF3))
if tF1 == tF2 == tF3:
container1.pop()
if tF1 == (tF2 or tF3):
tA = tA + 1/counter_tA
counter_tA =0
t+=1