-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_amendment.py
128 lines (107 loc) · 4.29 KB
/
generate_amendment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import numpy as np
def flip(idxs, val_ls):
for idx in idxs:
if val_ls[idx] == 0:
val_ls[idx] = 1
elif val_ls[idx] == 1:
val_ls[idx] = 0
def main():
ace_kl_idxs0 = [47, 51, 54, 111, 118, 62, 120, 121, 77, 76]
ace_kl_idxs1 = [83, 100, 43, 81, 111, 120, 99, 76, 82, 87]
ace_kl_idxs2 = [83, 100, 81, 43, 111, 120, 99, 76, 82, 49]
ace_kl_idxs3 = [111, 54, 120, 64, 76, 41, 82, 87, 86, 73]
lime_idxs0 = [17, 90, 15, 42, 9, 66, 55, 12, 40, 50]
lime_idxs1 = [17, 15, 16, 9, 40, 66, 106, 12, 42, 90]
lime_idxs2 = [115, 9, 12, 15, 16, 90, 106, 42, 40, 17]
lime_idxs3 = [12, 15, 50, 55, 40, 115, 16, 90, 9, 66]
random_gen = np.random.RandomState(12345)
'''
0
'''
with open('data/bad0_ori.dat', 'r') as f:
val_ls0 = map(int, f.readlines()[0].strip('\n').split(' '))
flip(ace_kl_idxs0, val_ls0)
with open('data/bad0_amended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls0))+'\n')
with open('data/bad0_ori.dat', 'r') as f:
val_ls0 = map(int, f.readlines()[0].strip('\n').split(' '))
flip(lime_idxs0, val_ls0)
with open('data/bad0_lamended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls0))+'\n')
with open('data/bad0_ori.dat', 'r') as f:
val_ls0 = map(int, f.readlines()[0].strip('\n').split(' '))
rand_idxs0 = random_gen.choice(range(122), 10)
flip(rand_idxs0, val_ls0)
with open('data/bad0_random_amended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls0))+'\n')
'''
1
'''
with open('data/bad1_ori.dat', 'r') as f:
val_ls1 = map(int, f.readlines()[0].strip('\n').split(' '))
flip(ace_kl_idxs1, val_ls1)
with open('data/bad1_amended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls1))+'\n')
with open('data/bad1_ori.dat', 'r') as f:
val_ls1 = map(int, f.readlines()[0].strip('\n').split(' '))
flip(lime_idxs1, val_ls1)
with open('data/bad1_lamended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls1))+'\n')
with open('data/bad1_ori.dat', 'r') as f:
val_ls1 = map(int, f.readlines()[0].strip('\n').split(' '))
rand_idxs1 = random_gen.choice(range(122), 10)
flip(rand_idxs1, val_ls1)
with open('data/bad1_random_amended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls1))+'\n')
'''
2
'''
with open('data/bad2_ori.dat', 'r') as f:
val_ls2 = map(int, f.readlines()[0].strip('\n').split(' '))
flip(ace_kl_idxs2, val_ls2)
with open('data/bad2_amended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls2))+'\n')
with open('data/bad2_ori.dat', 'r') as f:
val_ls2 = map(int, f.readlines()[0].strip('\n').split(' '))
flip(lime_idxs2, val_ls2)
with open('data/bad2_lamended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls2))+'\n')
with open('data/bad2_ori.dat', 'r') as f:
val_ls2 = map(int, f.readlines()[0].strip('\n').split(' '))
rand_idxs2 = random_gen.choice(range(122), 10)
flip(rand_idxs2, val_ls2)
with open('data/bad2_random_amended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls2))+'\n')
'''
3
'''
with open('data/bad3_ori.dat', 'r') as f:
val_ls3 = map(int, f.readlines()[0].strip('\n').split(' '))
flip(ace_kl_idxs3, val_ls3)
with open('data/bad3_amended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls3))+'\n')
with open('data/bad3_ori.dat', 'r') as f:
val_ls3 = map(int, f.readlines()[0].strip('\n').split(' '))
flip(lime_idxs3, val_ls3)
with open('data/bad3_lamended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls3))+'\n')
with open('data/bad3_ori.dat', 'r') as f:
val_ls3 = map(int, f.readlines()[0].strip('\n').split(' '))
rand_idxs3 = random_gen.choice(range(122), 10)
flip(rand_idxs3, val_ls3)
with open('data/bad3_random_amended.dat', 'w') as g:
g.write('1 122\n')
g.write(' '.join(map(str, val_ls3))+'\n')
if __name__ == '__main__':
main()