Python Forum
Message is going at wrong time
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Message is going at wrong time
#1
Hello,

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:

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 ....
And I tried to code it in this way but I have always timing problem.
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.tq  
The 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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Downloading time zone aware files, getting wrong files(by date))s tester_V 9 961 Jul-23-2023, 08:32 AM
Last Post: deanhystad
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,387 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  python gives wrong string length and wrong character thienson30 2 2,943 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  Error message wrong??? Transylvania 2 2,475 Sep-13-2018, 09:45 AM
Last Post: Transylvania
  Wrong or missing date format and time in mails sipriusPT 3 4,215 Aug-08-2017, 03:22 PM
Last Post: sipriusPT

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020