JuliaNLSolvers / NLsolve.jl

Julia solvers for systems of nonlinear equations and mixed complementarity problems
Other
329 stars 66 forks source link

Add apply_step! option for Newton method #284

Open sjdaines opened 1 year ago

sjdaines commented 1 year ago

If using method = :newton with linesearch=LineSearches.Static(), adds an option to supply a function to modify Newton steps eg to restrict step length or to restrict to a region. This makes it possible to include problem-specific constraints (eg from a physical or chemical system) to increase robustness.

Adds an additional argument apply_step! (default value (x, x_old, newton_step)->(x .= x_old .+ newton_step)) to define the function used to update the x value after the Newton iteration.

For example, apply_step! = (x, x_old, newton_step)->(x .= x_old .+ newton_step; x .= max.(x, 1e-80)) will enforce a constraint x[i] >= 1e-80 to maintain positive concentrations for a chemical kinetics problem.

nichollsh commented 10 months ago

+1 for this - it would be fantastic!