Hello,
I am trying to write a function in the class. The scenario is that:
physqueue[:][0]<lastt<dataqueue[:][0] but the timing is coming always wrong. I tried almost every combinations but I had always a problem with timing. The code is long so instead of pasting the whole code, I just paste the function part
Any helps?
I am trying to write a function in the class. The scenario is that:
Quote:Let's assume:
delaytime == 10
A recieves qubits at 0, 4, 8 with idt0, idt1 and idt2
B recieves qubits at 1, 5, ,9 with idt0, idt1 and idt2....
physqueue == []
A.dataqueue == B.otherport.dataqueue
B.dataqueue == A.otherport.dataqueue
For both A and B
lastt==-0.1
physqueuesize=what we give in the function
physqueue == []
dataqueue == []
The next event for A will be
# Next A.qubits at 0 with idt0, 4 with idt1, 8 with idt 2,
# Next A.dataqueue at 11, 15, 19
# Next event is A.tq=0 with idt0
The next B event will be :
# Next B.qubits at 1, 5, ,9
# Next B.dataqueue at 10, 14, 18
# Next even is B.tq= 1 with idt0
Let us assume A.lastt == 5.0
A.physqueue = [(0,idt0), (4, idt1)]
B.dataqueue = [(10.,idt0), (14, idt1)]
the content of A.dataqueue and B.physqueue depend of B.lastt, but we should have
B.lastt < .dataqueue[0][0] == 10.
A.dataqueue[0][0] > A.lastt == 5.
If B.lastt <1 :
A.dataqueue == [] #
elif 1<= B.lastt < 5 :
A.dataqueue == [(11, idt0)]
elif 5<= B.lastt < 9 :
A.dataqueue == [(11, idt0), (15, idt1)]
else :
9<= B.lastt <= 11 :
A.dataqueue == [(11, idt0), (15, idt1), (19, idt2) ]
Quote:Here is my pseudocode:And I tried to code it in this way but I have always timing problem.
if self.tq <= self.lastt #self.arrivingqubit is empty:
seft.tq, self.arrivingqubit = next(inqubits)
(ii) #Process dataqueue and empty physqueue if needed
if tm <= self.tq :
self.lastt = tm
updateqmem
process dataqueue:
you get the idt of the qubit received by otherport
you delete from physqueue the qubits older than this
you output the qubit with idt if is in the physqueue
# after this step physqueue[0][1].idt > cdata
(iii) # Fill physqueue and otherport.dataqueue
if self.tq < tm :
self.lastt = self.tq
updateqmem
put self.arrivingqubit in physqueue
otherport.dataqueue ....
def __next__(self): while True: if self.tq <= self.lastt: self.tq, self.arrivingqubit = next(self.inqubits) if len(self.dataqueue)==0: self.otherport.nextqubitin() while len(self.dataqueue)==0 or self.tq < self.dataqueue[0][0]: self.nextqubitin() while len(self.dataqueue)>0 and self.dataqueue[0][0] <= self.tq : td = self.dataqueue[0][0] cdata = self.dataqueue[0][1] self.updateqmem(td) self.lastt = td self.dataqueue.pop(0) while len(self.physqueue)>0 and self.physqueue[0][1].idt<cdata: #self.physqueue[0][0]>=td: td,q= self.physqueue.pop(0) if len(self.physqueue)>0 and self.physqueue[0][1].idt==cdata: tq,qb = self.physqueue.pop(0) return [td,qb] def nextqubitin(self): #forward time untill you receive next qubit self.tq = time of next qubit and self.arrivingqubit is the id of next qubit if self.tq <= self.lastt: self.tq, self.arrivingqubit = next(self.inqubits) tq, qubit = next(self.inqubits) if self.physqueuesize==0 or len(self.physqueue)<=self.physqueuesize: self.physqueue.append([self.tq, self.arrivingqubit]) #actually keep tq self.otherport.dataqueue.append([self.tq+self.delaytime, self.arrivingqubit.idt]) self.lastt=self.tqThe timing should be:
physqueue[:][0]<lastt<dataqueue[:][0] but the timing is coming always wrong. I tried almost every combinations but I had always a problem with timing. The code is long so instead of pasting the whole code, I just paste the function part
Any helps?