Beispiel #1
0
    def test_run_hrl_td3(self):
        # Run the script; verify it executes without failure.
        args = parse_train_options(
            '',
            '',
            args=[
                "MountainCarContinuous-v0",
                "--initial_exploration_steps",
                "1",
                "--batch_size",
                "32",
                "--meta_period",
                "5",
                "--total_steps",
                "500",
                "--log_interval",
                "500",
            ],
            multiagent=False,
            hierarchical=True,
        )
        run_hrl(args, 'data/goal-conditioned')

        # Check that the folders were generated.
        self.assertTrue(
            os.path.isdir(
                os.path.join(
                    os.getcwd(),
                    "data/goal-conditioned/MountainCarContinuous-v0")))

        # Clear anything that was generated.
        shutil.rmtree(os.path.join(os.getcwd(), "data"))
Beispiel #2
0
    def test_run_multi_hrl_td3_shared(self):
        # Run the script; verify it executes without failure.
        args = parse_train_options(
            '',
            '',
            args=[
                "multiagent-ring-v0-fast",
                "--shared",
                "--initial_exploration_steps",
                "1",
                "--total_steps",
                "500",
                "--log_interval",
                "500",
            ],
            multiagent=True,
            hierarchical=True,
        )
        run_multi_hrl(args, 'data/multi-goal-conditioned')

        # Check that the folders were generated.
        self.assertTrue(
            os.path.isdir(
                os.path.join(
                    os.getcwd(),
                    "data/multi-goal-conditioned/multiagent-ring-v0-fast")))

        # Clear anything that was generated.
        shutil.rmtree(os.path.join(os.getcwd(), "data"))
Beispiel #3
0
    def test_run_multi_fcnet_td3_maddpg_independent(self):
        # Run the script; verify it executes without failure.
        args = parse_train_options(
            '',
            '',
            args=[
                "multiagent-ring-v0",
                "--maddpg",
                "--initial_exploration_steps",
                "1",
                "--total_steps",
                "500",
                "--log_interval",
                "500",
            ],
            multiagent=True,
            hierarchical=False,
        )
        run_multi_fcnet(args, 'data/multi-fcnet')

        # Check that the folders were generated.
        self.assertTrue(
            os.path.isdir(
                os.path.join(os.getcwd(),
                             "data/multi-fcnet/multiagent-ring-v0")))

        # Clear anything that was generated.
        shutil.rmtree(os.path.join(os.getcwd(), "data"))
Beispiel #4
0
    def test_run_fcent_td3(self):
        # Run the script; verify it executes without failure.
        args = parse_train_options(
            '',
            '',
            args=[
                "MountainCarContinuous-v0",
                "--initial_exploration_steps",
                "1",
                "--total_steps",
                "500",
                "--log_interval",
                "500",
                "--num_envs",
                "2",  # to test RaySampler
                "--nb_rollout_steps",
                "2",
            ],
            multiagent=False,
            hierarchical=False,
        )
        run_fcnet(args, 'data/fcnet')

        # Check that the folders were generated.
        self.assertTrue(
            os.path.isdir(
                os.path.join(os.getcwd(),
                             "data/fcnet/MountainCarContinuous-v0")))

        # Clear anything that was generated.
        ray.shutdown()
        shutil.rmtree(os.path.join(os.getcwd(), "data"))
Beispiel #5
0
    def test_run_multi_fcnet_failure_maddpg_shared(self):
        # Run the script; verify it executes without failure.
        args = parse_train_options(
            '',
            '',
            args=[
                "MountainCarContinuous-v0", "--shared", "--maddpg",
                "--initial_exploration_steps", "1", "--total_steps", "500",
                "--log_interval", "500", "--alg", "woops"
            ])

        self.assertRaises(ValueError,
                          run_multi_fcnet,
                          args=args,
                          base_dir='data/multi-fcnet')

        # Clear anything that was generated.
        shutil.rmtree(os.path.join(os.getcwd(), "data"))
