Skip to content
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

IntervalNonlinearProblem kwargs not passed to solver #522

Open
lxvm opened this issue Dec 19, 2024 · 2 comments
Open

IntervalNonlinearProblem kwargs not passed to solver #522

lxvm opened this issue Dec 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@lxvm
Copy link

lxvm commented Dec 19, 2024

Describe the bug 🐞

Although the IntervalNonlinearProblem docs say keyword arguments are passed to the solver, I do not find the solution to depend on the abstol passed to the problem (abstol does have an effect when passed to the solve). I only tested ITP.

Expected behavior

I would like to see that the abstol passed to the problem overrides the default abstol, but is of lower precedence than tolerances passed into solve.

Minimal Reproducible Example 👇

using SimpleNonlinearSolve
const counter = Ref(0)
prob = IntervalNonlinearProblem((x, counter) -> (counter[] += 1; exp(-x)-x), (0.0, 1.0), counter; abstol=1e-3)
solve(prob, ITP())
counter[] # 37
counter[] = 0
solve(prob, ITP(); abstol=1e-3)
counter[] # 9, fewer function evaluations than first, meaning the problem tolerance was not used

I was using SimpleNonlinearSolve.jl v2.1.0.

@lxvm lxvm added the bug Something isn't working label Dec 19, 2024
@ErikQQY
Copy link
Member

ErikQQY commented Dec 19, 2024

Absolute tolerance needs to be specified in solve, in your first solve(prob, ITP()), ITP utilized the default abstol as real(oneunit(T)) * (eps(real(one(T))))^(4 // 5) which is approximately 3e-13. Then in your second solve(prob, ITP(); abstol=1e-3), the absolute tolerance is specified as 1e-3, hence fewer function evaluations.

@avik-pal
Copy link
Member

Absolute tolerance needs to be specified in solve, in your first solve(prob, ITP()), ITP utilized the default abstol as real(oneunit(T)) * (eps(real(one(T))))^(4 // 5) which is approximately 3e-13. Then in your second solve(prob, ITP(); abstol=1e-3), the absolute tolerance is specified as 1e-3, hence fewer function evaluations.

The issue here is if we specify kwargs in IntervalNonlinearProblem, those should be forwarded to solve automatically.

Since we override https://github.com/SciML/NonlinearSolve.jl/blob/master/lib/BracketingNonlinearSolve/src/itp.jl#L59 directly, we should probably do kwargs = merge(prob.kwargs, kwargs) to resolve this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants