-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update TrajectoryRunner with its docs and test
- Loading branch information
1 parent
78afd12
commit 6884940
Showing
6 changed files
with
207 additions
and
133 deletions.
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
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,37 @@ | ||
from lagom.envs.vec_env import VecEnv | ||
|
||
|
||
class BaseRunner(object): | ||
r"""Base class for all runners. | ||
Any runner should subclass this class. | ||
A runner is a data collection interface between the agent and the environment. | ||
For each calling of the runner, the agent will take actions and receive observation | ||
in and from an environment for a certain number of trajectories/segments and a certain | ||
number of time steps. | ||
.. note:: | ||
By default, the agent handles batched data returned from :class:`VecEnv` type of environment. | ||
And the collected data should use either :class:`Trajectory` or :class:`Segment`. | ||
""" | ||
def __init__(self, agent, env, gamma): | ||
r"""Initialize the runner. | ||
Args: | ||
agent (BaseAgent): agent | ||
env (VecEnv): VecEnv type of environment | ||
gamma (float): discount factor | ||
""" | ||
assert isinstance(env, VecEnv), f'expected VecEnv, got {type(env)}' | ||
|
||
self.agent = agent | ||
self.env = env | ||
self.gamma = gamma | ||
|
||
def __call__(self, N, T): | ||
r"""Run the agent in the environment and collect all necessary interaction data as a batch. """ | ||
raise NotImplementedError | ||
|
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
Oops, something went wrong.