-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RLlib] MADDPG: Move into main algorithms
folder and add proper unit and learning tests.
#24579
Merged
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6483bde
wip.
sven1977 e1000ff
wip.
sven1977 da80644
Merge branch 'master' of https://github.com/ray-project/ray into madd…
sven1977 3183f7e
Merge branch 'master' of https://github.com/ray-project/ray into madd…
sven1977 f5f2693
wip.
sven1977 ea77996
Merge branch 'master' of https://github.com/ray-project/ray into madd…
sven1977 e489bbc
Merge branch 'master' of https://github.com/ray-project/ray into madd…
sven1977 0224cf3
wip
sven1977 1eab03a
Merge branch 'master' of https://github.com/ray-project/ray into madd…
sven1977 f06f28e
wip
sven1977 f9b7480
Merge branch 'master' of https://github.com/ray-project/ray into madd…
sven1977 6446e51
wip
sven1977 ca4d93e
wip
sven1977 6c86ce7
wip.
sven1977 42de26f
Merge branch 'master' of https://github.com/ray-project/ray into madd…
sven1977 0b21d2d
wip.
sven1977 af64d24
Merge branch 'master' of https://github.com/ray-project/ray into madd…
sven1977 4fbf42e
wip.
sven1977 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
from ray.rllib.agents.maddpg.maddpg import MADDPGTrainer, DEFAULT_CONFIG | ||
from ray.rllib.algorithms.maddpg.maddpg import ( | ||
MADDPGTrainer, | ||
MADDPGTFPolicy, | ||
DEFAULT_CONFIG, | ||
) | ||
|
||
__all__ = ["MADDPGTrainer", "DEFAULT_CONFIG"] | ||
__all__ = [ | ||
"MADDPGTrainer", | ||
"MADDPGTFPolicy", | ||
"DEFAULT_CONFIG", | ||
] | ||
|
||
from ray.rllib.utils.deprecation import deprecation_warning | ||
|
||
deprecation_warning( | ||
"ray.rllib.agents.maddpg", | ||
"ray.rllib.algorithms.maddpg", | ||
error=False, | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from ray.rllib.agents.maddpg.maddpg import MADDPGTrainer, DEFAULT_CONFIG | ||
|
||
__all__ = ["MADDPGTrainer", "DEFAULT_CONFIG"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import unittest | ||
|
||
import ray | ||
import ray.rllib.agents.maddpg as maddpg | ||
from ray.rllib.examples.env.two_step_game import TwoStepGame | ||
from ray.rllib.policy.policy import PolicySpec | ||
from ray.rllib.utils.test_utils import ( | ||
check_train_results, | ||
framework_iterator, | ||
) | ||
|
||
|
||
class TestMADDPG(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls) -> None: | ||
ray.init() | ||
|
||
@classmethod | ||
def tearDownClass(cls) -> None: | ||
ray.shutdown() | ||
|
||
def test_maddpg_compilation(self): | ||
"""Test whether an MADDPGTrainer can be built with all frameworks.""" | ||
config = maddpg.DEFAULT_CONFIG.copy() | ||
config["env"] = TwoStepGame | ||
config["env_config"] = { | ||
"actions_are_logits": True, | ||
} | ||
config["multiagent"] = { | ||
"policies": { | ||
"pol1": PolicySpec( | ||
config={"agent_id": 0}, | ||
), | ||
"pol2": PolicySpec( | ||
config={"agent_id": 1}, | ||
), | ||
}, | ||
"policy_mapping_fn": (lambda aid, **kwargs: "pol2" if aid else "pol1"), | ||
} | ||
|
||
num_iterations = 1 | ||
|
||
# Only working for tf right now. | ||
for _ in framework_iterator(config, frameworks="tf"): | ||
trainer = maddpg.MADDPGTrainer(config) | ||
for i in range(num_iterations): | ||
results = trainer.train() | ||
check_train_results(results) | ||
print(results) | ||
trainer.stop() | ||
|
||
|
||
if __name__ == "__main__": | ||
import pytest | ||
import sys | ||
|
||
sys.exit(pytest.main(["-v", __file__])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we maybe instead add this to the weekly ci -- I feel like we don't need to as widely support this algorithm until there is a customer use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question: I think we should move toward:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave this test here for now to roughly match the other algos' coverage (everyone has CartPole/Pendulum tests in the CI, which is ok).