BUG: make every step_simulation call advance the flight - #26
Merged
Conversation
A call that landed on a phase boundary advanced the phase index, left the new phase uninitialised and returned, so it moved neither t nor y_sol. A caller counting one step per call, which is what the Balloon Popping Challenge environment does, then ran ahead of the flight's own clock. The phase transition now carries on into the new phase in the same call, so the only path that returns without advancing is the one that has just set finished, and by then there is nothing left to advance. Measured on flight_calisto: 5 calls with 2 that did not advance, against 3 calls with none. Final t is 48.4363 either way, so the same flight is being walked in fewer calls rather than a different one. Ignoring whitespace the change is a while loop and a continue; the rest of the diff is the indentation that loop adds. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
zuorenchen
approved these changes
Aug 2, 2026
Member
|
Thanks for the fix |
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.
Closes #20, taking the direction you described there.
The change
The phase transition set
phase_index += 1, marked the phase uninitialised and returned, so that call moved neithertnory_sol. It now carries on into the new phase in the same call, so the only path that returns without advancing is the one that has just setfinished, which you said was fine to leave.Ignoring whitespace it is a
whileloop and acontinue. The rest of the diff is the indentation that loop adds, sogit diff -wis the readable version.Measured
On
flight_calisto:tSame flight, fewer calls. The existing
test_stepped_trajectory_matches_simulatecompares the whole solution againstsimulate()atrtol=1e-8and still passes, so the nodes being walked are the same ones.What it does to the Challenge
A caller that counts one step per call records one fewer step, since the transition no longer costs one. Checked rather than assumed, on scenario 0 with the shipped example agent:
flight.tScenario 1 is 5964 to 5963, also with the score unchanged.
The step that goes is a degenerate one. The last three recorded rocket positions are identical,
(45.155, -0.048, 20.0), because the rocket has landed, so the sweep that disappears has zero length and cannot reach a balloon the previous sweep did not.The Challenge's golden masters pass. Its step-count check allows an absolute two steps of drift, which is deliberate and documented there, and the whole suite is green at 557 passed.
Things I went looking for afterwards
The loop terminates.
continueis only reached afterphase_index += 1, and the bound islen(self.flight_phases) - 1, so it is strictly increasing towards an exit. Phases can be added during a flight, but only from__simulateand from the parachute triggers that are not migrated into the stepping path, and neither is reachable from thecontinuebranch, which runs no node. Checked with the apogee and non-apogee cases as well.No mid-flight call is affected. On both shipped Challenge scenarios the calls that did not advance are the last two and nothing earlier:
So an agent sees the same observations for the whole flight, and only the two calls after landing change.
Nothing else in the file moved. Comparing the two
flight.pyat the AST level, the only function that differs isstep_simulation, and the difference is oneWhile, oneContinueand theTrueconstant.ruff formattouched the indentation and no logic.Submissions made before this still verify after it. A file packed against the current
developand checked by a copy of the Challenge running this branch passes all nineteen checks, with the balloon trajectories matching to0.000e+00 mover 6012 steps. Worth knowing because the leaderboard already holds submissions made against the old behaviour.Tests
Three added, and the one that matters fails on the obvious mutation:
test_no_call_returns_without_advancingThe other two are controls: that more than one phase is still visited, so returning early on every call would not pass, and that the flight still ends where
simulate()ends, so absorbing the transition does not skip the node it was standing on.Local run of CI:
ruff check,ruff format --check,pylint rocketpy/ tests/ docs/exiting 0, and 149 unit plus 152 integration tests passing.