示例#1
0
	def receive(self, src, msg):
		m = DecodedMsg(msg.dataGet())
		self.counter = m.get_counter()
		timeformat = '%Y/%d/%m %H:%M:%S'
		print 'Received message %s: counter: %d' % (time.strftime(timeformat), self.counter)
		if m.get_perform_svd():
			print '  svd received:'
			Svals = m.get_A()
			print Svals
			U,S,V = np.linalg.svd(self.A)
			print '  svd check:'
			print [s**2 for s in S]
			self.perform_svd = 0
示例#2
0
    def receive(self, src, msg):
        time.sleep(1)
        m = DecodedMsg(msg.dataGet())
        self.counter = m.get_counter()
        timeformat = '%Y/%d/%m %H:%M:%S'
        print 'Received message %s: counter: %d' % (time.strftime(timeformat),
                                                    self.counter)
        print ' current row: ', m.get_current_row()
        print ' true current row: ', self.current_row
        z = np.array(m.get_V_row())
        z = z[0:self.current_row + 1]
        print z
        V = self.A[:m.get_current_row() + 1]
        #U, S, W = np.linalg.svd(V.T)
        #print S
        Vnull = V[:, [1, 3, 5, 7]]
        #U,S,V = np.linalg.svd(Vnull.T)
        #print S
        print np.matrix(Vnull).T * np.matrix(z).T

        #U, s, W = np.linalg.svd(Vnull.T)
        #print W.T

        #print self.A[m.get_current_row()][:]
        #print m.get_current_row()
        #print S
        #V_null = self.A[0:self.current_row+1,[1,3, 9, 14]]
        #U, S, W = np.linalg.svd(V_null)
        #print S
        #if m.get_perform_svd() == self.N:
        ##print '  svd received:'
        #Svals = m.get_W()
        #print 'Rx svd: ', Svals
        #U,S,V = np.linalg.svd(self.A)
        ##S = [s**2 for s in S]
        ##print '  svd check:'
        #print 'PC svd: ', S
        #self.perform_svd = 0
        #self.A = make_A_matrix(self.N)
        #print 'MSE: ', np.linalg.norm(np.array(S)-np.array(Svals),2)
        #proctime = time.time() - self.prevtime
        #print 'Elapsed time: %f seconds' % proctime
        #else:
        #self.prevtime = time.time()
        #self.perform_svd += 1
        self.counter += 1
        self.current_row = (self.current_row + 1) % self.N
        #if self.current_row == 0:
        #self.A = make_A_matrix(self.N)
        self.send()
示例#3
0
	def receive(self, src, msg):
		time.sleep(1)
		m = DecodedMsg(msg.dataGet())
		self.counter = m.get_counter()
		timeformat = '%Y/%d/%m %H:%M:%S'
		print 'Received message %s: counter: %d' % (time.strftime(timeformat), self.counter)
		print ' current row: ', m.get_current_row()
		print ' true current row: ', self.current_row
		z = np.array(m.get_V_row())
		z = z[0:self.current_row+1]
		print z
		V = self.A[:m.get_current_row()+1]
		#U, S, W = np.linalg.svd(V.T)
		#print S
		Vnull = V[ :, [1,3,5,7] ]
		#U,S,V = np.linalg.svd(Vnull.T)
		#print S
		print np.matrix(Vnull).T*np.matrix(z).T
		
		#U, s, W = np.linalg.svd(Vnull.T)
		#print W.T

		#print self.A[m.get_current_row()][:]
		#print m.get_current_row()
		#print S
		#V_null = self.A[0:self.current_row+1,[1,3, 9, 14]]
		#U, S, W = np.linalg.svd(V_null)
		#print S
		#if m.get_perform_svd() == self.N:
			##print '  svd received:'
			#Svals = m.get_W()
			#print 'Rx svd: ', Svals
			#U,S,V = np.linalg.svd(self.A)
			##S = [s**2 for s in S]
			##print '  svd check:'
			#print 'PC svd: ', S
			#self.perform_svd = 0
			#self.A = make_A_matrix(self.N)
			#print 'MSE: ', np.linalg.norm(np.array(S)-np.array(Svals),2)
			#proctime = time.time() - self.prevtime
			#print 'Elapsed time: %f seconds' % proctime
		#else:
			#self.prevtime = time.time()
			#self.perform_svd += 1
		self.counter += 1
		self.current_row = (self.current_row + 1) % self.N
		#if self.current_row == 0:
			#self.A = make_A_matrix(self.N)
		self.send()
示例#4
0
 def receive(self, src, msg):
     m = DecodedMsg(msg.dataGet())
     self.counter = m.get_counter()
     timeformat = '%Y/%d/%m %H:%M:%S'
     print 'Received message %s: counter: %d' % (time.strftime(timeformat),
                                                 self.counter)
     if m.get_perform_svd():
         print '  svd received:'
         Svals = m.get_A()
         print Svals
         U, S, V = np.linalg.svd(self.A)
         print '  svd check:'
         print[s**2 for s in S]
         self.perform_svd = 0
         self.A = make_A_matrix(self.N)
     self.counter += 1
     self.perform_svd = self.counter % (self.N + 1)
     self.send()
示例#5
0
	def receive(self, src, msg):
		m = DecodedMsg(msg.dataGet())
		self.counter = m.get_counter()
		timeformat = '%Y/%d/%m %H:%M:%S'
		print 'Received message %s: counter: %d' % (time.strftime(timeformat), self.counter)
		if m.get_perform_svd() == self.N:
			#print '  svd received:'
			Svals = m.get_A()
			print 'Rx svd: ', Svals
			U,S,V = np.linalg.svd(self.A)
			#S = [s**2 for s in S]
			#print '  svd check:'
			print 'PC svd: ', S
			self.perform_svd = 0
			self.A = make_A_matrix(self.N)
			print 'MSE: ', np.linalg.norm(np.array(S)-np.array(Svals),2)
			proctime = time.time() - self.prevtime
			print 'Elapsed time: %f seconds' % proctime
		else:
			self.prevtime = time.time()
			self.perform_svd += 1
		self.counter += 1
		self.send()
示例#6
0
 def receive(self, src, msg):
     m = DecodedMsg(msg.dataGet())
     self.counter = m.get_counter()
     timeformat = '%Y/%d/%m %H:%M:%S'
     print 'Received message %s: counter: %d' % (time.strftime(timeformat),
                                                 self.counter)
     if m.get_perform_svd() == self.N:
         #print '  svd received:'
         Svals = m.get_A()
         print 'Rx svd: ', Svals
         U, S, V = np.linalg.svd(self.A)
         #S = [s**2 for s in S]
         #print '  svd check:'
         print 'PC svd: ', S
         self.perform_svd = 0
         self.A = make_A_matrix(self.N)
         print 'MSE: ', np.linalg.norm(np.array(S) - np.array(Svals), 2)
         proctime = time.time() - self.prevtime
         print 'Elapsed time: %f seconds' % proctime
     else:
         self.prevtime = time.time()
         self.perform_svd += 1
     self.counter += 1
     self.send()