weiss-sim 0.1.2__cp312-cp312-win_amd64.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.
- weiss_sim/__init__.py +72 -0
- weiss_sim/rl.py +56 -0
- weiss_sim/weiss_sim.cp312-win_amd64.pyd +0 -0
- weiss_sim-0.1.2.dist-info/METADATA +5 -0
- weiss_sim-0.1.2.dist-info/RECORD +6 -0
- weiss_sim-0.1.2.dist-info/WHEEL +4 -0
weiss_sim/__init__.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from .weiss_sim import (
|
|
6
|
+
ACTION_SPACE_SIZE,
|
|
7
|
+
OBS_LEN,
|
|
8
|
+
PASS_ACTION_ID,
|
|
9
|
+
SPEC_HASH,
|
|
10
|
+
BatchOutDebug,
|
|
11
|
+
BatchOutMinimal,
|
|
12
|
+
EnvPool,
|
|
13
|
+
__version__,
|
|
14
|
+
)
|
|
15
|
+
from .rl import RlStep, pass_action_id_for_decision_kind, reset_rl, step_rl
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class EnvPoolBuffers:
|
|
19
|
+
"""Preallocated numpy buffers for high-throughput stepping."""
|
|
20
|
+
|
|
21
|
+
def __init__(self, pool: EnvPool) -> None:
|
|
22
|
+
self.pool = pool
|
|
23
|
+
num_envs = pool.envs_len
|
|
24
|
+
self.out = BatchOutMinimal(num_envs)
|
|
25
|
+
self.obs = self.out.obs
|
|
26
|
+
self.masks = self.out.masks
|
|
27
|
+
self.rewards = self.out.rewards
|
|
28
|
+
self.terminated = self.out.terminated
|
|
29
|
+
self.truncated = self.out.truncated
|
|
30
|
+
self.actor = self.out.actor
|
|
31
|
+
self.decision_id = self.out.decision_id
|
|
32
|
+
self.engine_status = self.out.engine_status
|
|
33
|
+
self.spec_hash = self.out.spec_hash
|
|
34
|
+
self.legal_ids = np.empty(num_envs * pool.action_space, dtype=np.uint16)
|
|
35
|
+
self.legal_offsets = np.zeros(num_envs + 1, dtype=np.uint32)
|
|
36
|
+
|
|
37
|
+
def reset(self):
|
|
38
|
+
self.pool.reset_into(self.out)
|
|
39
|
+
return self.out
|
|
40
|
+
|
|
41
|
+
def reset_indices(self, indices):
|
|
42
|
+
self.pool.reset_indices_into(list(indices), self.out)
|
|
43
|
+
return self.out
|
|
44
|
+
|
|
45
|
+
def reset_done(self, done_mask):
|
|
46
|
+
self.pool.reset_done_into(done_mask, self.out)
|
|
47
|
+
return self.out
|
|
48
|
+
|
|
49
|
+
def step(self, actions):
|
|
50
|
+
self.pool.step_into(actions, self.out)
|
|
51
|
+
return self.out
|
|
52
|
+
|
|
53
|
+
def legal_action_ids(self):
|
|
54
|
+
count = self.pool.legal_action_ids_into(self.legal_ids, self.legal_offsets)
|
|
55
|
+
return self.legal_ids[:count], self.legal_offsets
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
__all__ = [
|
|
59
|
+
"EnvPool",
|
|
60
|
+
"EnvPoolBuffers",
|
|
61
|
+
"BatchOutMinimal",
|
|
62
|
+
"BatchOutDebug",
|
|
63
|
+
"ACTION_SPACE_SIZE",
|
|
64
|
+
"OBS_LEN",
|
|
65
|
+
"SPEC_HASH",
|
|
66
|
+
"RlStep",
|
|
67
|
+
"reset_rl",
|
|
68
|
+
"step_rl",
|
|
69
|
+
"pass_action_id_for_decision_kind",
|
|
70
|
+
"PASS_ACTION_ID",
|
|
71
|
+
"__version__",
|
|
72
|
+
]
|
weiss_sim/rl.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
from .weiss_sim import PASS_ACTION_ID, BatchOutMinimal, EnvPool
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True)
|
|
11
|
+
class RlStep:
|
|
12
|
+
obs: np.ndarray
|
|
13
|
+
masks: np.ndarray
|
|
14
|
+
rewards: np.ndarray
|
|
15
|
+
terminated: np.ndarray
|
|
16
|
+
truncated: np.ndarray
|
|
17
|
+
actor: np.ndarray
|
|
18
|
+
decision_id: np.ndarray
|
|
19
|
+
engine_status: np.ndarray
|
|
20
|
+
spec_hash: np.ndarray
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def pass_action_id_for_decision_kind(decision_kind):
|
|
24
|
+
return PASS_ACTION_ID
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def reset_rl(pool: EnvPool) -> RlStep:
|
|
28
|
+
out = BatchOutMinimal(pool.envs_len)
|
|
29
|
+
pool.reset_into(out)
|
|
30
|
+
return RlStep(
|
|
31
|
+
obs=out.obs,
|
|
32
|
+
masks=out.masks,
|
|
33
|
+
rewards=out.rewards,
|
|
34
|
+
terminated=out.terminated,
|
|
35
|
+
truncated=out.truncated,
|
|
36
|
+
actor=out.actor,
|
|
37
|
+
decision_id=out.decision_id,
|
|
38
|
+
engine_status=out.engine_status,
|
|
39
|
+
spec_hash=out.spec_hash,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def step_rl(pool: EnvPool, actions) -> RlStep:
|
|
44
|
+
out = BatchOutMinimal(pool.envs_len)
|
|
45
|
+
pool.step_into(actions, out)
|
|
46
|
+
return RlStep(
|
|
47
|
+
obs=out.obs,
|
|
48
|
+
masks=out.masks,
|
|
49
|
+
rewards=out.rewards,
|
|
50
|
+
terminated=out.terminated,
|
|
51
|
+
truncated=out.truncated,
|
|
52
|
+
actor=out.actor,
|
|
53
|
+
decision_id=out.decision_id,
|
|
54
|
+
engine_status=out.engine_status,
|
|
55
|
+
spec_hash=out.spec_hash,
|
|
56
|
+
)
|
|
Binary file
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
weiss_sim-0.1.2.dist-info/METADATA,sha256=SyRoMqTHL0cP1SHDFzr3cqrzijhWzNjnnKHCZKOm-go,104
|
|
2
|
+
weiss_sim-0.1.2.dist-info/WHEEL,sha256=MicGETHZ2NSvTN4l4NAAzDXbOHnrlOKS0CnBsnFTiLs,97
|
|
3
|
+
weiss_sim/__init__.py,sha256=1pcn5K4wCGxSycm-JmR0B5x3n2EZdXAOClvDwTafXDM,2025
|
|
4
|
+
weiss_sim/rl.py,sha256=Ylh0NTOgf2XEubEw-LZNawNTzHZv5SRKMpXBISqTQAI,1395
|
|
5
|
+
weiss_sim/weiss_sim.cp312-win_amd64.pyd,sha256=m2MnRg3tQuDmJsTEWVcu1la8nywe9AVGFIa2LYXwUoY,1466368
|
|
6
|
+
weiss_sim-0.1.2.dist-info/RECORD,,
|