# Buggy code
def debug_string(self):
    """This provides a progress notification for the algorithm.

    For each bracket, the algorithm will output a string as follows:

        Bracket(Max Size (n)=5, Milestone (r)=33, completed=14.6%):
        {PENDING: 2, RUNNING: 3, TERMINATED: 2}

    "Max Size" indicates the max number of pending/running experiments
    set according to the Hyperband algorithm.

    "Milestone" indicates the iterations a trial will run for before
    the next halving will occur.

    "Completed" indicates an approximate progress metric. Some brackets,
    like ones that are unfilled, will not reach 100%.
    """
    out = "Using HyperBand: "
    out += "num_stopped={} total_brackets={}".format(
        self._num_stopped, sum(len(band) for band in self._hyperbands)
    )
    for i, band in enumerate(self._hyperbands):
        out += "\nRound #{}:".format(i)
        for bracket in band:
            out += "\n  {}".format(bracket)
    return out


# Traceback (ray.tune.error.TuneError)
== Status ==
Memory usage on this node: 7.0/15.6 GiB
Using HyperBand: num_stopped=832 total_brackets=3
Round #0:
None
Bracket(Max Size (n)=2, Milestone (r)=1458, completed=100.0%): {RUNNING: 1, TERMINATED: 833}
Bracket(Max Size (n)=324, Milestone (r)=8, completed=47.3%): {PAUSED: 166}
Resources requested: 4/32 CPUs, 0/0 GPUs, 0.0/8.69 GiB heap, 0.0/2.98 GiB objects
Result logdir: /home/dl-user/ray_results/MCv0_DQN_BOHB
Number of trials: 1000 (166 PAUSED, 1 RUNNING, 833 TERMINATED)
+-----------------------------+------------+----------------------+-------------------+-------------+--------------------+--------+------------------+--------+----------+
| Trial name                  | status     | loc                  | batch_mode        |          lr |   train_batch_size |   iter |   total time (s) |     ts |   reward |
|-----------------------------+------------+----------------------+-------------------+-------------+--------------------+--------+------------------+--------+----------|
| DQN_MountainCar-v0_0428be42 | PAUSED     |                      | truncate_episodes | 1.99095e-05 |                408 |      2 |         25.6885  |   4032 |  -200    |
| DQN_MountainCar-v0_0428be45 | PAUSED     |                      | truncate_episodes | 0.000382289 |                211 |      2 |         24.7536  |   5040 |  -200    |
| DQN_MountainCar-v0_0428be48 | PAUSED     |                      | truncate_episodes | 0.000324929 |                233 |      2 |         25.5532  |   5040 |  -200    |
| DQN_MountainCar-v0_0747e5f2 | PAUSED     |                      | truncate_episodes | 0.000114766 |                 38 |      2 |         23.8492  |   7056 |  -200    |
| DQN_MountainCar-v0_0747e5f5 | PAUSED     |                      | truncate_episodes | 9.1226e-05  |                200 |      2 |         24.2349  |   5040 |  -200    |
| DQN_MountainCar-v0_08218bf0 | PAUSED     |                      | truncate_episodes | 0.000284028 |                 69 |      2 |         25.3671  |   7056 |  -200    |
| DQN_MountainCar-v0_093c0b8c | PAUSED     |                      | truncate_episodes | 0.00237606  |                114 |      2 |         23.3935  |   6048 |  -200    |
| DQN_MountainCar-v0_0a55eae6 | PAUSED     |                      | truncate_episodes | 0.000417829 |                111 |      2 |         23.4849  |   6048 |  -200    |
| DQN_MountainCar-v0_0b307d56 | PAUSED     |                      | truncate_episodes | 0.000196047 |                 59 |      2 |         23.1338  |   7056 |  -200    |
| DQN_MountainCar-v0_0eedea91 | PAUSED     |                      | truncate_episodes | 6.58278e-05 |                 59 |      2 |         24.0254  |   7056 |  -200    |
| DQN_MountainCar-v0_1fcd888b | RUNNING    | 172.16.160.219:47910 | truncate_episodes | 0.000237864 |                751 |     88 |       1638.34    | 199584 |  -122.05 |
| DQN_MountainCar-v0_0023f4f6 | TERMINATED |                      | truncate_episodes | 0.000255833 |                158 |      1 |          5.56779 |   1008 |  -200    |
| DQN_MountainCar-v0_0023f4f9 | TERMINATED |                      | complete_episodes | 0.000262904 |                156 |      1 |          5.43817 |   1200 |  -200    |
| DQN_MountainCar-v0_0023f4fc | TERMINATED |                      | complete_episodes | 0.0002605   |                260 |      1 |          5.33452 |   1200 |  -200    |
| DQN_MountainCar-v0_0108428e | TERMINATED |                      | truncate_episodes | 3.89327e-05 |                732 |      4 |         36.2218  |   5040 |  -200    |
| DQN_MountainCar-v0_01084291 | TERMINATED |                      | truncate_episodes | 2.39745e-05 |                714 |      4 |         36.2585  |   5040 |  -200    |
| DQN_MountainCar-v0_01084294 | TERMINATED |                      | truncate_episodes | 4.9252e-05  |                808 |      4 |         38.4182  |   5040 |  -200    |
| DQN_MountainCar-v0_01084297 | TERMINATED |                      | truncate_episodes | 7.42384e-05 |                804 |      4 |         38.0425  |   5040 |  -200    |
| DQN_MountainCar-v0_014223c0 | TERMINATED |                      | truncate_episodes | 0.0520328   |                 71 |      1 |          6.21906 |   1008 |  -200    |
| DQN_MountainCar-v0_01939ac4 | TERMINATED |                      | complete_episodes | 8.34678e-05 |                124 |      1 |          5.37302 |   1200 |  -200    |
| DQN_MountainCar-v0_01a4cc45 | TERMINATED |                      | complete_episodes | 0.00973094  |                373 |      3 |         27.2147  |  24000 |  -200    |
+-----------------------------+------------+----------------------+-------------------+-------------+--------------------+--------+------------------+--------+----------+
... 980 more trials not shown (156 PAUSED, 823 TERMINATED)


