Esempio n. 1
0
 def test_writeread3(self, qty=10):
     #sdm.initialize()
     for i in range(qty):
         a = Bitstring()
         sdm.thread_write(a, a)
         b = sdm.thread_read(a)
         self.assertEqual(a.distance_to(b), 0)
Esempio n. 2
0
 def test_writeread(self, qty=10):
     sdm.initialize()
     for i in range(qty):
         a = Bitstring()
         sdm.thread_write(a, a)
         b = sdm.thread_read(a)
         self.assertEqual(a.distance_to(b), 0)
     sdm.free()
Esempio n. 3
0
 def test_writereadnear(self, distance=50, qty=10):
     sdm.initialize()
     for i in range(qty):
         a = Bitstring()
         sdm.thread_write(a, a)
         b = a.copy()
         b.bitrandomswap(distance)
         c = sdm.thread_read(b)
         self.assertEqual(a.distance_to(c), 0)
     sdm.free()
Esempio n. 4
0
 def test_writereadnear(self, distance=50, qty=10):
     sdm.initialize()
     for i in range(qty):
         a = Bitstring()
         sdm.thread_write(a, a)
         b = a.copy()
         b.bitrandomswap(distance)
         c = sdm.thread_read(b)
         self.assertEqual(a.distance_to(c), 0)
     sdm.free()
Esempio n. 5
0
 def test_saveload(self):
     a = Bitstring()
     #sdm.initialize()
     sdm.thread_write(a, a)
     self.assertEqual(a.distance_to(sdm.thread_read(a)), 0)
     self.assertEqual(sdm.save_to_file('_test.sdm'), 0)
     sdm.free()
     sdm.initialize()
     self.assertTrue(a.distance_to(sdm.read(a)) > 0)
     sdm.free()
     self.assertEqual(sdm.initialize_from_file('_test.sdm'), 0)
     self.assertEqual(a.distance_to(sdm.thread_read(a)), 0)
Esempio n. 6
0
def h():
    import sdm
    import sdm_utils
    #import numpy as NP
    a = b = arange (0,1000)
    sdm.initialize_from_file("/Users/AL/Desktop/mem10000_n1000_10000x_at_x.sdm")
    v = sdm.Bitstring()
    sdm.thread_write(v,v)
    print ("computing distances")
    #for i in range (0,999,250):
        #a = sdm_utils.critical_distance2(0, 10, 1, v)
        #b = sdm_utils.critical_distance2(0, 10, 1, v)
    heatmap (a,b)
Esempio n. 7
0
def scan_for_distances():
    import time, cPickle;
    sdm.initialize()
    v = sdm.Bitstring()
    for i in range (0,10,1):	
        sdm.thread_write(v,v)
    import pylab
    for i in range (1000,51000,1000):
        print 'Computing distances for '+str(i)+' items registered'
        #add 1000 itens to memory
        mem_write_x_at_x(1000)
        a = sdm_utils.critical_distance2(0, 1000, 1, v, read=sdm.thread_read_chada)
        #get new distance values in a
        #save a
        cPickle.dump(a, open (str(i)+'10writes_Chada_Read.cPickle', 'wb'))
        print 'saved '+str(i)+'.cPickle'
Esempio n. 8
0
def linhares_critical1():
    #cd /Users/AL/Dropbox/0. AL Current Work/3. To Submit/Dr K/AL/python/
    import sdm
    import sdm_utils
    import time
    start=time.clock()
    #sdm.initialize()
    sdm.initialize_from_file("/Users/AL/Desktop/mem45000_n1000_10000x_at_x.sdm")
    mem_write_x_at_x(5000)
    v = sdm.Bitstring()
    sdm.thread_write(v,v)
    print ("computing distances graph")
    print (time.clock()-start, "seconds") 
    a = sdm_utils.critical_distance2(0, 1000, 1, v)
    print (time.clock()-start) 
    print "saving file"
    sdm.save_to_file("/Users/AL/Desktop/mem50000_n1000_10000x_at_x.sdm")
    import pylab
    pylab.plot(a)
    pylab.show()
Esempio n. 9
0
def scan_for_distances(numwrites=1):
    import time, cPickle;

    #Configure execution
    numwrites_string = '_x_at_x_'+str(numwrites)+'_writes'

    sdm.initialize()
    v = sdm.Bitstring()
    for i in range(numwrites):
        sdm.thread_write(v,v)
    for i in range (1000,2000,1000):
        print 'Registering '+str(i)+' new items in SDM'
        #add 1000 itens to memory
        mem_write_x_at_x(1000)
        print 'Computing the distances to these items'
        a = sdm_utils.critical_distance2(0, sdm.get_dimension(), 1, v, iterated_reading=6, read=sdm.thread_read_cubed,debug=0)
        #save new distance values in a
        picklename = 'N=256_iter_read=2_'+str(i)+'saved items'+numwrites_string+'_DrK_cubed.cPickle'
        cPickle.dump(a, open (picklename, 'wb'))
        print 'saved '+picklename
    sdm.free()
Esempio n. 10
0
def mem_write_x_at_random(count=10):
    for i in range (count):
        b=sdm.Bitstring()
        c=sdm.Bitstring()
        sdm.thread_write(b,c)
Esempio n. 11
0
#!/usr/bin/env python

import sdm
import time

print 'Initializing..',
sdm.initialize()
print 'done!'

#print 'Running count..'
#start = time.time()
#for i in range(300):
#    a = sdm.Bitstring()
#    print i, sdm.thread_radius_count(a)
#print 'Time:', time.time()-start

print 'Running write..'
start = time.time()
for i in range(300):
    a = sdm.Bitstring()
    print i, sdm.thread_write(a, a)
print 'Time:', time.time()-start

Esempio n. 12
0
#!/usr/bin/env python

import sdm
import time

print 'Initializing..',
sdm.initialize()
print 'done!'

#print 'Running count..'
#start = time.time()
#for i in range(300):
#    a = sdm.Bitstring()
#    print i, sdm.thread_radius_count(a)
#print 'Time:', time.time()-start

print 'Running write..'
start = time.time()
for i in range(300):
    a = sdm.Bitstring()
    print i, sdm.thread_write(a, a)
print 'Time:', time.time() - start
Esempio n. 13
0
def mem_write_x_at_x(count=1):
    for i in range (count):
        b=sdm.Bitstring()
        sdm.thread_write(b,b)