Skip to content

Commit cef7482

Browse files
committed
centralize _solve_body! code
1 parent f18fc61 commit cef7482

1 file changed

Lines changed: 5 additions & 18 deletions

File tree

src/interface/interface.jl

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,7 @@ function solve(problem::Problem, algorithm::Algorithm; kwargs...)
4949
state = initialize_state(problem, algorithm; kwargs...)
5050
emit_message(logger, problem, algorithm, state, :Start)
5151

52-
# main body of the algorithm
53-
while !is_finished!(problem, algorithm, state)
54-
# logging event between convergence check and algorithm step
55-
emit_message(logger, problem, algorithm, state, :PreStep)
56-
57-
# algorithm step
58-
increment!(state)
59-
step!(problem, algorithm, state)
60-
61-
# logging event between algorithm step and convergence check
62-
emit_message(logger, problem, algorithm, state, :PostStep)
63-
end
64-
65-
# emit message about finished state
66-
output = finalize_state!(problem, algorithm, state)
67-
emit_message(logger, problem, algorithm, state, :Stop)
68-
69-
return output
52+
return _solve_body!(problem, algorithm, state, logger)
7053
end
7154

7255
@doc """
@@ -87,6 +70,10 @@ function solve!(problem::Problem, algorithm::Algorithm, state::State; kwargs...)
8770
initialize_state!(problem, algorithm, state; kwargs...)
8871
emit_message(logger, problem, algorithm, state, :Start)
8972

73+
return _solve_body!(problem, algorithm, state, logger)
74+
end
75+
76+
function _solve_body!(problem::Problem, algorithm::Algorithm, state::State, logger)
9077
# main body of the algorithm
9178
while !is_finished!(problem, algorithm, state)
9279
# logging event between convergence check and algorithm step

0 commit comments

Comments
 (0)