Skip to content

Commit 815cc55

Browse files
committed
Handle decorators in get_cost
1 parent 03ab065 commit 815cc55

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/solvers/solver.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,11 @@ The method may be implemented by particular solvers if they store the cost at th
198198
iterate in the state, but by default it is obtained by calling `get_cost(p, get_iterate(s))`.
199199
"""
200200
function get_cost(p::AbstractManoptProblem, s::AbstractManoptSolverState)
201+
return _get_cost(p, s, dispatch_state_decorator(s))
202+
end
203+
function _get_cost(p::AbstractManoptProblem, s::AbstractManoptSolverState, ::Val{false})
201204
return get_cost(p, get_iterate(s))
202205
end
206+
function _get_cost(p::AbstractManoptProblem, s::AbstractManoptSolverState, ::Val{true})
207+
return get_cost(p, s.state)
208+
end

test/solvers/test_quasi_Newton.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,5 +572,9 @@ end
572572
solve!(mp, qns)
573573
@test get_cost(mp, qns) == f(M, get_iterate(qns))
574574

575+
@testset "get_cost with DebugSolverState" begin
576+
dqns = DebugSolverState(qns, DebugMessages(:Info, :Always))
577+
@test get_cost(mp, dqns) == f(M, get_iterate(dqns))
578+
end
575579
end
576580
end

0 commit comments

Comments
 (0)