-
-
Notifications
You must be signed in to change notification settings - Fork 232
Make NonlinearSolve.jl an optional dependency #3850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Move NonlinearSolve and SCCNonlinearSolve from direct deps to weakdeps - Create MTKNonlinearSolveExt extension to handle NonlinearSolve functionality - Update linearization to use conditional loading of TrustRegion algorithm - Add error message when NonlinearSolve is required but not loaded This change allows ModelingToolkit to be used without NonlinearSolve.jl as a hard dependency, reducing the dependency footprint for users who don't need nonlinear solving functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
# Export the TrustRegion algorithm for use in linearization | ||
ModelingToolkit._get_default_nlsolve_alg() = TrustRegion() | ||
|
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
end | |
end |
else | ||
initialization_solver_alg | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
Use single-line function definition for better readability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
@@ -379,4 +378,7 @@ PrecompileTools.@compile_workload begin | |||
end | |||
end | |||
|
|||
# Default nonlinear solver algorithm - will be overridden by extension when NonlinearSolve is loaded | |||
_get_default_nlsolve_alg() = error("NonlinearSolve.jl is required for linearization with initialization. Please load NonlinearSolve.jl to use this functionality.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
_get_default_nlsolve_alg() = error("NonlinearSolve.jl is required for linearization with initialization. Please load NonlinearSolve.jl to use this functionality.") | |
function _get_default_nlsolve_alg() | |
error("NonlinearSolve.jl is required for linearization with initialization. Please load NonlinearSolve.jl to use this functionality.") | |
end |
Benchmark Results (Julia vlts)Time benchmarks
Memory benchmarks
|
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
Summary
Motivation
This change reduces the dependency footprint of ModelingToolkit for users who don't need nonlinear solving functionality. NonlinearSolve.jl brings in a significant dependency tree, and making it optional allows for faster installation and lighter deployments.
Changes
[weakdeps]
sectionext/MTKNonlinearSolveExt/MTKNonlinearSolveExt.jl
to load TrustRegion algorithm when NonlinearSolve is availableImpact
Test plan
🤖 Generated with Claude Code