7 """Convertit un nombre en binaire"""
9 res =[0 for i in range(n)]
24 acc = acc + 2**(n-i-1)
29 def prngRairobin(fbin,b,x):
30 # f is the binary function
31 # b is the number to iterate
32 # x0 is the intial binary conf
34 #print "************************"
37 if rn.randint(0,1) == 1:
38 image = fbin[tuple(xp)]
39 st = rn.randint(0,n-1)
40 #print "x["+str(st)+"]="+str(xp[st])+"->"+str(image[st])
45 def prngPython(p2nm1,st):
47 x = rn.randint(0,p2nm1)
52 def prngUnaireBin(fbin,b,x):
53 # f is the binary function
54 # b is the number to iterate
55 # x0 is the intial binary conf
57 #print "************************"
60 #if rn.randint(0,1) == 1:
61 image = fbin[tuple(xp)]
62 st = rn.randint(0,n-1)
63 #print "x["+str(st)+"]="+str(xp[st])+"->"+str(image[st])
70 ## n'est pas un circuit hmiltonien
72 #f = [13, 10, 9, 14, 3, 11, 1, 12, 15, 4, 7, 5, 2, 6, 0, 8]
74 #f= [29, 22, 21, 30, 19, 27, 24, 28, 7, 20, 5, 4, 23, 26, 25, 17, 31, 12, 15, 8, 10, 14, 13, 9, 3, 2, 1, 6, 11, 18, 0, 16] #g*5 meilleure unaire
76 #f=[55, 60, 45, 44, 43, 62, 61, 48, 53, 50, 52, 36, 59, 51, 33, 49, 15, 14, 47, 46, 35, 58, 57, 56, 7, 54, 39, 37, 3, 38, 1, 40, 63, 26, 25, 30, 19, 27, 17, 28, 31, 20, 23, 21, 18, 22, 16, 24, 13, 12, 29, 8, 10, 42, 41, 0, 5, 2, 4, 6, 11, 34, 9, 32] #g*6 meilleure unaire
78 f=[111, 94, 93, 116, 122, 114, 125, 88, 115, 126, 85, 84, 123, 98, 81, 120, 109, 78, 105, 110, 99, 107, 104, 108, 101, 118, 117, 96, 103, 66, 113, 64, 79, 86, 95, 124, 83, 91, 121, 24, 119, 22, 69, 20, 87, 18, 17, 112, 77, 76, 73, 12, 74, 106, 72, 8, 7, 102, 71, 100, 75, 82, 97, 0, 127, 54, 57, 62, 51, 59, 56, 48, 53, 38, 37, 60, 55, 58, 33, 49, 63, 44, 47, 40, 42, 46, 45, 41, 35, 34, 39, 52, 43, 50, 32, 36, 29, 28, 61, 92, 26, 90, 89, 25, 19, 30, 23, 4, 27, 2, 16, 80, 31, 10, 15, 14, 3, 11, 13, 9, 5, 70, 21, 68, 67, 6, 65, 1] # f*7 ou g*7
81 f = [223, 190, 249, 254, 187, 251, 233, 232, 183, 230, 247, 180, 227, 178, 240, 248, 237, 236, 253, 172, 203, 170, 201, 168, 229, 166, 165, 244, 163, 242, 241, 192, 215, 220, 205, 216, 218, 222, 221, 208, 213, 210, 212, 214, 219, 211, 217, 209, 239, 202, 207, 140, 139, 234, 193, 204, 135, 196, 199, 132, 194, 130, 225, 200, 159, 62, 185, 252, 59, 250, 169, 56, 191, 246, 245, 52, 243, 50, 176, 48, 173, 238, 189, 44, 235, 42, 137, 184, 231, 38, 37, 228, 35, 226, 177, 224, 151, 156, 141, 152, 154, 158, 157, 144, 149, 146, 148, 150, 155, 147, 153, 145, 175, 206, 143, 12, 11, 142, 129, 128, 7, 198, 197, 4, 195, 2, 161, 160, 255, 124, 109, 108, 122, 126, 125, 112, 117, 114, 116, 100, 123, 98, 97, 113, 79, 106, 111, 110, 99, 74, 121, 120, 71, 118, 103, 101, 115, 66, 65, 104, 127, 90, 89, 94, 83, 91, 81, 92, 95, 84, 87, 85, 82, 86, 80, 88, 77, 76, 93, 72, 107, 78, 105, 64, 69, 102, 68, 70, 75, 67, 73, 96, 55, 58, 45, 188, 51, 186, 61, 40, 119, 182, 181, 53, 179, 54, 33, 49, 15, 174, 47, 60, 171, 46, 57, 32, 167, 6, 36, 164, 43, 162, 1, 0, 63, 26, 25, 30, 19, 27, 17, 28, 31, 20, 23, 21, 18, 22, 16, 24, 13, 10, 29, 14, 3, 138, 41, 136, 39, 134, 133, 5, 131, 34, 9, 8] #f8 ou g8
83 f =[223, 250, 249, 254, 187, 251, 233, 232, 183, 230, 247, 180, 227, 178, 240, 248, 237, 236, 173, 172, 171, 238, 201, 168, 229, 166, 228, 244, 235, 242, 241, 192, 215, 220, 205, 216, 218, 222, 153, 152, 151, 210, 212, 214, 219, 146, 217, 209, 239, 142, 141, 206, 195, 234, 193, 136, 231, 196, 199, 197, 194, 226, 225, 200, 63, 188, 253, 252, 59, 190, 189, 176, 191, 246, 245, 164, 243, 162, 161, 177, 143, 170, 45, 44, 43, 138, 185, 184, 135, 38, 167, 165, 179, 34, 129, 224, 31, 154, 221, 158, 147, 26, 25, 156, 159, 22, 213, 149, 211, 150, 144, 208, 207, 14, 13, 204, 203, 202, 169, 8, 133, 198, 132, 4, 139, 131, 1, 160, 255, 124, 109, 108, 122, 126, 125, 112, 117, 114, 116, 100, 123, 98, 97, 113, 79, 106, 111, 110, 99, 74, 121, 120, 71, 118, 103, 101, 115, 66, 65, 104, 127, 90, 89, 94, 83, 91, 81, 92, 95, 84, 87, 85, 82, 86, 80, 88, 77, 76, 93, 72, 107, 78, 105, 64, 69, 102, 68, 70, 75, 67, 73, 96, 55, 58, 57, 62, 51, 186, 41, 40, 119, 182, 181, 53, 35, 54, 48, 56, 175, 174, 61, 60, 11, 46, 9, 32, 37, 6, 36, 52, 163, 50, 49, 0, 23, 28, 157, 24, 155, 30, 29, 16, 21, 18, 20, 148, 27, 19, 145, 17, 47, 10, 15, 140, 3, 42, 137, 12, 39, 134, 7, 5, 2, 130, 33, 128]
84 # chemin completement equilibre
88 # 14 = (1,1,1,0) = f(0,0,0,0)
89 # 6 = (0,1,1,0) = f(0,0,0,1)
91 # 8 = (1,0,0,0) = f(1,1,1,1)
93 n = int(log(len(f))/log(2))
95 p2nm1 = int(pow(2,n))-1
96 # pour eviter de le calculer a chaque fois
98 # fbin est la fonction (representee comme un dico)
99 # qui au tuple binaire (x3,x2,x1,x0) associe
100 # le nombre f(x3,x2,x1,x0)
102 for j in range(len(f)):
103 fbin[tuple(bin(j,n))] = bin(f[j],n)
105 #nb d'iteration pour leMixing time
107 x0 = bin(rn.randint(0,p2nm1),n)
110 fd = open("resulttemp"+str(n)+".txt","a")
111 #fd = open("resultg"+str(n)+".txt","a")
116 # on a besoin de 10^8 bit et la fonction en genere n a chaque fois
121 x= prngUnaireBin(fbin,b,x)
123 fd.write("".join([str(t) for t in x]))
124 #fd.write("".join([str(rn.randint(0,1)) for _ in range(n)]))