Skip to content

Fix Lambert solver accuracy, convergence, and transfer direction - #1653

Merged
schaubh merged 9 commits into
developfrom
feature/bsk_1651_lambert
Oct 26, 2026
Merged

schaubh merged 9 commits into
developfrom
feature/bsk_1651_lambert

Conversation

@schaubh

@schaubh schaubh commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fix duplicate Gooding multi-revolution solutions and add explicit prograde/retrograde selection through the Lambert problem message and planner. Both algorithms now preserve distinct solution branches and handle coalesced roots at the minimum transfer time.

Additional fixes safeguard minimum-time and root searches, correct the intermediate Izzo starter, restore recovery after aligned inputs, and validate numeric inputs, configuration, and solver selections. Numerical failures return zeroed outputs with cleared validity flags; malformed inputs raise BasiliskError.

Nine focused commits separate the Gooding fix, transfer-direction support, convergence safeguards, Izzo starter correction, alignment recovery, input validation, solver-method validation, independent zero-revolution tests, and cross-platform CI fixes.

The final commit makes NaN validation safe when floating-point exceptions are enabled and fixes repeated Corrosion configuration by applying the patch to pristine source without rewriting unchanged output.

Reviewers should note these interface changes:

  • transferDirection defaults to PROGRADE in zero-initialized messages. C/C++ producers must initialize the new field.
  • solverMethod is now an integer validated before enum conversion. C++ callers reading it into SolverMethod must validate and explicitly cast it.
  • Difficult converged solutions can exceed the validator’s existing iteration limit; this behavior is documented.

Verification

Added regression coverage for both algorithms, solution branches, minimum-time boundaries, parabolic transfers, transfer directions, invalid inputs, recovery, and validator integration. Zero-revolution tests compare against independent orbit-derived velocities, with mutation tests confirming that incorrect outputs are detected.

Additional regressions cover NaN values in every position-vector component, floating-point exception flags, repeated Corrosion configuration, timestamp collisions, and detection of changed upstream patch targets.

Local validation passed:

  • 1,561 Lambert Python tests, completing in a few seconds.
  • 8 native Lambert tests and 2 Lambert scenarios.
  • A review sweep of 1,976 solves against known Keplerian orbits, with maximum endpoint velocity error approximately 9 × 10⁻⁸ m/s.
  • Targeted compilation, standalone header checks, and diff whitespace checks.

All eight CI checks passed for commit 18965b5c83, including Linux, Windows, macOS minimum and maximum Python configurations, latest dependencies, documentation, formatting, and pre-commit checks. The configured Python suites, native tests, and build-integration checks passed; skips in the macOS configuration with optional features disabled were expected.

Linux also passed incremental-build checks, Rust workspace and minimum-supported-toolchain tests, and Clippy with warnings treated as errors. The Linux and Windows runs confirmed both CI fixes.

Full build logs were reviewed. No new C/C++ compiler or linker warnings were found.

Documentation

Updated solver and planner documentation, message-field comments, release-note snippets, and known issues. These describe direction conventions, compatibility requirements, convergence and failure semantics, input validation, and alignment recovery.

Release-note snippets also describe the NaN-validation and Corrosion-reconfiguration fixes.

The documentation build completed successfully without Sphinx or Doxygen warnings.

Future work

Address the pre-existing macOS Rust debug-stripping warnings in a separate PR. These arise when rust-objcopy cannot load libLLVM.dylib; compilation, linking, and tests still succeed. They do not block the Lambert changes.

Correct both Gooding starters and use consistent minimum-time data.
Safeguard the minimum search with a derivative bracket, bisection fallback,
and finite/convergence checks. Handle coalesced roots explicitly.

Add independent root and orbit regressions, including lambda = -0.99,
and update module documentation, release notes, and known issues.

Validation: 733 C/C++, 97 Rust, and 12717 Python tests passed (1 skipped).
All 669 Lambert tests passed in 1.59 seconds (2.65 seconds with startup).
Allow Gooding and Izzo to solve retrograde transfers by selecting the orbit
normal and complementary transfer angle from LambertProblemMsgPayload's
transferDirection field. Preserve PROGRADE as the zero/default value and
expose the choice through LambertPlanner.setTransferDirection.

Reject unknown direction values and document the input-frame and polar
conventions. Add reported-orbit, multi-revolution, minimum-time, unbound,
polar, and planner-to-solver regression coverage, plus release and known
issue notes.

Validation: full build and documentation build passed; 733 C/C++, 97 Rust,
and 12793 Python tests passed (1 skipped). All 745 Lambert tests passed in
1.61 seconds, or 2.70 seconds including startup. Modified headers compile
in isolation, including the message payload as C.

