Ejemplo n.º 1
0
    def receive(self, src, msg):
        time.sleep(1)
        m = DecodedMsg(msg.dataGet())
        timeformat = '%Y/%d/%m %H:%M:%S'
        print 'Received message %s:' % time.strftime(timeformat)
        print ' true current row: ', self.current_row

        ## get received data from mote
        rec_row = m.get_crow()
        print rec_row

        x_mote = np.array(m.get_V_coeff())
        #x_mote = x_mote[0:self.current_row+1]

        print 'mote result: ', x_mote

        #print 'selfsym ' , self.sym

        ## check functionality in python
        V = self.A[:self.current_row + 1]
        #U, S, W = np.linalg.svd(V.T)
        #print S
        Vnull = V[:, [1, 3, 5, 7]]
        z = nullvec(Vnull.T)
        #ant_vec = np.mat('[0; 0; 0; 0; .1; 0; .2; 0]')
        ant_vec = np.multiply(np.mat('[0; 0; 1; 0; 1; 0; 1; 0]'), self.data)

        Vant = V * ant_vec

        #if len(z)>0:
        #print 'antidoteresult: ',z.T*Vant
        #else:
        #print 'antidoteresult: ',[]

        if len(z) > 0:
            #x_python = np.dot(z.T, V[:,0])
            #print x_python
            #print np.shape(z), np.shape(Vnull)
            #print np.matrix(Vnull).T*np.matrix(z)
            #print self.sym[0]
            #nulldata = z.T*self.sym[0]*np.ones((self.current_row+1,1))
            #print self.sym
            #print z.T
            #print self.sym[:self.current_row+1]
            nulldata = z.T * self.sym[:self.current_row + 1]
            antdata = z.T * Vant
            finalresult = nulldata - antdata
            maindimension = V[:, [0]]
            xdot = z.T * maindimension
            finalresult = (finalresult / xdot)
            print 'final Python result: ', finalresult

        else:
            print[]
        #U,S,V = np.linalg.svd(Vnull.T)
        #print S

        self.current_row = (self.current_row + 1) % self.N
        #if self.current_row == 0:
        #self.A = make_A_matrix(self.N)
        self.send()
Ejemplo n.º 2
0
	def receive(self, src, msg):
		time.sleep(1)
		m = DecodedMsg(msg.dataGet())
		timeformat = '%Y/%d/%m %H:%M:%S'
		print 'Received message %s:' % time.strftime(timeformat)
		print ' true current row: ', self.current_row


		## get received data from mote
		rec_row = m.get_crow()
		print rec_row

		x_mote = np.array(m.get_V_coeff())
		#x_mote = x_mote[0:self.current_row+1]


		print 'mote result: ', x_mote

		#print 'selfsym ' , self.sym

		

		## check functionality in python

		V = self.A[:self.current_row+1,:]
		#change to same random thing?
		#V = np.asarray(self.rndV[1:,:])
		#also update symbols each time based on new random coeffs
		#self.sym = V*self.data

		#print self.A[:self.current_row+1,:]
		#print 'V is'
		#print V

		#print 'symbols to python'
		#print self.sym[:self.current_row+1]
		#print 'symbols over the air'
		#print self.rndSym
		#print self.sym2
		
		#U, S, W = np.linalg.svd(V.T)
		#print S
		Vnull = V[ :, [1,3,5,7] ]
		z = nullvec(Vnull.T)
		#ant_vec = np.mat('[0; 0; 0; 0; .1; 0; .2; 0]')
		ant_vec = np.multiply(np.mat('[0; 0; 1; 0; 1; 0; 1; 0]'), self.data)

		Vant = V*ant_vec
		
		#if len(z)>0:
			#print 'antidoteresult: ',z.T*Vant
		#else:			
			#print 'antidoteresult: ',[]

		if len(z)>0:
			#x_python = np.dot(z.T, V[:,0])
			#print x_python
			#print np.shape(z), np.shape(Vnull)
			#print np.matrix(Vnull).T*np.matrix(z)
			#print self.sym[0]
			#nulldata = z.T*self.sym[0]*np.ones((self.current_row+1,1))
			#print self.sym
			#print z.T
			#print self.sym[:self.current_row+1]
			nulldata = z.T*self.sym[:self.current_row+1]
			antdata = z.T*Vant
			finalresult = nulldata - antdata
			maindimension = V[:,[0]]
			xdot = z.T*maindimension
			finalresult = (finalresult/xdot)
			print 'final Python result: ',finalresult

			
		else:
			print []
		#U,S,V = np.linalg.svd(Vnull.T)
		#print S

		self.current_row = (self.current_row + 1) % self.N
		if self.current_row == 0:
			self.A = make_A_matrix(self.N)
			self.sym = self.A*self.data
		self.send()
