ModelingToolkit.jl icon indicating copy to clipboard operation
ModelingToolkit.jl copied to clipboard

feat: initial implementation of HomotopyContinuation interface

Open AayushSabharwal opened this issue 1 year ago • 10 comments

julia> @variables x y z
julia> eqs = [
           0 ~ x^2 + y^2 + 2x*y
           0 ~ x^2 + 4x + 4
           0 ~ y * z + 4x^2
       ]
julia> @mtkbuild sys = NonlinearSystem(eqs)
julia> prob = MTK.HomotopyContinuationProblem(sys, [x => 1.0, y => 1.0, z => 1.0], [])
julia> sol = HomotopyContinuation.solve(prob.hcsys; threading = false)

Checklist

  • [ ] Appropriate tests were added
  • [ ] Any code changes were done in a way that does not break public API
  • [ ] All documentation related to code changes were updated
  • [ ] The new code follows the contributor guidelines, in particular the SciML Style Guide and COLPRAC.
  • [ ] Any new documentation only uses public API

Additional context

Add any other context about the problem here.

AayushSabharwal avatar Oct 12 '24 08:10 AayushSabharwal

I think most of what's left now is documentation. It would also be nice to not require symbolic jacobians. I want to integrate that with ADTypes and DifferentationInterface, since they're "free" dependencies. ADTypes is pulled in via DI, and DI is pulled in via DiffEqCallbacks and NonlinearSolve, both of which are dependencies of MTK.

AayushSabharwal avatar Oct 12 '24 14:10 AayushSabharwal

Leave any Jac change for a future PR. Contain the scope a bit here.

ChrisRackauckas avatar Oct 12 '24 15:10 ChrisRackauckas

One thing that Catalyst does that might be nice is to also support rational functions by converting them into polynomial systems. I think @TorkelE set this up with @shashi at some point via a mix of stuff in Catalyst and Symbolics.

isaacsas avatar Oct 12 '24 15:10 isaacsas

Could you point to what transformation you're referring to regarding rational functions?

AayushSabharwal avatar Oct 12 '24 15:10 AayushSabharwal

You can always multiply through by the denominators to make the system polynomial.

If you look at the Catalyst extension you can see what @TorkelE did.

https://github.com/SciML/Catalyst.jl/blob/master/ext/CatalystHomotopyContinuationExtension/homotopy_continuation_extension.jl

isaacsas avatar Oct 12 '24 16:10 isaacsas

Ah, I see what you mean now. Yeah that should be simple.

AayushSabharwal avatar Oct 12 '24 16:10 AayushSabharwal

Note, there is no reason not to leave rational systems for a follow up. Just having it on polynomial systems to start is nice!

isaacsas avatar Oct 12 '24 16:10 isaacsas

I haven't gone through properly, but one test case that def should be added is parametric exponents (e.g. x^n). If these are not handled properly (I.e. replaced with their value before sent to HC) HC will fail.

TorkelE avatar Oct 18 '24 14:10 TorkelE

What's left for this to be ready?

ChrisRackauckas avatar Oct 19 '24 05:10 ChrisRackauckas

Adding the parametric exponents test @TorkelE suggested, and figuring out why CI is failing

AayushSabharwal avatar Oct 19 '24 10:10 AayushSabharwal