Fixes #1652.
…utions

Bracket each root branch and require finite results, a small root step or
correction, and a small flight-time residual before publishing velocities.
Clear failed solution and performance slots independently on every update.

Preserve accurate starters and converged corrections, resume high-order
refinement after bisection, and evaluate near-parabolic flight times smoothly.
Document the convergence contract and validator iteration limit, with release
notes and known-issue updates.

Add regression coverage for numerical failure and recovery, independent branch
validity, near-minimum and parabolic transfers, iteration counts, and validator
acceptance. Validation: 1,023 Lambert Python tests, three native tests, both
Lambert scenarios, standalone header checks, and the documentation build pass.
…dling

Correct the logarithmic interpolation exponent in the C++ solver and Python
reference so intermediate zero-revolution starters stay between zero and one.
This reduces unnecessary refinements and prevents iteration-limit rejection
by the validator for affected transfers near the parabolic boundary.

Handle exact parabolic flight times analytically in the Python reference and
use a stable Newton step near that boundary, avoiding NaNs when a starter
rounds to one while retaining the actual flight-time residual.

Add interpolation, root accuracy, iteration-count, validator, and unmocked
parabolic-boundary regressions. Update module documentation, release notes,
and known issues.

Validation: 1,196 Lambert Python tests passed in 2.05 seconds (3.22 seconds
including startup), all three native Lambert tests passed, and documentation
built without warnings. Additional independent boundary probes passed.
Recompute the alignment rejection flag on every update so one aligned input
cannot permanently disable the solver. Return before normalizing a rejected
orbit normal while retaining cleared solution and performance outputs.

Add regressions that reuse one module and message without resets across
aligned and valid requests, covering both algorithms, transfer directions,
zero- and multi-revolution transfers, and alignment-threshold changes.
Update module documentation, release notes, and known issues.

Validation: 1,248 Lambert Python tests passed in 2.07 seconds (3.19 seconds
including startup), all three native tests and both Lambert scenarios passed,
and documentation built without warnings. Mixed-update recovery probes
matched fresh-module results.
Reject nonfinite or nonpositive time and gravity, unusable endpoint norms, and invalid alignment thresholds before solving. Preserve accepted configuration after rejected values and allow corrected requests to recover.

Use componentwise roundoff bounds to reject parallel and antiparallel endpoints before computing lambda or scaled flight time. Add Python and native regressions for validation, recovery, output clearing, and floating-point exceptions; update module documentation, release notes, and known issues.
Store LambertProblemMsgPayload.solverMethod as a raw integer and reject values other than IZZO or GOODING before converting to the internal enum or updating solver state. Preserve the Izzo default and recovery after corrected requests.

Add Python and native regressions for integer boundaries, message transport, default selection, and recovery with both methods. Document the C++ payload type change in the module guide, release notes, and known issues.
Preserve endpoint velocities derived from classical orbital elements instead of overwriting them with solver outputs. Wrap elliptic mean-anomaly differences forward to obtain the correct flight time across periapsis.

Add eight eccentric-orbit cases and sixteen corruption checks covering both endpoint velocities, both solvers, and all four conic cases. Document the analytical validation and its units while retaining fast single-step tests.
@schaubh schaubh self-assigned this Oct 26, 2026
@schaubh
schaubh requested a review from a team as a code owner October 26, 2026 02:17
@schaubh schaubh added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Oct 26, 2026
@schaubh schaubh added this to Basilisk Oct 26, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T02:20:00.203117Z 47f95ef PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Validate Lambert position components with std::isfinite to reject quiet
NaNs without raising FE_INVALID on x86. Extend native regression coverage
to every component of both endpoints.

Generate the Corrosion patch from pristine cached source on each
configuration, preserving unchanged output timestamps. Add regressions
for repeated configuration with matching timestamps.

Update module documentation, release notes, and known issues.

Validation: 1,561 Lambert Python tests, 8 native tests, 23 Rust build tests,
CMake target-query checks, isolated x86 checks, and documentation build.
@schaubh
schaubh merged commit ba98379 into develop Oct 26, 2026
8 checks passed
@schaubh
schaubh deleted the feature/bsk_1651_lambert branch October 26, 2026 17:03
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Basilisk Oct 26, 2026
@Noah-Parsons

Copy link
Copy Markdown
Contributor

Thank you for fixing both issues so quickly, and for including the starting-value change. I will re-run the full sweep against develop and post the results here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

Status: ✅ Done

2 participants