Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Closes #XXX
Adds
examples/dqn_training.ipynb. It trains a DQN agent on a BSK-RL environment in plain PyTorch through the standard Gymnasium API, with no RL library. All existing training examples use RLlib PPO, so this is the first example of a value-based, off-policy method, and the first that trains a BSK-RL env with a hand-written loop.The key point is the time-discounted TD target for BSK-RL's semi-MDP steps:
d_tscomes frominfo["d_ts"]andgammais per second. This matches the convention inTimeDiscountedGAEPPOTorchLearnerand the time-discounted GAE example.Changes
examples/dqn_training.ipynb: new examplerllib_training, so the two can be compared directlyinfo["d_ts"]for each actiond_ts, and a DQN agent (Huber loss, gradient clipping, Polyak target updates, 4 gradient updates per environment step)examples/_default.rst: adds the example under Trainingdocs/source/release_notes.rst: release note entryNo new dependencies: uses
torch(in therllibextra, which the docs CI already installs) andmatplotlib(pulled in bybsk).Type of change
How should this pull request be reviewed?
How Has This Been Tested?
Executed the notebook end to end with
jupyter nbconvert --execute. It runs in about 10.5 minutes on a 2-vCPU Linux machine. Output: DQN greedy return +0.203 with 10% failures, vs random −0.200 with 50% failures.Checked robustness across seeds with the same hyperparameters (20k steps, 10 held-out evaluation episodes each):
Earlier settings were less reliable across seeds: 1 update per step, higher learning rate, larger per-second
gamma, and Double DQN. That's why the example uses 4 updates per step withlr=2.5e-4.Caveat: my test environment couldn't download
de430.bsp, so these runs used DE421 as a local stand-in for the planetary ephemeris. With the real file, the exact numbers may differ slightly.ruff check,black --checkandisort --checkpass on the notebook.No library code changed, so no unit or integration tests were added. The docs build executes the notebook, which covers it.
Future Work