Skip to content

[Wave RHO][2/4] Adapt solutions to new initial-guess grids - #1073

Draft
mickaelbegon wants to merge 3 commits into
pyomeca:masterfrom
mickaelbegon:codex/pr-solution-grid-warm-start
Draft

[Wave RHO][2/4] Adapt solutions to new initial-guess grids#1073
mickaelbegon wants to merge 3 commits into
pyomeca:masterfrom
mickaelbegon:codex/pr-solution-grid-warm-start

Conversation

@mickaelbegon

@mickaelbegon mickaelbegon commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Note

Wave RHO 2/4 — Draft/WIP. Tracking issue: #1086.

This wave and its decomposition come from an analysis performed by OpenAI Codex. Maintainer review is required before these proposals are considered ready.

Wave RHO context

The overall goal is to upstream generic, application-independent foundations for reliable receding-horizon workflows with IPOPT and Acados: solver-input correctness, supported warm-start grid transfer, explicit window outcomes/diagnostics/hooks, and finally supported solver tuning.

Proposed review/merge order:

  1. [Wave RHO][1/4] Fix Acados control-bound scaling and ordering #1075 — Acados control-bound correctness
  2. [Wave RHO][2/4] Adapt solutions to new initial-guess grids #1073 — solution-to-initial-guess grid adaptation
  3. [Wave RHO][3/4] Preserve receding-horizon outcomes and expose Acados diagnostics #1072 — RHO outcomes, hooks, cyclic shifts, diagnostics, and iterate access
  4. [Wave RHO][4/4] Expose supported advanced Acados options #1074 — advanced Acados options

Role of this PR: generic warm-start transfer foundation across shooting and collocation grids.

Interaction: Can be reviewed in parallel with #1075; its public grid-transfer path supports the workflow discussed in #1072.

All four PRs target master independently; this is an interaction/review order, not a stacked Git dependency.

What changed

  • add Solution.to_initial_guesses(...)
  • add public adapt_solution_to_initial_guesses(...)
  • resample states, controls and algebraic variables onto target shooting or collocation grids
  • transfer parameters without relying on InitialGuessList.values() or private attributes
  • preserve constant, linear, each-frame and all-points interpolation semantics

Why

Warm starts between windows or solvers need a supported way to adapt solutions when node counts and transcription grids differ.

Validation

  • pytest -q tests/shard4/test_solution_grid_adaptation.py
  • 2 passed

This change is Reviewable

@mickaelbegon mickaelbegon changed the title Adapt solutions to new initial-guess grids [HOLD] Adapt solutions to new initial-guess grids Jul 22, 2026
@mickaelbegon
mickaelbegon force-pushed the codex/pr-solution-grid-warm-start branch from 7a4d5cc to 8a881e2 Compare July 27, 2026 15:19
@mickaelbegon mickaelbegon changed the title [HOLD] Adapt solutions to new initial-guess grids [Wave RHO][2/4] Adapt solutions to new initial-guess grids Jul 27, 2026
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.89%. Comparing base (89c83a3) to head (238a50f).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
bioptim/optimization/solution/utils.py 81.25% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1073      +/-   ##
==========================================
+ Coverage   77.26%   77.89%   +0.63%     
==========================================
  Files         196      196              
  Lines       21506    21571      +65     
==========================================
+ Hits        16616    16803     +187     
+ Misses       4890     4768     -122     
Flag Coverage Δ
unittests 77.89% <82.35%> (+0.63%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pariterre pariterre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pariterre reviewed 4 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on mickaelbegon).


bioptim/optimization/solution/solution.py line 739 at r1 (raw file):

        return new

    def to_initial_guesses(

Is this used anywhere?


bioptim/optimization/solution/utils.py line 38 at r1 (raw file):

    if interpolation == InterpolationType.CONSTANT:
        return 1
    if interpolation == InterpolationType.CONSTANT_WITH_FIRST_AND_LAST_DIFFERENT:

elif, as they are mutually exclusive


bioptim/optimization/solution/utils.py line 63 at r1 (raw file):

            if key not in source_phases[phase]:
                raise KeyError(f"{group_name} '{key}' is absent from the solution phase {phase}")
            values = _resample_initial_guess(source_phases[phase][key], _target_column_count(target_guess))

Resampling as a linear interpolation won't work for certain InterpolationTypes. Check/raise should be done here

@mickaelbegon

Copy link
Copy Markdown
Contributor Author

@pariterre While working on cocofest (especially with Acados), I was obliged to warm-start problems in many ways...
Acados needs a good initial guess (interpolation, control interpolation + forwardDynamics, projection of phase I... ) and homotopy to converge. The idea would be to have tools to simplify warm starting.

Idea:
PR #1073 could be reshaped into a target-OCP-aware mesh-continuation utility that evaluates the source collocation polynomial on the target grid and optionally runs a lightweight phase-I projection to produce a dynamically consistent warm start.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants