Skip to content

Commit 6a1fe44

Browse files
committed
fix: initial objective for termination conditions
1 parent be6b9a5 commit 6a1fe44

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/NonlinearSolveFirstOrder/test/least_squares_tests.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,24 @@ end
5454
@test norm(sol.resid, 2) < 1e-6
5555
end
5656
end
57+
58+
@testitem "Correct Best Solution: #565" setup=[CoreNLLSTesting] tags=[:core] begin
59+
using StableRNGs
60+
61+
x = collect(0:0.1:10)
62+
63+
line_fct(x, p) = p[1] .+ p[2] .* x
64+
65+
y_line = line_fct(x, [1, 3])
66+
y_line_n = line_fct(x, [1, 3]) + randn(StableRNG(0), length(x))
67+
68+
res(β, (x, y)) = line_fct(x, β) .- y
69+
70+
prob = NonlinearLeastSquaresProblem(res, [1, 3], p = (x, y_line_n))
71+
sol1 = solve(prob; maxiters = 1000)
72+
73+
prob = NonlinearLeastSquaresProblem(res, [1, 5], p = (x, y_line_n))
74+
sol2 = solve(prob; maxiters = 1000)
75+
76+
@test sol1.u sol2.u
77+
end

0 commit comments

Comments
 (0)