multi-agent-rlenv 3.5.0__py3-none-any.whl → 3.5.1__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/step.py +1 -1
- marlenv/wrappers/__init__.py +2 -0
- marlenv/wrappers/potential_shaping.py +49 -0
- marlenv/wrappers/rlenv_wrapper.py +1 -2
- {multi_agent_rlenv-3.5.0.dist-info → multi_agent_rlenv-3.5.1.dist-info}/METADATA +1 -1
- {multi_agent_rlenv-3.5.0.dist-info → multi_agent_rlenv-3.5.1.dist-info}/RECORD +9 -8
- {multi_agent_rlenv-3.5.0.dist-info → multi_agent_rlenv-3.5.1.dist-info}/WHEEL +0 -0
- {multi_agent_rlenv-3.5.0.dist-info → multi_agent_rlenv-3.5.1.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.1"
|
|
66
66
|
|
|
67
67
|
from . import models
|
|
68
68
|
from .models import (
|
marlenv/models/step.py
CHANGED
|
@@ -39,7 +39,7 @@ class Step:
|
|
|
39
39
|
case int() | float():
|
|
40
40
|
self.reward = np.array([reward], dtype=np.float32)
|
|
41
41
|
case np.ndarray():
|
|
42
|
-
self.reward = reward
|
|
42
|
+
self.reward = reward.astype(np.float32)
|
|
43
43
|
case other:
|
|
44
44
|
# We assume this is a sequence of some sort
|
|
45
45
|
self.reward = np.array(other, dtype=np.float32)
|
marlenv/wrappers/__init__.py
CHANGED
|
@@ -10,6 +10,7 @@ from .blind_wrapper import Blind
|
|
|
10
10
|
from .centralised import Centralized
|
|
11
11
|
from .available_actions_mask import AvailableActionsMask
|
|
12
12
|
from .delayed_rewards import DelayedReward
|
|
13
|
+
from .potential_shaping import PotentialShaping
|
|
13
14
|
|
|
14
15
|
__all__ = [
|
|
15
16
|
"RLEnvWrapper",
|
|
@@ -26,4 +27,5 @@ __all__ = [
|
|
|
26
27
|
"Blind",
|
|
27
28
|
"Centralized",
|
|
28
29
|
"DelayedReward",
|
|
30
|
+
"PotentialShaping",
|
|
29
31
|
]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from abc import abstractmethod, ABC
|
|
2
|
+
from .rlenv_wrapper import RLEnvWrapper
|
|
3
|
+
from marlenv import Space, MARLEnv, Observation
|
|
4
|
+
from typing import TypeVar, Optional
|
|
5
|
+
|
|
6
|
+
A = TypeVar("A", bound=Space)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PotentialShaping(RLEnvWrapper[A], ABC):
|
|
10
|
+
"""
|
|
11
|
+
Potential shaping for the Laser Learning Environment (LLE).
|
|
12
|
+
|
|
13
|
+
https://people.eecs.berkeley.edu/~pabbeel/cs287-fa09/readings/NgHaradaRussell-shaping-ICML1999.pdf
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
gamma: float
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
env: MARLEnv,
|
|
21
|
+
gamma: float = 1.0,
|
|
22
|
+
extra_shape: Optional[tuple[int]] = None,
|
|
23
|
+
):
|
|
24
|
+
super().__init__(env, extra_shape=extra_shape)
|
|
25
|
+
self.gamma = gamma
|
|
26
|
+
self.current_potential = self.compute_potential()
|
|
27
|
+
|
|
28
|
+
def add_extras(self, obs: Observation) -> Observation:
|
|
29
|
+
"""Add the extras related to potential shaping. Does nothing by default."""
|
|
30
|
+
return obs
|
|
31
|
+
|
|
32
|
+
def reset(self):
|
|
33
|
+
obs, state = super().reset()
|
|
34
|
+
self.current_potential = self.compute_potential()
|
|
35
|
+
return self.add_extras(obs), state
|
|
36
|
+
|
|
37
|
+
def step(self, actions):
|
|
38
|
+
phi_t = self.current_potential
|
|
39
|
+
step = super().step(actions)
|
|
40
|
+
|
|
41
|
+
self.current_potential = self.compute_potential()
|
|
42
|
+
shaped_reward = self.gamma * self.current_potential - phi_t
|
|
43
|
+
step.obs = self.add_extras(step.obs)
|
|
44
|
+
step.reward += shaped_reward
|
|
45
|
+
return step
|
|
46
|
+
|
|
47
|
+
@abstractmethod
|
|
48
|
+
def compute_potential(self) -> float:
|
|
49
|
+
"""Compute the potential of the current state of the environment."""
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from typing import Optional, Sequence
|
|
2
2
|
from typing_extensions import TypeVar
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from abc import ABC
|
|
5
4
|
import numpy as np
|
|
6
5
|
|
|
7
6
|
from marlenv.models import MARLEnv, Space, DiscreteSpace, State
|
|
@@ -11,7 +10,7 @@ AS = TypeVar("AS", bound=Space, default=Space)
|
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
@dataclass
|
|
14
|
-
class RLEnvWrapper(MARLEnv[AS]
|
|
13
|
+
class RLEnvWrapper(MARLEnv[AS]):
|
|
15
14
|
"""Parent class for all RLEnv wrappers"""
|
|
16
15
|
|
|
17
16
|
wrapped: MARLEnv[AS]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multi-agent-rlenv
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.1
|
|
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=zNSSEveqBncupuGlVpeywLpK4BZSrXufi-BUhG96e4s,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
|
|
@@ -16,11 +16,11 @@ marlenv/models/episode.py,sha256=IF3-8YV0tHsIjTYZUOlHmX_IyjnrrzTWk-HPk_mwcR4,151
|
|
|
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
|
|
19
|
-
marlenv/models/step.py,sha256=
|
|
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
|
|
22
22
|
marlenv/utils/schedule.py,sha256=slhtpQiBHSUNyPmSkKb2yBgiHJqPhoPxa33GxvyV8Jc,8565
|
|
23
|
-
marlenv/wrappers/__init__.py,sha256=
|
|
23
|
+
marlenv/wrappers/__init__.py,sha256=uV00m0jysZBgOW-TvRekis-gsAKPeR51P3HsuRZKxG8,880
|
|
24
24
|
marlenv/wrappers/agent_id_wrapper.py,sha256=9qHV3LMQ4AjcDCSuvQhz5h9hUf7Xtrdi2sIxmNZk5NA,1126
|
|
25
25
|
marlenv/wrappers/available_actions_mask.py,sha256=OMyt2KntsR8JA2RuRgvwdzqzPe-_H-KKkbUUJfe_mks,1404
|
|
26
26
|
marlenv/wrappers/available_actions_wrapper.py,sha256=_HRl9zsjJgSrLgVuT-BjpnnfrfM8ic6wBUWlg67uCx4,926
|
|
@@ -30,10 +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/
|
|
33
|
+
marlenv/wrappers/potential_shaping.py,sha256=N4h0agFVxZZgCwMZTPFW64MGRFEYYFFVd9k4F27_MgQ,1520
|
|
34
|
+
marlenv/wrappers/rlenv_wrapper.py,sha256=S6G1VjFklTEzU6bj0AXrTDXnsTQJARq8VB4uUH6AXe4,2993
|
|
34
35
|
marlenv/wrappers/time_limit.py,sha256=GxbxcbfFyuVg14ylQU2C_cjmV9q4uDAt5wepfgX_PyM,3976
|
|
35
36
|
marlenv/wrappers/video_recorder.py,sha256=ucBQSNRPqDr-2mYxrTCqlrWcxSWtSJ7XlRC9-LdukBM,2535
|
|
36
|
-
multi_agent_rlenv-3.5.
|
|
37
|
-
multi_agent_rlenv-3.5.
|
|
38
|
-
multi_agent_rlenv-3.5.
|
|
39
|
-
multi_agent_rlenv-3.5.
|
|
37
|
+
multi_agent_rlenv-3.5.1.dist-info/METADATA,sha256=92aLf2gsXK8leco_rbbZzU-fLnIIgV3F6xdV1D3fP50,4897
|
|
38
|
+
multi_agent_rlenv-3.5.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
39
|
+
multi_agent_rlenv-3.5.1.dist-info/licenses/LICENSE,sha256=_eeiGVoIJ7kYt6l1zbIvSBQppTnw0mjnYk1lQ4FxEjE,1074
|
|
40
|
+
multi_agent_rlenv-3.5.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|