Skip to content

Commit

Permalink
Set max_steps as None by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
Junyoungpark committed Aug 30, 2023
1 parent 02dc606 commit 1cef082
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rl4co/models/nn/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ def random_policy(td):
return td


def rollout(env, td, policy, max_steps: int = 10_000):
def rollout(env, td, policy, max_steps: int = None):
"""Helper function to rollout a policy. Currently, TorchRL does not allow to step
over envs when done with `env.rollout()`. We need this because for environements that complete at different steps.
over envs when done with `env.rollout()`. We need this because for environments that complete at different steps.
"""

max_steps = float("inf") if max_steps is None else max_steps
actions = []
steps = 0

while not td["done"].all():
td = policy(td)
actions.append(td["action"])
Expand Down Expand Up @@ -96,7 +99,7 @@ def forward(
self,
td: TensorDict,
env: Union[str, RL4COEnvBase] = None,
max_steps: int = 10_000,
max_steps: int = None,
):
# Instantiate environment if needed
if isinstance(env, str) or env is None:
Expand Down

0 comments on commit 1cef082

Please sign in to comment.