Repository navigation
Add HomotopyPolyAlgorithm: staged polyalgorithm for HomotopyProblem - #1019
Merged
ChrisRackauckas merged 2 commits intoJul 10, 2026
Merged
Conversation
A polyalgorithm for SciMLBase.HomotopyProblem that tries a tuple of
continuation algorithms in order and returns the first solution with a
successful retcode; if every stage fails, the LAST stage's failed
solution is returned (its retcode/original describe the most robust
attempt). The zero-argument default is
HomotopyPolyAlgorithm((HomotopySweep(), ArcLengthContinuation()))
encoding the natural escalation: the natural-parameter sweep is the
cheap first attempt but cannot reverse lambda and therefore cannot
follow a branch around a fold; pseudo-arclength continuation tracks the
curve in the augmented (u, lambda) space and rounds folds at the higher
cost of an (n+1)-dimensional corrector per step.
The existing default routing is unchanged: solve(prob, nothing) still
selects HomotopySweep(). The polyalgorithm is opt-in; switching the
default is left as a separate maintainer decision.
Tests cover construction/defaults, the happy path (with a residual
evaluation counter proving the arclength stage never runs when the
sweep succeeds), the fallback path on the S-fold u^3 - 3u = -3 + 6*lam
(calibrated with maxiters = 10 because an unbounded SimpleNewtonRaphson
path-jumps across the fold and the sweep falsely succeeds), the
both-stages-fail path on (1-lam)*u + lam*(u^2+1) (no real root at
lam = 1), a zero-width lambda span, and Float32 eltype preservation.
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Chris Rackauckas <[email protected]>
Per maintainer decision: `solve(prob::HomotopyProblem)` and `solve(prob, nothing)` now route to `HomotopyPolyAlgorithm()` (sweep first, pseudo-arclength fallback) instead of a bare `HomotopySweep()`. Problems the sweep alone cannot finish (fold-blocked paths) now succeed under the default when the arclength stage can round the fold; the happy path is unchanged (the sweep still runs first and its success short-circuits the fallback). Verified locally (Julia 1.11): full homotopy battery — 21 homotopy_sweep items, 6 arclength items, and the polyalg tests — passes 185/185 with the new default routing. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
Member
Author
|
Per maintainer decision, the default routing is now included in this PR: |
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.
Note
This PR should be ignored until reviewed by @ChrisRackauckas.
Summary
Adds
HomotopyPolyAlgorithmto NonlinearSolveBase: a polyalgorithm forSciMLBase.HomotopyProblemthat tries a tuple of continuation algorithms in order and returns the first solution with a successful retcode. If every stage fails, the last stage's failed solution is returned (itsretcode/originaldescribe the most robust attempt).The zero-argument default encodes the natural escalation for homotopy solves:
HomotopySweepis the cheap first attempt — natural-parameter continuation marches λ monotonically and reuses one inner-solver cache across the whole sweep, but it cannot reverse λ and therefore cannot follow a branch around a fold (turning point).ArcLengthContinuationis the robust fallback — it tracks the curve by pseudo-arclength in the augmented(u, λ)space, so λ is free to decrease and folds that defeat the sweep are rounded, at the higher cost of an(n+1)-dimensional corrector per step.Design
lib/NonlinearSolveBase/src/homotopy_polyalg.jl, modeled loosely onNonlinearSolvePolyAlgorithm(polyalg.jl): a@concrete struct HomotopyPolyAlgorithm <: AbstractNonlinearSolveAlgorithmholdingalgs <: Tuple, plus the zero-argument default constructor. Deliberately kept simple: no cache/init!machinery —CommonSolve.solve(prob::SciMLBase.HomotopyProblem, alg::HomotopyPolyAlgorithm, args...; kwargs...)loops the stages and forwardsargs...; kwargs...to each.@docsblock indocs/src/native/solvers.mdunder "Homotopy / Continuation Solvers".solve(prob::HomotopyProblem, ::Nothing)still selectsHomotopySweep(). The polyalgorithm is opt-in. Whether the default should becomeHomotopyPolyAlgorithm()is left as a separate decision for the maintainer — it would make default homotopy solves strictly more robust, but adds the arclength attempt's cost to every currently-failing sweep and changes whichretcode/ufailing solves report.Tests
New
test/Core/homotopy_polyalg_tests__item1.jl(registered intest/runtests.jlin the core group), covering:algs[1] isa HomotopySweep,algs[2] isa ArcLengthContinuation) and a custom stage tuple.Refresidual-evaluation counter proving the arclength stage never ran (the polyalg's evaluation count exactly equals a plainHomotopySweep()solve's count: 150 == 150 observed).u³ - 3u = -3 + 6λ(turning points at λ = 5/6 and 1/6): stage 1 fails, stage 2 rounds both folds and lands on the connected upper-sheet rootu ≈ +2.1038034with target residual < 1e-6.(1-λ)u + λ(u²+1)(no real root at λ = 1):!successful_retcode, finiteu, andsol.alg isa ArcLengthContinuation(the last stage's solution).Empirical calibration note (path jumping)
The fallback test needed calibration: with
inner = SimpleNewtonRaphson()and unbounded iterations,HomotopySweeppath-jumps on the S-fold — Newton on the cubic, warm-started from near the fold atu = -1, eventually reaches the far root on the upper sheet, so the sweep reportsSuccessatu ≈ +2.1038rather than failing. The test therefore passesmaxiters = 10through the solve kwargs: a budget that comfortably suffices for on-path warm-started corrector steps but not for the wild excursion of a jump. Observed on amaxitersscan of 2–10: the sweep fails withMaxItersat every value (stalling atu ≈ -1.13, next to the fold atu = -1) whileArcLengthContinuationsucceeds at every value with target residual ~1e-15.What was run locally
@safetestsetincludes on Julia 1.11: all 21homotopy_sweep_tests__item*.jl, all 6arclength_tests__item*.jl, and the newhomotopy_polyalg_tests__item1.jl— 185 Pass, 185 Total, 0 failures (Test Summary:homotopy battery | Pass 185 Total 185, ~4m50s; run twice, the second time on the exact Runic-formatted code being committed).Runic.main(["--check", ...])exits 0 on every touched file.🤖 Generated with Claude Code