gym-csle-stopping-game 0.6.4__py3-none-any.whl → 0.6.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of gym-csle-stopping-game might be problematic. Click here for more details.
- gym_csle_stopping_game/__version__.py +1 -1
- gym_csle_stopping_game/dao/stopping_game_config.py +1 -1
- gym_csle_stopping_game/dao/stopping_game_state.py +1 -1
- gym_csle_stopping_game/envs/stopping_game_mdp_attacker_env.py +1 -1
- gym_csle_stopping_game/util/stopping_game_util.py +54 -5
- gym_csle_stopping_game-0.6.5.dist-info/METADATA +46 -0
- {gym_csle_stopping_game-0.6.4.dist-info → gym_csle_stopping_game-0.6.5.dist-info}/RECORD +9 -9
- {gym_csle_stopping_game-0.6.4.dist-info → gym_csle_stopping_game-0.6.5.dist-info}/WHEEL +1 -1
- gym_csle_stopping_game-0.6.4.dist-info/METADATA +0 -46
- {gym_csle_stopping_game-0.6.4.dist-info → gym_csle_stopping_game-0.6.5.dist-info}/top_level.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.6.
|
|
1
|
+
__version__ = '0.6.5'
|
|
@@ -14,7 +14,7 @@ class StoppingGameConfig(SimulationEnvInputConfig):
|
|
|
14
14
|
T: npt.NDArray[Any], O: npt.NDArray[np.int_], Z: npt.NDArray[Any],
|
|
15
15
|
R: npt.NDArray[Any], S: npt.NDArray[np.int_], A1: npt.NDArray[np.int_],
|
|
16
16
|
A2: npt.NDArray[np.int_], L: int, R_INT: int, R_COST: int, R_SLA: int, R_ST: int,
|
|
17
|
-
b1: npt.NDArray[np.
|
|
17
|
+
b1: npt.NDArray[np.float64],
|
|
18
18
|
save_dir: str, checkpoint_traces_freq: int, gamma: float = 1, compute_beliefs: bool = True,
|
|
19
19
|
save_trace: bool = True) -> None:
|
|
20
20
|
"""
|
|
@@ -10,7 +10,7 @@ class StoppingGameState(JSONSerializable):
|
|
|
10
10
|
Represents the state of the optimal stopping game
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
def __init__(self, b1: npt.NDArray[np.
|
|
13
|
+
def __init__(self, b1: npt.NDArray[np.float64], L: int) -> None:
|
|
14
14
|
"""
|
|
15
15
|
Intializes the state
|
|
16
16
|
|
|
@@ -48,7 +48,7 @@ class StoppingGameMdpAttackerEnv(BaseEnv):
|
|
|
48
48
|
self.reset()
|
|
49
49
|
super().__init__()
|
|
50
50
|
|
|
51
|
-
def step(self, pi2: Union[npt.NDArray[Any], int, float, np.int_, np.
|
|
51
|
+
def step(self, pi2: Union[npt.NDArray[Any], int, float, np.int_, np.float64]) \
|
|
52
52
|
-> Tuple[npt.NDArray[Any], int, bool, bool, Dict[str, Any]]:
|
|
53
53
|
"""
|
|
54
54
|
Takes a step in the environment by executing the given action
|
|
@@ -11,7 +11,7 @@ class StoppingGameUtil:
|
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
@staticmethod
|
|
14
|
-
def b1() -> npt.NDArray[np.
|
|
14
|
+
def b1() -> npt.NDArray[np.float64]:
|
|
15
15
|
"""
|
|
16
16
|
Gets the initial belief
|
|
17
17
|
|
|
@@ -233,7 +233,7 @@ class StoppingGameUtil:
|
|
|
233
233
|
return int(np.random.choice(np.arange(0, len(S)), p=state_probs))
|
|
234
234
|
|
|
235
235
|
@staticmethod
|
|
236
|
-
def sample_initial_state(b1: npt.NDArray[np.
|
|
236
|
+
def sample_initial_state(b1: npt.NDArray[np.float64]) -> int:
|
|
237
237
|
"""
|
|
238
238
|
Samples the initial state
|
|
239
239
|
|
|
@@ -264,7 +264,7 @@ class StoppingGameUtil:
|
|
|
264
264
|
return int(o)
|
|
265
265
|
|
|
266
266
|
@staticmethod
|
|
267
|
-
def bayes_filter(s_prime: int, o: int, a1: int, b: npt.NDArray[np.
|
|
267
|
+
def bayes_filter(s_prime: int, o: int, a1: int, b: npt.NDArray[np.float64], pi2: npt.NDArray[Any], l: int,
|
|
268
268
|
config: StoppingGameConfig) -> float:
|
|
269
269
|
"""
|
|
270
270
|
A Bayesian filter to compute the belief of player 1
|
|
@@ -302,8 +302,8 @@ class StoppingGameUtil:
|
|
|
302
302
|
return float(b_prime_s_prime)
|
|
303
303
|
|
|
304
304
|
@staticmethod
|
|
305
|
-
def next_belief(o: int, a1: int, b: npt.NDArray[np.
|
|
306
|
-
config: StoppingGameConfig, l: int, a2: int = 0, s: int = 0) -> npt.NDArray[np.
|
|
305
|
+
def next_belief(o: int, a1: int, b: npt.NDArray[np.float64], pi2: npt.NDArray[Any],
|
|
306
|
+
config: StoppingGameConfig, l: int, a2: int = 0, s: int = 0) -> npt.NDArray[np.float64]:
|
|
307
307
|
"""
|
|
308
308
|
Computes the next belief using a Bayesian filter
|
|
309
309
|
|
|
@@ -337,3 +337,52 @@ class StoppingGameUtil:
|
|
|
337
337
|
:return: a2 is the attacker action
|
|
338
338
|
"""
|
|
339
339
|
return int(np.random.choice(np.arange(0, len(pi2[s])), p=pi2[s]))
|
|
340
|
+
|
|
341
|
+
@staticmethod
|
|
342
|
+
def pomdp_solver_file(config: StoppingGameConfig, discount_factor: float, pi2: npt.NDArray[Any]) -> str:
|
|
343
|
+
"""
|
|
344
|
+
Gets the POMDP environment specification based on the format at http://www.pomdp.org/code/index.html,
|
|
345
|
+
for the defender's local problem against a static attacker
|
|
346
|
+
|
|
347
|
+
:param config: the POMDP config
|
|
348
|
+
:param discount_factor: the discount factor
|
|
349
|
+
:param pi2: the attacker strategy
|
|
350
|
+
:return: the file content as a string
|
|
351
|
+
"""
|
|
352
|
+
file_str = ""
|
|
353
|
+
file_str = file_str + f"discount: {discount_factor}\n\n"
|
|
354
|
+
file_str = file_str + "values: reward\n\n"
|
|
355
|
+
file_str = file_str + f"states: {len(config.S)}\n\n"
|
|
356
|
+
file_str = file_str + f"actions: {len(config.A1)}\n\n"
|
|
357
|
+
file_str = file_str + f"observations: {len(config.O)}\n\n"
|
|
358
|
+
initial_belief_str = " ".join(list(map(lambda x: str(x), config.b1)))
|
|
359
|
+
file_str = file_str + f"start: {initial_belief_str}\n\n\n"
|
|
360
|
+
num_transitions = 0
|
|
361
|
+
for s in config.S:
|
|
362
|
+
for a1 in config.A1:
|
|
363
|
+
probs = []
|
|
364
|
+
for s_prime in range(len(config.S)):
|
|
365
|
+
num_transitions += 1
|
|
366
|
+
prob = 0
|
|
367
|
+
for a2 in config.A2:
|
|
368
|
+
prob += config.T[0][a1][a2][s][s_prime] * pi2[s][a2]
|
|
369
|
+
file_str = file_str + f"T: {a1} : {s} : {s_prime} {prob:.80f}\n"
|
|
370
|
+
probs.append(prob)
|
|
371
|
+
assert round(sum(probs), 3) == 1
|
|
372
|
+
file_str = file_str + "\n\n"
|
|
373
|
+
for a1 in config.A1:
|
|
374
|
+
for s_prime in config.S:
|
|
375
|
+
probs = []
|
|
376
|
+
for o in range(len(config.O)):
|
|
377
|
+
prob = config.Z[0][0][s_prime][o]
|
|
378
|
+
file_str = file_str + f"O : {a1} : {s_prime} : {o} {prob:.80f}\n"
|
|
379
|
+
probs.append(prob)
|
|
380
|
+
assert round(sum(probs), 3) == 1
|
|
381
|
+
file_str = file_str + "\n\n"
|
|
382
|
+
for s in config.S:
|
|
383
|
+
for a1 in config.A1:
|
|
384
|
+
for s_prime in config.S:
|
|
385
|
+
for o in config.O:
|
|
386
|
+
r = config.R[0][a1][0][s]
|
|
387
|
+
file_str = file_str + f"R: {a1} : {s} : {s_prime} : {o} {r:.80f}\n"
|
|
388
|
+
return file_str
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: gym-csle-stopping-game
|
|
3
|
+
Version: 0.6.5
|
|
4
|
+
Summary: OpenAI gym reinforcement learning environment of a Dynkin (Optimal stopping) game in CSLE
|
|
5
|
+
Author: Kim Hammar
|
|
6
|
+
Author-email: hammar.kim@gmail.com
|
|
7
|
+
License: Creative Commons Attribution-ShareAlike 4.0 International
|
|
8
|
+
Keywords: Reinforcement-Learning Cyber-Security Markov-Games Markov-Decision-Processes
|
|
9
|
+
Platform: unix
|
|
10
|
+
Platform: linux
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Requires-Dist: gymnasium>=0.27.1
|
|
18
|
+
Requires-Dist: csle-base>=0.6.5
|
|
19
|
+
Requires-Dist: csle-common>=0.6.5
|
|
20
|
+
Requires-Dist: csle-attacker>=0.6.5
|
|
21
|
+
Requires-Dist: csle-defender>=0.6.5
|
|
22
|
+
Requires-Dist: csle-collector>=0.6.5
|
|
23
|
+
Provides-Extra: testing
|
|
24
|
+
Requires-Dist: pytest>=6.0; extra == "testing"
|
|
25
|
+
Requires-Dist: pytest-cov>=2.0; extra == "testing"
|
|
26
|
+
Requires-Dist: pytest-mock>=3.6.0; extra == "testing"
|
|
27
|
+
Requires-Dist: grpcio>=1.57.0; extra == "testing"
|
|
28
|
+
Requires-Dist: grpcio-tools>=1.57.0; extra == "testing"
|
|
29
|
+
Requires-Dist: pytest-grpc>=0.8.0; extra == "testing"
|
|
30
|
+
Requires-Dist: mypy>=1.4.1; extra == "testing"
|
|
31
|
+
Requires-Dist: mypy-extensions>=1.0.0; extra == "testing"
|
|
32
|
+
Requires-Dist: mypy-protobuf>=3.5.0; extra == "testing"
|
|
33
|
+
Requires-Dist: types-PyYAML>=6.0.12.11; extra == "testing"
|
|
34
|
+
Requires-Dist: types-paramiko>=3.2.0.0; extra == "testing"
|
|
35
|
+
Requires-Dist: types-protobuf>=4.23.0.3; extra == "testing"
|
|
36
|
+
Requires-Dist: types-requests>=2.31.0.1; extra == "testing"
|
|
37
|
+
Requires-Dist: types-urllib3>=1.26.25.13; extra == "testing"
|
|
38
|
+
Requires-Dist: flake8>=6.1.0; extra == "testing"
|
|
39
|
+
Requires-Dist: flake8-rst-docstrings>=0.3.0; extra == "testing"
|
|
40
|
+
Requires-Dist: tox>=3.24; extra == "testing"
|
|
41
|
+
Requires-Dist: sphinx>=5.3.0; extra == "testing"
|
|
42
|
+
Requires-Dist: sphinxcontrib-napoleon>=0.7; extra == "testing"
|
|
43
|
+
Requires-Dist: sphinx-rtd-theme>=1.1.1; extra == "testing"
|
|
44
|
+
Requires-Dist: twine>=4.0.2; extra == "testing"
|
|
45
|
+
Requires-Dist: build>=0.10.0; extra == "testing"
|
|
46
|
+
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
gym_csle_stopping_game/__init__.py,sha256=ooy6TjxvBi1sZMEX3_mVlvfskqI5GqwITWzI882tfk0,657
|
|
2
|
-
gym_csle_stopping_game/__version__.py,sha256=
|
|
2
|
+
gym_csle_stopping_game/__version__.py,sha256=g0OeNAF6f8ojnlyb43abksBvbLUrnL-AlwclSoULgd0,22
|
|
3
3
|
gym_csle_stopping_game/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
gym_csle_stopping_game/constants/constants.py,sha256=eIoD9eXifZ73kP-lSlvG-IXCpe4n6D-_aDygx0zOr5U,1030
|
|
5
5
|
gym_csle_stopping_game/dao/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
gym_csle_stopping_game/dao/stopping_game_attacker_mdp_config.py,sha256=kmtrVa2CCVbi5xfd6uPWqMvhGmP8ccrtn1e_VmVvH7k,3494
|
|
7
|
-
gym_csle_stopping_game/dao/stopping_game_config.py,sha256=
|
|
7
|
+
gym_csle_stopping_game/dao/stopping_game_config.py,sha256=r77noSBWbP1AeBFiBVmiDeEn58SkBcHGklJStzAEEkE,6641
|
|
8
8
|
gym_csle_stopping_game/dao/stopping_game_defender_pomdp_config.py,sha256=3FfNi2-R6n1LqjA644EVq-v7wtp6sqyEkEdBN90-2n0,3753
|
|
9
|
-
gym_csle_stopping_game/dao/stopping_game_state.py,sha256=
|
|
9
|
+
gym_csle_stopping_game/dao/stopping_game_state.py,sha256=bwlvjzPkrgD61yp9EIZRZJWexEN-4SmY2OU__iIp3c0,2829
|
|
10
10
|
gym_csle_stopping_game/envs/__init__.py,sha256=SQHaqXI0_2HYsC8i9swXEHDFcXKEYpb8GRP9l_S0Sw8,74
|
|
11
11
|
gym_csle_stopping_game/envs/stopping_game_env.py,sha256=J9h73alytskNgHxa7LHM83R1PUNIALDoy0PCItA4P9k,16403
|
|
12
|
-
gym_csle_stopping_game/envs/stopping_game_mdp_attacker_env.py,sha256=
|
|
12
|
+
gym_csle_stopping_game/envs/stopping_game_mdp_attacker_env.py,sha256=UoSDY2U8x3AmOqiquwnAzolsya6bM2vVsAkW7i8ljWk,10878
|
|
13
13
|
gym_csle_stopping_game/envs/stopping_game_pomdp_defender_env.py,sha256=cyC2OuJA41aqE84KA9-oJRWsKLIqzekh8A8zyf6Qo5I,8766
|
|
14
14
|
gym_csle_stopping_game/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
gym_csle_stopping_game/util/stopping_game_util.py,sha256=
|
|
16
|
-
gym_csle_stopping_game-0.6.
|
|
17
|
-
gym_csle_stopping_game-0.6.
|
|
18
|
-
gym_csle_stopping_game-0.6.
|
|
19
|
-
gym_csle_stopping_game-0.6.
|
|
15
|
+
gym_csle_stopping_game/util/stopping_game_util.py,sha256=IlgdrQCVjkt4ta2T18Hws3b9vxJFlcywsPgWWmN06H4,13629
|
|
16
|
+
gym_csle_stopping_game-0.6.5.dist-info/METADATA,sha256=ZAhlxpiwp6QftyAYkNXYVrD6bpYmLhkt9tD3_UFXIvE,2112
|
|
17
|
+
gym_csle_stopping_game-0.6.5.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
18
|
+
gym_csle_stopping_game-0.6.5.dist-info/top_level.txt,sha256=3DBHkAEI00nq0aXZlJUkXJrLiwkcJCfaFoYcaOzEZUU,23
|
|
19
|
+
gym_csle_stopping_game-0.6.5.dist-info/RECORD,,
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: gym-csle-stopping-game
|
|
3
|
-
Version: 0.6.4
|
|
4
|
-
Summary: OpenAI gym reinforcement learning environment of a Dynkin (Optimal stopping) game in CSLE
|
|
5
|
-
Author: Kim Hammar
|
|
6
|
-
Author-email: hammar.kim@gmail.com
|
|
7
|
-
License: Creative Commons Attribution-ShareAlike 4.0 International
|
|
8
|
-
Keywords: Reinforcement-Learning Cyber-Security Markov-Games Markov-Decision-Processes
|
|
9
|
-
Platform: unix
|
|
10
|
-
Platform: linux
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
-
Classifier: Intended Audience :: Science/Research
|
|
16
|
-
Requires-Python: >=3.8
|
|
17
|
-
Requires-Dist: gymnasium >=0.27.1
|
|
18
|
-
Requires-Dist: csle-base >=0.6.4
|
|
19
|
-
Requires-Dist: csle-common >=0.6.4
|
|
20
|
-
Requires-Dist: csle-attacker >=0.6.4
|
|
21
|
-
Requires-Dist: csle-defender >=0.6.4
|
|
22
|
-
Requires-Dist: csle-collector >=0.6.4
|
|
23
|
-
Provides-Extra: testing
|
|
24
|
-
Requires-Dist: pytest >=6.0 ; extra == 'testing'
|
|
25
|
-
Requires-Dist: pytest-cov >=2.0 ; extra == 'testing'
|
|
26
|
-
Requires-Dist: pytest-mock >=3.6.0 ; extra == 'testing'
|
|
27
|
-
Requires-Dist: grpcio >=1.57.0 ; extra == 'testing'
|
|
28
|
-
Requires-Dist: grpcio-tools >=1.57.0 ; extra == 'testing'
|
|
29
|
-
Requires-Dist: pytest-grpc >=0.8.0 ; extra == 'testing'
|
|
30
|
-
Requires-Dist: mypy >=1.4.1 ; extra == 'testing'
|
|
31
|
-
Requires-Dist: mypy-extensions >=1.0.0 ; extra == 'testing'
|
|
32
|
-
Requires-Dist: mypy-protobuf >=3.5.0 ; extra == 'testing'
|
|
33
|
-
Requires-Dist: types-PyYAML >=6.0.12.11 ; extra == 'testing'
|
|
34
|
-
Requires-Dist: types-paramiko >=3.2.0.0 ; extra == 'testing'
|
|
35
|
-
Requires-Dist: types-protobuf >=4.23.0.3 ; extra == 'testing'
|
|
36
|
-
Requires-Dist: types-requests >=2.31.0.1 ; extra == 'testing'
|
|
37
|
-
Requires-Dist: types-urllib3 >=1.26.25.13 ; extra == 'testing'
|
|
38
|
-
Requires-Dist: flake8 >=6.1.0 ; extra == 'testing'
|
|
39
|
-
Requires-Dist: flake8-rst-docstrings >=0.3.0 ; extra == 'testing'
|
|
40
|
-
Requires-Dist: tox >=3.24 ; extra == 'testing'
|
|
41
|
-
Requires-Dist: sphinx >=5.3.0 ; extra == 'testing'
|
|
42
|
-
Requires-Dist: sphinxcontrib-napoleon >=0.7 ; extra == 'testing'
|
|
43
|
-
Requires-Dist: sphinx-rtd-theme >=1.1.1 ; extra == 'testing'
|
|
44
|
-
Requires-Dist: twine >=4.0.2 ; extra == 'testing'
|
|
45
|
-
Requires-Dist: build >=0.10.0 ; extra == 'testing'
|
|
46
|
-
|
{gym_csle_stopping_game-0.6.4.dist-info → gym_csle_stopping_game-0.6.5.dist-info}/top_level.txt
RENAMED
|
File without changes
|