multi-agent-rlenv 3.5.2__py3-none-any.whl → 3.5.4__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.
- marlenv/__init__.py +1 -1
- marlenv/models/episode.py +4 -49
- marlenv/models/observation.py +10 -0
- marlenv/models/state.py +8 -0
- {multi_agent_rlenv-3.5.2.dist-info → multi_agent_rlenv-3.5.4.dist-info}/METADATA +4 -1
- {multi_agent_rlenv-3.5.2.dist-info → multi_agent_rlenv-3.5.4.dist-info}/RECORD +8 -8
- {multi_agent_rlenv-3.5.2.dist-info → multi_agent_rlenv-3.5.4.dist-info}/WHEEL +0 -0
- {multi_agent_rlenv-3.5.2.dist-info → multi_agent_rlenv-3.5.4.dist-info}/licenses/LICENSE +0 -0
marlenv/__init__.py
CHANGED
|
@@ -62,7 +62,7 @@ print(env.extras_shape) # (1, )
|
|
|
62
62
|
If you want to create a new environment, you can simply create a class that inherits from `MARLEnv`. If you want to create a wrapper around an existing `MARLEnv`, you probably want to subclass `RLEnvWrapper` which implements a default behaviour for every method.
|
|
63
63
|
"""
|
|
64
64
|
|
|
65
|
-
__version__ = "3.5.
|
|
65
|
+
__version__ = "3.5.4"
|
|
66
66
|
|
|
67
67
|
from . import models
|
|
68
68
|
from .models import (
|
marlenv/models/episode.py
CHANGED
|
@@ -22,10 +22,10 @@ class Episode:
|
|
|
22
22
|
all_extras: list[npt.NDArray[np.float32]]
|
|
23
23
|
actions: list[npt.NDArray]
|
|
24
24
|
rewards: list[npt.NDArray[np.float32]]
|
|
25
|
-
all_available_actions: list[npt.NDArray[np.
|
|
25
|
+
all_available_actions: list[npt.NDArray[np.bool]]
|
|
26
26
|
all_states: list[npt.NDArray[np.float32]]
|
|
27
27
|
all_states_extras: list[npt.NDArray[np.float32]]
|
|
28
|
-
metrics: dict[str,
|
|
28
|
+
metrics: dict[str, Any]
|
|
29
29
|
episode_len: int
|
|
30
30
|
other: dict[str, list[Any]]
|
|
31
31
|
is_done: bool = False
|
|
@@ -33,7 +33,7 @@ class Episode:
|
|
|
33
33
|
"""Whether the episode did reach a terminal state (different from truncated)"""
|
|
34
34
|
|
|
35
35
|
@staticmethod
|
|
36
|
-
def new(obs: Observation, state: State, metrics: Optional[dict[str,
|
|
36
|
+
def new(obs: Observation, state: State, metrics: Optional[dict[str, Any]] = None) -> "Episode":
|
|
37
37
|
if metrics is None:
|
|
38
38
|
metrics = {}
|
|
39
39
|
return Episode(
|
|
@@ -363,51 +363,6 @@ class Episode:
|
|
|
363
363
|
for i, s in enumerate(scores):
|
|
364
364
|
self.metrics[f"score-{i}"] = float(s)
|
|
365
365
|
|
|
366
|
-
|
|
367
|
-
# self,
|
|
368
|
-
# new_obs: Observation,
|
|
369
|
-
# new_state: State,
|
|
370
|
-
# action: A,
|
|
371
|
-
# reward: np.ndarray,
|
|
372
|
-
# done: bool,
|
|
373
|
-
# truncated: bool,
|
|
374
|
-
# info: dict[str, Any],
|
|
375
|
-
# **kwargs,
|
|
376
|
-
# ):
|
|
377
|
-
# """Add a new transition to the episode"""
|
|
378
|
-
# self.episode_len += 1
|
|
379
|
-
# self.all_observations.append(new_obs.data)
|
|
380
|
-
# self.all_extras.append(new_obs.extras)
|
|
381
|
-
# self.all_available_actions.append(new_obs.available_actions)
|
|
382
|
-
# self.all_states.append(new_state.data)
|
|
383
|
-
# self.all_states_extras.append(new_state.extras)
|
|
384
|
-
# match action:
|
|
385
|
-
# case np.ndarray() as action:
|
|
386
|
-
# self.actions.append(action)
|
|
387
|
-
# case other:
|
|
388
|
-
# self.actions.append(np.array(other))
|
|
389
|
-
# self.rewards.append(reward)
|
|
390
|
-
# for key, value in kwargs.items():
|
|
391
|
-
# current = self.other.get(key, [])
|
|
392
|
-
# current.append(value)
|
|
393
|
-
# self.other[key] = current
|
|
394
|
-
|
|
395
|
-
# if done:
|
|
396
|
-
# # Only set the truncated flag if the episode is not done (both could happen with a time limit)
|
|
397
|
-
# self.is_truncated = truncated
|
|
398
|
-
# self.is_done = done
|
|
399
|
-
# # Add metrics that can be plotted
|
|
400
|
-
# for key, value in info.items():
|
|
401
|
-
# if isinstance(value, bool):
|
|
402
|
-
# value = int(value)
|
|
403
|
-
# self.metrics[key] = value
|
|
404
|
-
# self.metrics["episode_len"] = self.episode_len
|
|
405
|
-
|
|
406
|
-
# rewards = np.array(self.rewards)
|
|
407
|
-
# scores = np.sum(rewards, axis=0)
|
|
408
|
-
# for i, s in enumerate(scores):
|
|
409
|
-
# self.metrics[f"score-{i}"] = float(s)
|
|
410
|
-
|
|
411
|
-
def add_metrics(self, metrics: dict[str, float]):
|
|
366
|
+
def add_metrics(self, metrics: dict[str, Any]):
|
|
412
367
|
"""Add metrics to the episode"""
|
|
413
368
|
self.metrics.update(metrics)
|
marlenv/models/observation.py
CHANGED
|
@@ -87,3 +87,13 @@ class Observation:
|
|
|
87
87
|
if not np.array_equal(self.data, other.data):
|
|
88
88
|
return False
|
|
89
89
|
return np.array_equal(self.extras, other.extras) and np.array_equal(self.available_actions, other.available_actions)
|
|
90
|
+
|
|
91
|
+
def as_tensors(self, device=None):
|
|
92
|
+
"""
|
|
93
|
+
Convert the observation to a tuple of tensors of shape (1, n_agents, <dim>).
|
|
94
|
+
"""
|
|
95
|
+
import torch
|
|
96
|
+
|
|
97
|
+
data = torch.from_numpy(self.data).unsqueeze(0).to(device, non_blocking=True)
|
|
98
|
+
extras = torch.from_numpy(self.extras).unsqueeze(0).to(device, non_blocking=True)
|
|
99
|
+
return data, extras
|
marlenv/models/state.py
CHANGED
|
@@ -52,3 +52,11 @@ class State(Generic[StateType]):
|
|
|
52
52
|
if not np.array_equal(self.extras, value.extras):
|
|
53
53
|
return False
|
|
54
54
|
return True
|
|
55
|
+
|
|
56
|
+
def as_tensors(self, device=None):
|
|
57
|
+
"""Convert the state to a tuple of tensors of shape (1, <dim>)."""
|
|
58
|
+
import torch
|
|
59
|
+
|
|
60
|
+
data = torch.from_numpy(self.data).unsqueeze(0).to(device, non_blocking=True)
|
|
61
|
+
extras = torch.from_numpy(self.extras).unsqueeze(0).to(device, non_blocking=True)
|
|
62
|
+
return data, extras
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multi-agent-rlenv
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.4
|
|
4
4
|
Summary: A strongly typed Multi-Agent Reinforcement Learning framework
|
|
5
5
|
Project-URL: repository, https://github.com/yamoling/multi-agent-rlenv
|
|
6
6
|
Author-email: Yannick Molinghen <yannick.molinghen@ulb.be>
|
|
@@ -19,6 +19,7 @@ Requires-Dist: pymunk>=6.0; extra == 'all'
|
|
|
19
19
|
Requires-Dist: pysc2; extra == 'all'
|
|
20
20
|
Requires-Dist: scipy>=1.10; extra == 'all'
|
|
21
21
|
Requires-Dist: smac; extra == 'all'
|
|
22
|
+
Requires-Dist: torch>=2.0; extra == 'all'
|
|
22
23
|
Provides-Extra: gym
|
|
23
24
|
Requires-Dist: gymnasium>=0.29.1; extra == 'gym'
|
|
24
25
|
Provides-Extra: overcooked
|
|
@@ -31,6 +32,8 @@ Requires-Dist: scipy>=1.10; extra == 'pettingzoo'
|
|
|
31
32
|
Provides-Extra: smac
|
|
32
33
|
Requires-Dist: pysc2; extra == 'smac'
|
|
33
34
|
Requires-Dist: smac; extra == 'smac'
|
|
35
|
+
Provides-Extra: torch
|
|
36
|
+
Requires-Dist: torch>=2.0; extra == 'torch'
|
|
34
37
|
Description-Content-Type: text/markdown
|
|
35
38
|
|
|
36
39
|
# `marlenv` - A unified framework for muti-agent reinforcement learning
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
marlenv/__init__.py,sha256
|
|
1
|
+
marlenv/__init__.py,sha256=-XMj91_t4PoY6zLhr395u_svfIXYlvk-tMR4YqG-2VQ,3656
|
|
2
2
|
marlenv/env_builder.py,sha256=RJoHJLYAUE1ausAoJiRC3fUxyxpH1WRJf7Sdm2ml-uk,5517
|
|
3
3
|
marlenv/env_pool.py,sha256=nCEBkGQU62fcvCAANyAqY8gCFjYlVnSCg-V3Fhx00yc,933
|
|
4
4
|
marlenv/exceptions.py,sha256=gJUC_2rVAvOfK_ypVFc7Myh-pIfSU3To38VBVS_0rZA,1179
|
|
@@ -12,10 +12,10 @@ marlenv/adapters/pymarl_adapter.py,sha256=2s7EY31s1hrml3q-BBaXo_eDMXTjkebozZPvzs
|
|
|
12
12
|
marlenv/adapters/smac_adapter.py,sha256=8uWC7YKsaSXeTS8AUhpGOKvrWMbVEQT2-pml5BaFUB0,8343
|
|
13
13
|
marlenv/models/__init__.py,sha256=uihmRs71Gg5z7Bvau_xtaQVg7xEtX8sTzi74bIHL5P0,443
|
|
14
14
|
marlenv/models/env.py,sha256=BG1iVHxGD_p827mF0ewyOBn6wU2gtFsHLW1b4UtW-V0,7841
|
|
15
|
-
marlenv/models/episode.py,sha256=
|
|
16
|
-
marlenv/models/observation.py,sha256=
|
|
15
|
+
marlenv/models/episode.py,sha256=DOX2FpWK-wm0BX_vC2bVD4BUMiP-JHUfRl80MGXD7kc,13472
|
|
16
|
+
marlenv/models/observation.py,sha256=RhvKvmys4bu3UwwVsvu7fJ7TMKt2QkKnBD1e0hw2r7s,3528
|
|
17
17
|
marlenv/models/spaces.py,sha256=v7jnhPfj7vq7DFFJpSbQEYe4NGLLlj_bj2pzvvSBX7Y,7777
|
|
18
|
-
marlenv/models/state.py,sha256=
|
|
18
|
+
marlenv/models/state.py,sha256=LbP--JxBzRwMFpEAaZyxCX13xKQ27xPE2fabohaq9YI,2058
|
|
19
19
|
marlenv/models/step.py,sha256=00PhD_ccdCIYAY1SVJdJU91weU0Y_tNIJwK16TN_53I,3056
|
|
20
20
|
marlenv/models/transition.py,sha256=UkJVRNxZoyRkjE7YmKtUf_4xA7cOEh20O60dTldbvys,5070
|
|
21
21
|
marlenv/utils/__init__.py,sha256=C3qhvkVwctBP8mG3G5nkAZ5DKfErVRkdbHo7oeWVsM0,209
|
|
@@ -34,7 +34,7 @@ marlenv/wrappers/potential_shaping.py,sha256=T_QvnmWReCgpyoInxRw2UXbmdvcBD5U-vV1
|
|
|
34
34
|
marlenv/wrappers/rlenv_wrapper.py,sha256=S6G1VjFklTEzU6bj0AXrTDXnsTQJARq8VB4uUH6AXe4,2993
|
|
35
35
|
marlenv/wrappers/time_limit.py,sha256=GxbxcbfFyuVg14ylQU2C_cjmV9q4uDAt5wepfgX_PyM,3976
|
|
36
36
|
marlenv/wrappers/video_recorder.py,sha256=ucBQSNRPqDr-2mYxrTCqlrWcxSWtSJ7XlRC9-LdukBM,2535
|
|
37
|
-
multi_agent_rlenv-3.5.
|
|
38
|
-
multi_agent_rlenv-3.5.
|
|
39
|
-
multi_agent_rlenv-3.5.
|
|
40
|
-
multi_agent_rlenv-3.5.
|
|
37
|
+
multi_agent_rlenv-3.5.4.dist-info/METADATA,sha256=xgYpo8yrpncxWufHZSqMIeeT3Bb8Ll9DylTRKyesdT4,5005
|
|
38
|
+
multi_agent_rlenv-3.5.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
39
|
+
multi_agent_rlenv-3.5.4.dist-info/licenses/LICENSE,sha256=_eeiGVoIJ7kYt6l1zbIvSBQppTnw0mjnYk1lQ4FxEjE,1074
|
|
40
|
+
multi_agent_rlenv-3.5.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|