Skip to content

Add terminal constraint support to IPDDP#174

Merged
astomodynamics merged 11 commits into
masterfrom
feature/ipddp-terminal-constraints
Apr 10, 2026
Merged

Add terminal constraint support to IPDDP#174
astomodynamics merged 11 commits into
masterfrom
feature/ipddp-terminal-constraints

Conversation

@astomodynamics
Copy link
Copy Markdown
Owner

@astomodynamics astomodynamics commented Apr 5, 2026

Summary

Add terminal-constraint support to IPDDP, land the RC MPCC Python portfolio demo, and document the updated solver surface.

Changes

  • extend IPDDP to support TerminalEqualityConstraint and TerminalInequalityConstraint in the single-shooting interior-point solve path
  • preserve and repair warm-started interior-point state across repeated solves for path constraints, terminal inequalities, and terminal equalities
  • tighten filter, barrier, and dual-infeasibility bookkeeping for constrained IPDDP, including terminal-constraint residuals and optional state-stationarity reporting
  • reject unsupported terminal-constraint subclasses instead of silently dropping them from IPDDP
  • factor shared CDDP/interior-point helper logic into cddp_context_utils and interior_point_utils
  • add the RC MPCC Python portfolio demo plus gallery asset generation updates
  • update README and docs pages to describe the current IPDDP constraint coverage and the Python portfolio scope

Test Plan

  • python3 -m py_compile examples/python_portfolio_lib.py examples/ipddp_mpcc_rc.py
  • pytest -q python/tests/test_portfolio.py
  • cmake --build build --target test_ipddp_solver -j2
  • ./build/tests/test_ipddp_solver --gtest_filter='IPDDPTest.SolveWithTerminalInequalityOnly:IPDDPTest.ScaledDualInfeasibilityIncludesStateStationarityWhenEnabled:IPDDPTest.TracksInitialViolationForPathOnlyProblems:IPDDPTest.BarrierResetTracksThetaForPathOnlyProblems:IPDDPTest.WarmStartPreservesPathDualSlackState:IPDDPTest.WarmStartPreservesTerminalInequalityInteriorState:IPDDPTest.WarmStartPreservesTerminalEqualityMultiplierState:IPDDPTest.SolveWithTerminalEqualityOnly:IPDDPTest.SolveWithPathConstraintAndTerminalEquality:IPDDPTest.RejectsUnsupportedTerminalConstraintType:IPDDPTest.TerminalEqualityBackwardPassTracksStationarityResidual:IPDDPTest.TerminalEqualityBackwardPassUsesSecondOrderDynamicsWhenEnabled:IPDDPTest.SolveCar'

How to Test

  • create a CDDP problem and solve it with solve("IPDDP")
  • add path constraints with addPathConstraint(...)
  • add terminal constraints with addTerminalConstraint(...) using TerminalEqualityConstraint or TerminalInequalityConstraint
  • verify that warm-started solves preserve acceptable terminal/path infeasibility and converge to an acceptable status
  • regenerate the Python portfolio with python examples/python_portfolio.py --demo all --output-dir docs/assets/python_portfolio

Screenshots/Videos

  • Updated Python portfolio gallery asset: docs/assets/python_portfolio/mpcc_racing_line.gif

Additional Notes

  • review follow-up commits closed gaps in terminal-equality handling, warm-start preservation, filter bookkeeping, and the public docs
  • the Python portfolio remains animation-focused; terminal-constrained IPDDP coverage is exercised primarily in the regression suite rather than a separate gallery card

Move duplicated line-search, constraint bookkeeping, and filter logic into dedicated utility files used by the core and interior-point solvers.

Add a regression test covering stale warm-start trajectory dimensions so solve() rebuilds incompatible state and control trajectories before use.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c9242f2d9

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cddp_core/ipddp_solver.cpp Outdated
Comment thread src/cddp_core/ipddp_solver.cpp
Comment thread src/cddp_core/ipddp_solver.cpp Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the CDDP interior-point solver stack by adding terminal constraint support to IPDDP (terminal equalities + terminal inequalities) and refactors duplicated CDDP/interior-point utilities into shared helper modules.