Ejemplo n.º 3
0
	def receive(self, src, msg):
		time.sleep(1)
		m = DecodedMsg(msg.dataGet())
		timeformat = '%Y/%d/%m %H:%M:%S'
		print 'Received message %s:' % time.strftime(timeformat)
		print ' true current row: ', self.current_row


		## get received data from mote
		rec_row = m.get_crow()
		print rec_row

		x_mote = np.array(m.get_V_coeff())
		#x_mote = x_mote[0:self.current_row+1]


		print 'mote result: ', x_mote

		

		## check functionality in python
		V = self.A[:self.current_row+1]
		#print 'A', self.A
		#print 'V', V
		#U, S, W = np.linalg.svd(V.T)
		#print S
		Vnull = V[ :, [1,3,5,7] ]
		z = nullvec(Vnull.T)
		#print z
		ant_vec = np.mat('[0; 0; :1; 0; 1; 0; 1; 0]')

		Vant = V*ant_vec
		
		if len(z)>0:
			print 'antidoteresult: ',z.T*Vant
		else:
			print 'antidoteresult: ',[]

		if len(z)>0:
			#x_python = np.dot(z.T, V[:,0])
			#print x_python
			#print np.shape(z), np.shape(Vnull)
			#print np.matrix(Vnull).T*np.matrix(z)
			nulldata= z.T*np.ones((self.current_row+1,1))
			antdata = z.T*Vant
			finalresult = nulldata - antdata
			maindimension = V[:,[0]]
			xdot = z.T*maindimension
			finalresult = (finalresult/xdot)
			print 'final result: ',finalresult

			
		else:
			print []
		#U,S,V = np.linalg.svd(Vnull.T)
		#print S

		
		#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.current_row = (self.current_row + 1) % self.N
		#if self.current_row == 0:
			#self.A = make_A_matrix(self.N)
		self.send()
Ejemplo n.º 4
0
    def receive(self, src, msg):
        time.sleep(1)
        m = DecodedMsg(msg.dataGet())
        timeformat = '%Y/%d/%m %H:%M:%S'
        print 'Received message %s:' % time.strftime(timeformat)
        print ' true current row: ', self.current_row

        ## get received data from mote
        rec_row = m.get_crow()
        print rec_row

        x_mote = np.array(m.get_V_coeff())
        #x_mote = x_mote[0:self.current_row+1]

        print 'mote result: ', x_mote

        ## check functionality in python
        V = self.A[:self.current_row + 1]
        #print 'A', self.A
        #print 'V', V
        #U, S, W = np.linalg.svd(V.T)
        #print S
        Vnull = V[:, [1, 3, 5, 7]]
        z = nullvec(Vnull.T)
        #print z
        ant_vec = np.mat('[0; 0; :1; 0; 1; 0; 1; 0]')

        Vant = V * ant_vec

        if len(z) > 0:
            print 'antidoteresult: ', z.T * Vant
        else:
            print 'antidoteresult: ', []

        if len(z) > 0:
            #x_python = np.dot(z.T, V[:,0])
            #print x_python
            #print np.shape(z), np.shape(Vnull)
            #print np.matrix(Vnull).T*np.matrix(z)
            nulldata = z.T * np.ones((self.current_row + 1, 1))
            antdata = z.T * Vant
            finalresult = nulldata - antdata
            maindimension = V[:, [0]]
            xdot = z.T * maindimension
            finalresult = (finalresult / xdot)
            print 'final result: ', finalresult

        else:
            print[]
        #U,S,V = np.linalg.svd(Vnull.T)
        #print S

        #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.current_row = (self.current_row + 1) % self.N
        #if self.current_row == 0:
        #self.A = make_A_matrix(self.N)
        self.send()