Skip to content

Commit 4d41af3

Browse files
committed
allow customization of output
1 parent 0879500 commit 4d41af3

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/AlgorithmsInterface.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ include("logging.jl")
2323
# general interface
2424
export Algorithm, Problem, State
2525
export initialize_state, initialize_state!
26+
export finalize_state!
2627

2728
export step!, solve, solve!
2829

src/interface/interface.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ function initialize_state! end
1717
@doc "$(_doc_init_state)"
1818
initialize_state!(::Problem, ::Algorithm, ::State; kwargs...)
1919

20+
21+
"""
22+
output = finalize_state!(problem::Problem, algorithm::Algorithm, state::State)
23+
24+
Finalize the solver and decide what values get returned from the [`solve!`](@ref) call.
25+
By default, this is a no-op and returns the `state`, but this allows for customization
26+
in cases where the details of the `state` can remain hidden.
27+
"""
28+
finalize_state!(problem::Problem, algorithm::Algorithm, state::State) = state
29+
2030
# has to be defined before used in solve but is documented alphabetically after
2131

2232
@doc """
@@ -66,9 +76,10 @@ function solve!(problem::Problem, algorithm::Algorithm, state::State; kwargs...)
6676
end
6777

6878
# emit message about finished state
79+
output = finalize_state!(problem, algorithm, state)
6980
emit_message(logger, problem, algorithm, state, :Stop)
7081

71-
return state
82+
return output
7283
end
7384

7485
function step! end

0 commit comments

Comments
 (0)