Traceback (most recent call last):
File "/home/dl-user/python-code/modularized_version_ray/ray_BOHB.py", line 123, in <module>
verbose=1,
File "/home/dl-user/.local/lib/python3.7/site-packages/ray/tune/tune.py", line 327, in run
runner.step()
File "/home/dl-user/.local/lib/python3.7/site-packages/ray/tune/trial_runner.py", line 342, in step
self.trial_executor.on_no_available_trials(self)
File "/home/dl-user/.local/lib/python3.7/site-packages/ray/tune/trial_executor.py", line 177, in on_no_available_trials
raise TuneError("There are paused trials, but no more pending "
ray.tune.error.TuneError: There are paused trials, but no more pending trials with sufficient resources.

Process finished with exit code 1

# Fixed code
def debug_string(self):
    """This provides a progress notification for the algorithm.

    For each bracket, the algorithm will output a string as follows:

        Bracket(Max Size (n)=5, Milestone (r)=33, completed=14.6%):
        {PENDING: 2, RUNNING: 3, TERMINATED: 2}

    "Max Size" indicates the max number of pending/running experiments
    set according to the Hyperband algorithm.

    "Milestone" indicates the iterations a trial will run for before
    the next halving will occur.

    "Completed" indicates an approximate progress metric. Some brackets,
    like ones that are unfilled, will not reach 100%.
    """
    out = "Using HyperBand: "
    out += "num_stopped={} total_brackets={}".format(
        self._num_stopped, sum(len(band) for band in self._hyperbands)
    )
    for i, band in enumerate(self._hyperbands):
        out += "\nRound #{}:".format(i)
        for bracket in band:
            if bracket:
                out += "\n  {}".format(bracket)
    return out