Beispiel #6
0
    def test_run_hrl_failure(self):
        # Run the script; verify it executes without failure.
        args = parse_train_options(
            '',
            '',
            args=[
                "MountainCarContinuous-v0", "--initial_exploration_steps", "1",
                "--batch_size", "32", "--meta_period", "5", "--total_steps",
                "500", "--log_interval", "500", "--alg", "woops"
            ])

        self.assertRaises(ValueError,
                          run_hrl,
                          args=args,
                          base_dir='data/goal-conditioned')

        # Clear anything that was generated.
        shutil.rmtree(os.path.join(os.getcwd(), "data"))
Beispiel #7
0
    def test_run_multi_hrl_failure_independent(self):
        # Run the script; verify it executes without failure.
        args = parse_train_options('',
                                   '',
                                   args=[
                                       "multiagent-ring_small",
                                       "--initial_exploration_steps", "1",
                                       "--total_steps", "500",
                                       "--log_interval", "500", "--alg",
                                       "woops"
                                   ])

        self.assertRaises(ValueError,
                          run_multi_hrl,
                          args=args,
                          base_dir='data/multi-goal-conditioned')

        # Clear anything that was generated.
        shutil.rmtree(os.path.join(os.getcwd(), "data"))
Beispiel #8
0
    def test_run_fcent_failure(self):
        # Run the script; verify it fails.
        args = parse_train_options(
            '',
            '',
            args=[
                "MountainCarContinuous-v0", "--initial_exploration_steps", "1",
                "--total_steps", "500", "--log_interval", "500", "--alg",
                "woops"
            ],
            multiagent=False,
            hierarchical=False,
        )
        self.assertRaises(ValueError,
                          run_fcnet,
                          args=args,
                          base_dir='data/fcnet')

        # Clear anything that was generated.
        shutil.rmtree(os.path.join(os.getcwd(), "data"))
Beispiel #9
0
    def test_run_multi_fcnet_sac_shared(self):
        # Run the script; verify it executes without failure.
        args = parse_train_options('',
                                   '',
                                   args=[
                                       "multiagent-ring_small", "--shared",
                                       "--initial_exploration_steps", "1",
                                       "--total_steps", "500",
                                       "--log_interval", "500", "--alg", "SAC"
                                   ])
        run_multi_fcnet(args, 'data/multi-fcnet')

        # Check that the folders were generated.
        self.assertTrue(
            os.path.isdir(
                os.path.join(os.getcwd(),
                             "data/multi-fcnet/multiagent-ring_small")))

        # Clear anything that was generated.
        shutil.rmtree(os.path.join(os.getcwd(), "data"))
Beispiel #10
0
    def test_run_fcent_sac(self):
        # Run the script; verify it executes without failure.
        args = parse_train_options('',
                                   '',
                                   args=[
                                       "MountainCarContinuous-v0",
                                       "--initial_exploration_steps", "1",
                                       "--total_steps", "500",
                                       "--log_interval", "500", "--alg", "SAC"
                                   ])
        run_fcnet(args, 'data/fcnet')

        # Check that the folders were generated.
        self.assertTrue(
            os.path.isdir(
                os.path.join(os.getcwd(),
                             "data/fcnet/MountainCarContinuous-v0")))

        # Clear anything that was generated.
        shutil.rmtree(os.path.join(os.getcwd(), "data"))
Beispiel #11
0
    def test_run_multi_fcnet_failure_maddpg_independent(self):
        # Run the script; verify it executes without failure.
        args = parse_train_options(
            '',
            '',
            args=[
                "multiagent-ring-v0", "--maddpg",
                "--initial_exploration_steps", "1", "--total_steps", "500",
                "--log_interval", "500", "--alg", "woops"
            ],
            multiagent=True,
            hierarchical=False,
        )

        self.assertRaises(ValueError,
                          run_multi_fcnet,
                          args=args,
                          base_dir='data/multi-fcnet')

        # Clear anything that was generated.
        shutil.rmtree(os.path.join(os.getcwd(), "data"))