multi-agent-rlenv 3.5.1__py3-none-any.whl → 3.5.2__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/env.py +1 -1
- marlenv/models/episode.py +6 -6
- marlenv/wrappers/potential_shaping.py +11 -6
- {multi_agent_rlenv-3.5.1.dist-info → multi_agent_rlenv-3.5.2.dist-info}/METADATA +1 -1
- {multi_agent_rlenv-3.5.1.dist-info → multi_agent_rlenv-3.5.2.dist-info}/RECORD +8 -8
- {multi_agent_rlenv-3.5.1.dist-info → multi_agent_rlenv-3.5.2.dist-info}/WHEEL +0 -0
- {multi_agent_rlenv-3.5.1.dist-info → multi_agent_rlenv-3.5.2.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.2"
|
|
66
66
|
|
|
67
67
|
from . import models
|
|
68
68
|
from .models import (
|
marlenv/models/env.py
CHANGED
|
@@ -199,7 +199,7 @@ class MARLEnv(ABC, Generic[ActionSpaceType]):
|
|
|
199
199
|
episode.add(step, action)
|
|
200
200
|
return episode
|
|
201
201
|
|
|
202
|
-
def has_same_inouts(self, other) -> bool:
|
|
202
|
+
def has_same_inouts(self, other: "MARLEnv[ActionSpaceType]") -> bool:
|
|
203
203
|
"""Alias for `have_same_inouts(self, other)`."""
|
|
204
204
|
if not isinstance(other, MARLEnv):
|
|
205
205
|
return False
|
marlenv/models/episode.py
CHANGED
|
@@ -66,13 +66,13 @@ class Episode:
|
|
|
66
66
|
if target_len < self.episode_len:
|
|
67
67
|
raise ValueError(f"Cannot pad episode to a smaller size: {target_len} < {self.episode_len}")
|
|
68
68
|
padding_size = target_len - self.episode_len
|
|
69
|
-
obs = self.all_observations + [self.all_observations[0]] * padding_size
|
|
70
|
-
extras = self.all_extras + [self.all_extras[0]] * padding_size
|
|
71
|
-
actions = self.actions + [self.actions[0]] * padding_size
|
|
72
|
-
rewards = self.rewards + [self.rewards[0]] * padding_size
|
|
69
|
+
obs = self.all_observations + [np.zeros_like(self.all_observations[0])] * padding_size
|
|
70
|
+
extras = self.all_extras + [np.zeros_like(self.all_extras[0])] * padding_size
|
|
71
|
+
actions = self.actions + [np.zeros_like(self.actions[0])] * padding_size
|
|
72
|
+
rewards = self.rewards + [np.zeros_like(self.rewards[0])] * padding_size
|
|
73
73
|
availables = self.all_available_actions + [self.all_available_actions[0]] * padding_size
|
|
74
|
-
states = self.all_states + [self.all_states[0]] * padding_size
|
|
75
|
-
states_extras = self.all_states_extras + [self.all_states_extras[0]] * padding_size
|
|
74
|
+
states = self.all_states + [np.zeros_like(self.all_states[0])] * padding_size
|
|
75
|
+
states_extras = self.all_states_extras + [np.zeros_like(self.all_states_extras[0])] * padding_size
|
|
76
76
|
other = {key: value + [value[0]] * padding_size for key, value in self.other.items()}
|
|
77
77
|
return Episode(
|
|
78
78
|
all_observations=obs,
|
|
@@ -2,10 +2,15 @@ from abc import abstractmethod, ABC
|
|
|
2
2
|
from .rlenv_wrapper import RLEnvWrapper
|
|
3
3
|
from marlenv import Space, MARLEnv, Observation
|
|
4
4
|
from typing import TypeVar, Optional
|
|
5
|
+
import numpy as np
|
|
6
|
+
import numpy.typing as npt
|
|
7
|
+
|
|
8
|
+
from dataclasses import dataclass
|
|
5
9
|
|
|
6
10
|
A = TypeVar("A", bound=Space)
|
|
7
11
|
|
|
8
12
|
|
|
13
|
+
@dataclass
|
|
9
14
|
class PotentialShaping(RLEnvWrapper[A], ABC):
|
|
10
15
|
"""
|
|
11
16
|
Potential shaping for the Laser Learning Environment (LLE).
|
|
@@ -23,7 +28,7 @@ class PotentialShaping(RLEnvWrapper[A], ABC):
|
|
|
23
28
|
):
|
|
24
29
|
super().__init__(env, extra_shape=extra_shape)
|
|
25
30
|
self.gamma = gamma
|
|
26
|
-
self.
|
|
31
|
+
self._current_potential = self.compute_potential()
|
|
27
32
|
|
|
28
33
|
def add_extras(self, obs: Observation) -> Observation:
|
|
29
34
|
"""Add the extras related to potential shaping. Does nothing by default."""
|
|
@@ -31,19 +36,19 @@ class PotentialShaping(RLEnvWrapper[A], ABC):
|
|
|
31
36
|
|
|
32
37
|
def reset(self):
|
|
33
38
|
obs, state = super().reset()
|
|
34
|
-
self.
|
|
39
|
+
self._current_potential = self.compute_potential()
|
|
35
40
|
return self.add_extras(obs), state
|
|
36
41
|
|
|
37
42
|
def step(self, actions):
|
|
38
|
-
|
|
43
|
+
prev_potential = self._current_potential
|
|
39
44
|
step = super().step(actions)
|
|
40
45
|
|
|
41
|
-
self.
|
|
42
|
-
shaped_reward = self.gamma * self.
|
|
46
|
+
self._current_potential = self.compute_potential()
|
|
47
|
+
shaped_reward = self.gamma * self._current_potential - prev_potential
|
|
43
48
|
step.obs = self.add_extras(step.obs)
|
|
44
49
|
step.reward += shaped_reward
|
|
45
50
|
return step
|
|
46
51
|
|
|
47
52
|
@abstractmethod
|
|
48
|
-
def compute_potential(self) -> float:
|
|
53
|
+
def compute_potential(self) -> float | npt.NDArray[np.float32]:
|
|
49
54
|
"""Compute the potential of the current state of the environment."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multi-agent-rlenv
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.2
|
|
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>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
marlenv/__init__.py,sha256=
|
|
1
|
+
marlenv/__init__.py,sha256=UoZATsYMuKlnHyYdIRX7eQ6mGcmMww-tqX3uCyWVqRA,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
|
|
@@ -11,8 +11,8 @@ marlenv/adapters/pettingzoo_adapter.py,sha256=w9Ta-X4L_6ZXdDGmREOdcU0vpLR8lGP__s
|
|
|
11
11
|
marlenv/adapters/pymarl_adapter.py,sha256=2s7EY31s1hrml3q-BBaXo_eDMXTjkebozZPvzsgrb9c,3353
|
|
12
12
|
marlenv/adapters/smac_adapter.py,sha256=8uWC7YKsaSXeTS8AUhpGOKvrWMbVEQT2-pml5BaFUB0,8343
|
|
13
13
|
marlenv/models/__init__.py,sha256=uihmRs71Gg5z7Bvau_xtaQVg7xEtX8sTzi74bIHL5P0,443
|
|
14
|
-
marlenv/models/env.py,sha256=
|
|
15
|
-
marlenv/models/episode.py,sha256=
|
|
14
|
+
marlenv/models/env.py,sha256=BG1iVHxGD_p827mF0ewyOBn6wU2gtFsHLW1b4UtW-V0,7841
|
|
15
|
+
marlenv/models/episode.py,sha256=IKPLuDVlz85Be6zrC21gyautjqRkEApS4fgRqQR52s0,15190
|
|
16
16
|
marlenv/models/observation.py,sha256=kAmh1hIoC2TGrZlGVzV0y4TXXCSrI7gcmG0raeoncYk,3153
|
|
17
17
|
marlenv/models/spaces.py,sha256=v7jnhPfj7vq7DFFJpSbQEYe4NGLLlj_bj2pzvvSBX7Y,7777
|
|
18
18
|
marlenv/models/state.py,sha256=958PXTHadi3gtRnhGgcGtqBnF44R11kdcx62NN2gwxA,1717
|
|
@@ -30,11 +30,11 @@ marlenv/wrappers/delayed_rewards.py,sha256=P8az9rYmu67OzL1ZEFqfTQcCxRI_AXKXrKUBQ
|
|
|
30
30
|
marlenv/wrappers/last_action_wrapper.py,sha256=QVepSLcWExqACwKvAM0G2LALapSoWdd7YHmah2LZ3vE,2603
|
|
31
31
|
marlenv/wrappers/paddings.py,sha256=0aAi7RP1yL8I5mR4Oxzl9-itKys88mgsPjqe7q-frbk,2024
|
|
32
32
|
marlenv/wrappers/penalty_wrapper.py,sha256=3YBoUV6ETksZ8tFEOq1WYXvPs3ejMAehE6-QA8e4JOE,864
|
|
33
|
-
marlenv/wrappers/potential_shaping.py,sha256=
|
|
33
|
+
marlenv/wrappers/potential_shaping.py,sha256=T_QvnmWReCgpyoInxRw2UXbmdvcBD5U-vV1ledLG7y8,1661
|
|
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.2.dist-info/METADATA,sha256=QjQkN0ZJsbaa-GyP7fAs4JFSTJkEUBLrIV0zCGPUvrc,4897
|
|
38
|
+
multi_agent_rlenv-3.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
39
|
+
multi_agent_rlenv-3.5.2.dist-info/licenses/LICENSE,sha256=_eeiGVoIJ7kYt6l1zbIvSBQppTnw0mjnYk1lQ4FxEjE,1074
|
|
40
|
+
multi_agent_rlenv-3.5.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|