forked from yuqiChen94/Causally-Different-Attacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapproximating_the_causal_capabilities.py
91 lines (89 loc) · 1.96 KB
/
approximating_the_causal_capabilities.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
from search.find_causal_capability import simulation_with_attack
from search.find_causal_capability import simulation_normal
from search.find_causal_capability import find_causal_capability
from attack_array.attack_array import interpret_capability_set
from statemachine.myFSM import convert_Y_set
history = [
[
[0, 2],
[4, 2],
[5, 2],
[8, 1],
[17, 1],
[21, 2],
[3, 2],
[19, 2],
[23, 2],
[12, 2],
[20, 2],
[22, 1],
[20, 1],
[9, 2],
[8, 2],
[10, 2],
[7, 2],
[23, 1],
[21, 1],
[18, 2],
[16, 2],
[1, 1],
[5, 1],
],
[
[16, 1],
[15, 2],
[10, 1],
[11, 1],
[8, 1],
[7, 2],
[5, 2],
[7, 1],
[13, 1],
[14, 1],
[0, 1],
[20, 1],
[18, 1],
[4, 2],
[2, 1],
[21, 2],
[15, 1],
[25, 1],
[0, 2],
[20, 2],
[14, 2],
[1, 2],
[17, 1],
[24, 2],
[11, 2],
[10, 2],
[8, 2],
[3, 1],
[16, 2],
[23, 1],
[6, 1],
[22, 1],
[12, 2],
[23, 2],
[21, 1],
[9, 1],
[6, 2],
[2, 2],
],
]
# history is an attack
print(interpret_capability_set(history[0]))
threshold = 1000
sensor_index = 0
# target sensor is LIT101, of which index is 0.
current_sensor = 590
# current sensor value
time_interval = 10
# time interval for simulator
# start from the initial state
print(simulation_with_attack(sensor_index, current_sensor, history, time_interval))
print(simulation_normal(sensor_index, current_sensor, history, time_interval))
Y_set = find_causal_capability(
sensor_index, current_sensor, history, time_interval, threshold
)
# print (find_causal_capability(sensor_index,current_sensor,history,time_interval,threshold))
print(convert_Y_set(Y_set))