Skip to content

Commit

Permalink
Change the norm
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Nov 28, 2023
1 parent 49f8904 commit 594100e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/SimpleNonlinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import PrecompileTools: @compile_workload, @setup_workload, @recompile_invalidat

import DiffEqBase: AbstractNonlinearTerminationMode,
AbstractSafeNonlinearTerminationMode, AbstractSafeBestNonlinearTerminationMode,
NonlinearSafeTerminationReturnCode, get_termination_mode
NonlinearSafeTerminationReturnCode, get_termination_mode,
NONLINEARSOLVE_DEFAULT_NORM
using FiniteDiff, ForwardDiff
import ForwardDiff: Dual
import MaybeInplace: @bb, setindex_trait, CanSetindex, CannotSetindex
Expand Down
8 changes: 4 additions & 4 deletions src/nlsolve/dfsane.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::SimpleDFSane, args...;
abstol, reltol, tc_cache = init_termination_cache(abstol, reltol, fx, x,
termination_condition)

fx_norm = norm(fx)^nexp
fx_norm = NONLINEARSOLVE_DEFAULT_NORM(fx)^nexp
α_1 = one(T)
f_1 = fx_norm

Expand Down Expand Up @@ -99,7 +99,7 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::SimpleDFSane, args...;
@bb @. x += α_p * d

fx = __eval_f(prob, fx, x)
fx_norm_new = norm(fx)^nexp
fx_norm_new = NONLINEARSOLVE_DEFAULT_NORM(fx)^nexp

while k < maxiters
fx_norm_new (f_bar + η - γ * α_p^2 * fx_norm) && break
Expand All @@ -108,7 +108,7 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::SimpleDFSane, args...;
@bb @. x -= α_m * d

fx = __eval_f(prob, fx, x)
fx_norm_new = norm(fx)^nexp
fx_norm_new = NONLINEARSOLVE_DEFAULT_NORM(fx)^nexp

fx_norm_new (f_bar + η - γ * α_m^2 * fx_norm) && break

Expand All @@ -118,7 +118,7 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::SimpleDFSane, args...;
@bb @. x += α_p * d

fx = __eval_f(prob, fx, x)
fx_norm_new = norm(fx)^nexp
fx_norm_new = NONLINEARSOLVE_DEFAULT_NORM(fx)^nexp

k += 1
end
Expand Down
6 changes: 3 additions & 3 deletions test/basictests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ end
# --- Allocation Checks ---

## SimpleDFSane needs to allocate a history vector
@testset "Allocation Checks: $(_nameof(alg))" for alg in ( SimpleNewtonRaphson(),
SimpleHalley(), SimpleBroyden(), SimpleKlement(), SimpleLimitedMemoryBroyden(),
SimpleTrustRegion())
@testset "Allocation Checks: $(_nameof(alg))" for alg in (SimpleNewtonRaphson(),
SimpleHalley(), SimpleBroyden(), SimpleKlement(), SimpleLimitedMemoryBroyden(),
SimpleTrustRegion())
@check_allocs nlsolve(prob, alg) = DiffEqBase.__solve(prob, alg; abstol = 1e-9)

nlprob_scalar = NonlinearProblem{false}(quadratic_f, 1.0, 2.0)
Expand Down

0 comments on commit 594100e

Please sign in to comment.