Skip to content

Commit

Permalink
adjusting \epsilon upward when linesearch fails
Browse files Browse the repository at this point in the history
  • Loading branch information
dfridovi committed Nov 27, 2024
1 parent 0269261 commit 29977d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function solve(
iters += 1
end

ϵ *= 1 - exp(-iters)
ϵ *= (status == :solved) ? 1 - exp(-iters) : 1 + exp(-iters)
end

(; status, x, y, s, kkt_error, ϵ)
Expand Down
10 changes: 5 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using FiniteDiff: FiniteDiff
M = [2 1; 1 2]
A = [1 0; 0 1]
b = [1; 1]
θ = zeros(2)
θ = rand(2)

G(x, y; θ) = M * x - A' * y - θ
H(x, y; θ) = A * x - b
Expand All @@ -28,12 +28,12 @@ using FiniteDiff: FiniteDiff
end

function check_solution(sol)
@test all(abs.(G(sol.x, sol.y; θ)) .≤ 1e-3)
@test all(abs.(G(sol.x, sol.y; θ)) .≤ 2e-3)
@test all(H(sol.x, sol.y; θ) .≥ 0)
@test all(sol.y .≥ 0)
@test sum(sol.y .* H(sol.x, sol.y; θ)) 1e-3
@test all(sol.s .≤ 1e-3)
@test sol.kkt_error 1e-3
@test sum(sol.y .* H(sol.x, sol.y; θ)) 2e-3
@test all(sol.s .≤ 2e-3)
@test sol.kkt_error 2e-3
@test sol.status == :solved
end

Expand Down

0 comments on commit 29977d0

Please sign in to comment.