Changes:

  • Add terminal equality/inequality constraint handling to IPDDPSolver, including new bookkeeping for residuals, filter metrics, merit evaluation, and step-size control.
  • Extract shared CDDP context utilities (line-search alphas, warm-start trajectory shaping, constraint add/remove) and shared interior-point filter/printing helpers.
  • Add regression tests for stale warm-start trajectory dimensions and terminal-inequality-only IPDDP solves, plus tighten an existing IPDDP regression assertion.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/cddp_core/ipddp_solver.cpp Major solver changes: terminal constraint support + refactor to shared interior-point helpers
include/cddp-cpp/cddp_core/ipddp_solver.hpp New solver state for terminal constraints, filter metrics, and forward-pass failure handling
include/cddp-cpp/cddp_core/options.hpp Expands IPDDP options surface (new knobs for filter/barrier/warmstart, etc.)
include/cddp-cpp/cddp_core/terminal_constraint.hpp Updates terminal constraint overrides to match indexed constraint interface
src/cddp_core/msipddp_solver.cpp Refactor to shared interior-point utils (filter, printing, max-violation)
src/cddp_core/interior_point_utils.hpp/.cpp New shared interior-point helper implementations
src/cddp_core/cddp_core.cpp Refactor duplicated logic to cddp_context_utils helpers
src/cddp_core/cddp_context_utils.hpp/.cpp New shared helpers for line-search alphas, trajectory shaping, and constraint bookkeeping
tests/cddp_core/test_ipddp_solver.cpp Adds terminal-inequality-only regression test + strengthens an existing SolveCar check
tests/cddp_core/test_cddp_core.cpp Adds regression test ensuring stale trajectory dimensions are repaired on solve
include/cddp-cpp/cddp.hpp Exposes terminal constraints via aggregate public header
CMakeLists.txt Adds new helper .cpp files to the core library sources

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cddp_core/ipddp_solver.cpp
Comment thread src/cddp_core/ipddp_solver.cpp Outdated
Comment thread src/cddp_core/ipddp_solver.cpp
Comment thread include/cddp-cpp/cddp_core/options.hpp
Comment thread src/cddp_core/ipddp_solver.cpp
Avoid dereferencing empty linearized dynamics arrays in the
zero-horizon rollout helper.

This keeps IPDDP initialization and helper paths safe when no
linearized stages are present.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cddp_core/ipddp_solver.cpp
Comment thread src/cddp_core/ipddp_solver.cpp Outdated
Comment thread src/cddp_core/ipddp_solver.cpp Outdated
Comment thread src/cddp_core/ipddp_solver.cpp Outdated
Comment thread tests/cddp_core/test_ipddp_solver.cpp
Comment thread tests/cddp_core/test_ipddp_solver.cpp Outdated
Move the racing-line MPCC implementation into a dedicated IPDDP example\nand keep the portfolio wrapper working for both top-level and package\nimports.\n\nGuard nonpositive step counts in the wrapper and CLI, refresh the\nportfolio GIF, and cover the new paths with regression tests.
Preserve warm-started path and terminal interior-point state.\nTrack the current path-only filter violation baseline with regressions.
Preserve terminal-equality warm-start state and mixed-constraint backward-pass behavior.\n\nAdd regressions for unsupported terminal constraints, stationarity reporting, and second-order dynamics in terminal-equality solves.
@astomodynamics astomodynamics added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request cleanup labels Apr 10, 2026
@astomodynamics astomodynamics merged commit bff6df9 into master Apr 10, 2026
8 checks passed
@astomodynamics astomodynamics deleted the feature/ipddp-terminal-constraints branch April 10, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants