3
3
)
4
4
from csle_tolerance .util .intrusion_recovery_pomdp_util import IntrusionRecoveryPomdpUtil
5
5
import pytest_mock
6
- import numpy as np
7
6
8
7
9
8
class TestIntrusionRecoveryGameConfigSuite :
@@ -28,7 +27,7 @@ def test__init__(self) -> None:
28
27
observations = [0 , 1 ],
29
28
cost_tensor = [[1 , 2 ], [3 , 4 ]],
30
29
observation_tensor = [[1 , 2 ], [3 , 4 ]],
31
- transition_tensor = [[[0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ]]],
30
+ transition_tensor = [[[[ 0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ] ]]],
32
31
b1 = [0.1 , 0.9 ],
33
32
T = 100 ,
34
33
simulation_env_name = "sim_env" ,
@@ -48,8 +47,7 @@ def test__init__(self) -> None:
48
47
assert dto .cost_tensor == [[1 , 2 ], [3 , 4 ]]
49
48
assert dto .observation_tensor == [[1 , 2 ], [3 , 4 ]]
50
49
assert dto .transition_tensor == [
51
- [[0.1 , 0.2 ], [0.3 , 0.4 ]],
52
- [[0.5 , 0.6 ], [0.7 , 0.8 ]],
50
+ [[[0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ]]]
53
51
]
54
52
assert dto .b1 == [0.1 , 0.9 ]
55
53
assert dto .T == 100
@@ -74,7 +72,7 @@ def test__str__(self) -> None:
74
72
observations = [0 , 1 ],
75
73
cost_tensor = [[1 , 2 ], [3 , 4 ]],
76
74
observation_tensor = [[1 , 2 ], [3 , 4 ]],
77
- transition_tensor = [[[0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ]]],
75
+ transition_tensor = [[[[ 0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ] ]]],
78
76
b1 = [0.1 , 0.9 ],
79
77
T = 100 ,
80
78
simulation_env_name = "sim_env" ,
@@ -85,7 +83,7 @@ def test__str__(self) -> None:
85
83
"eta: 0.5, p_a: 0.8, p_c_1: 0.1, BTR: 10, negate_costs: True, seed: 123, "
86
84
"discount_factor: 0.9, states: [0, 1, 2], actions: [0, 1], observations: [[1, 2], [3, 4]], "
87
85
"cost_tensor: [[1, 2], [3, 4]], observation_tensor: [[1, 2], [3, 4]], "
88
- "transition_tensor: [[[0.1, 0.2], [0.3, 0.4]], [[0.5, 0.6], [0.7, 0.8]]], b1:[0.1, 0.9], "
86
+ "transition_tensor: [[[[ 0.1, 0.2], [0.3, 0.4]], [[0.5, 0.6], [0.7, 0.8] ]]], b1:[0.1, 0.9], "
89
87
"T: 100, simulation_env_name: sim_env, gym_env_name: gym_env, max_horizon: 1000"
90
88
)
91
89
assert dto .__str__ () == expected
@@ -107,7 +105,7 @@ def test_from_dict(self) -> None:
107
105
"observations" : [0 , 1 ],
108
106
"cost_tensor" : [[1 , 2 ], [3 , 4 ]],
109
107
"observation_tensor" : [[1 , 2 ], [3 , 4 ]],
110
- "transition_tensor" : [[[0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ]]],
108
+ "transition_tensor" : [[[[ 0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ] ]]],
111
109
"b1" : [0.1 , 0.9 ],
112
110
"T" : 100 ,
113
111
"simulation_env_name" : "sim_env" ,
@@ -127,8 +125,7 @@ def test_from_dict(self) -> None:
127
125
assert dto .cost_tensor == [[1 , 2 ], [3 , 4 ]]
128
126
assert dto .observation_tensor == [[1 , 2 ], [3 , 4 ]]
129
127
assert dto .transition_tensor == [
130
- [[0.1 , 0.2 ], [0.3 , 0.4 ]],
131
- [[0.5 , 0.6 ], [0.7 , 0.8 ]],
128
+ [[[0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ]]]
132
129
]
133
130
assert dto .b1 == [0.1 , 0.9 ]
134
131
assert dto .T == 100
@@ -152,7 +149,7 @@ def test_to_dict(self) -> None:
152
149
observations = [0 , 1 ],
153
150
cost_tensor = [[1 , 2 ], [3 , 4 ]],
154
151
observation_tensor = [[1 , 2 ], [3 , 4 ]],
155
- transition_tensor = [[[0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ]]],
152
+ transition_tensor = [[[[ 0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ] ]]],
156
153
b1 = [0.1 , 0.9 ],
157
154
T = 100 ,
158
155
simulation_env_name = "sim_env" ,
@@ -171,7 +168,7 @@ def test_to_dict(self) -> None:
171
168
"observations" : [0 , 1 ],
172
169
"cost_tensor" : [[1 , 2 ], [3 , 4 ]],
173
170
"observation_tensor" : [[1 , 2 ], [3 , 4 ]],
174
- "transition_tensor" : [[[0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ]]],
171
+ "transition_tensor" : [[[[ 0.1 , 0.2 ], [0.3 , 0.4 ]], [[0.5 , 0.6 ], [0.7 , 0.8 ] ]]],
175
172
"b1" : [0.1 , 0.9 ],
176
173
"T" : 100 ,
177
174
"simulation_env_name" : "sim_env" ,
@@ -186,7 +183,7 @@ def test_from_json_file(self, mocker: pytest_mock.MockFixture) -> None:
186
183
eta = 2
187
184
p_a = 0.05
188
185
p_c_1 = 0.01
189
- BTR = np . inf
186
+ BTR = 100
190
187
negate_costs = False
191
188
discount_factor = 1 - p_c_1
192
189
num_observations = 100
@@ -214,7 +211,7 @@ def test_from_json_file(self, mocker: pytest_mock.MockFixture) -> None:
214
211
eta = eta ,
215
212
p_a = p_a ,
216
213
p_c_1 = p_c_1 ,
217
- BTR = BTR ,
214
+ BTR = 100 ,
218
215
negate_costs = negate_costs ,
219
216
seed = 999 ,
220
217
discount_factor = discount_factor ,
@@ -227,7 +224,7 @@ def test_from_json_file(self, mocker: pytest_mock.MockFixture) -> None:
227
224
observation_tensor = observation_tensor ,
228
225
transition_tensor = transition_tensor ,
229
226
b1 = IntrusionRecoveryPomdpUtil .initial_belief (p_a = p_a ),
230
- T = BTR ,
227
+ T = int ( BTR ) ,
231
228
simulation_env_name = simulation_name ,
232
229
gym_env_name = "csle-tolerance-intrusion-recovery-pomdp-v1" ,
233
230
)
@@ -238,7 +235,7 @@ def test_from_json_file(self, mocker: pytest_mock.MockFixture) -> None:
238
235
assert dto .eta == 2
239
236
assert dto .p_a == 0.05
240
237
assert dto .p_c_1 == 0.01
241
- assert dto .BTR == np . inf
238
+ assert dto .BTR == 100
242
239
assert dto .negate_costs is False
243
240
assert dto .seed == 999
244
241
assert dto .discount_factor == 1 - p_c_1
0 commit comments