-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
optimizersLabeled issues concern the `Optimizer`; this will eventually be moved to `GeometricOptimizers`.Labeled issues concern the `Optimizer`; this will eventually be moved to `GeometricOptimizers`.solversThis issue concerns solvers (both linear and nonlinear).This issue concerns solvers (both linear and nonlinear).
Description
The
NonlinearSolverStatuswas made immutable in #109.With commit 85d665a we now have:
SimpleSolvers.jl/src/optimization/optimizer.jl
Lines 182 to 197 in 85d665a
function solve!(x::AbstractVector, state::OptimizerState, opt::Optimizer) initialize_state!(state) while true increase_iteration_number!(state) solver_step!(x, state, opt) status = OptimizerStatus(state, cache(opt), value(problem(opt), x); config = config(opt)) meets_stopping_criteria(status, opt, state) && break update!(state, gradient(opt), x) end warn_iteration_number(state, config(opt)) status = OptimizerStatus(state, cache(opt), value(problem(opt), x); config = config(opt)) OptimizerResult(status, x, value(problem(opt), x)) end
for the optimizer and
SimpleSolvers.jl/src/nonlinear/nonlinear_solver.jl
Lines 144 to 159 in 85d665a
function solve!(x::AbstractArray, s::NonlinearSolver, state::NonlinearSolverState, params=NullParameters()) initialize!(s, x) while true increase_iteration_number!(state) solver_step!(x, s, state, params) # update!(cache(s), state, x, nonlinearproblem(s), params) # this should not be necessary! status = NonlinearSolverStatus(state, cache(s), config(s)) meets_stopping_criteria(status, iteration_number(state), config(s)) && break end status = NonlinearSolverStatus(state, cache(s), config(s)) config(s).verbosity > 1 && print_status(status, iteration_number(state), config(s)) warn_iteration_number(iteration_number(state), config(s)) x end
for the nonlinear solver. This seems to be largely uniform, but theNonlinearSolverStateis updated insolver_step!, whereas theOptimizerStateis updated insolve!directly (see above).The solver step in 85d665a:
SimpleSolvers.jl/src/nonlinear/nonlinear_solver.jl
Lines 114 to 132 in 85d665a
function solver_step!(x::AbstractVector{T}, s::NonlinearSolver{T}, state::NonlinearSolverState{T}, params) where {T} direction!(s, x, params; state = state) # The following loop checks if the RHS contains any NaNs. # If so, the direction vector is reduced by a factor of LINESEARCH_NAN_FACTOR. update!(state, x, value!(value(state), nonlinearproblem(s), x, params), iteration_number(state)) for _ in 1:LINESEARCH_NAN_MAX_ITERATIONS solution(cache(s)) .= solution(state) .+ direction(cache(s)) value!(value(cache(s)), nonlinearproblem(s), solution(cache(s)), params) if any(isnan, value(cache(s))) (s.config.verbosity ≥ 2 && @warn "NaN detected in nonlinear solver. Reducing length of direction vector.") direction(cache(s)) .*= T(LINESEARCH_NAN_FACTOR) else break end end α = solve(linesearch_problem(s, state, params), linesearch(s)) compute_new_iterate!(x, α, direction(cache(s))) x end
Originally posted by @benedict-96 in #61
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
optimizersLabeled issues concern the `Optimizer`; this will eventually be moved to `GeometricOptimizers`.Labeled issues concern the `Optimizer`; this will eventually be moved to `GeometricOptimizers`.solversThis issue concerns solvers (both linear and nonlinear).This issue concerns solvers (both linear and nonlinear).