@@ -389,6 +389,15 @@ function quasi_Newton!(
389389end
390390calls_with_kwargs (:: typeof (quasi_Newton!)) = (decorate_objective!, decorate_state!)
391391
392+ function _get_max_stepsize (M:: AbstractManifold , qns:: QuasiNewtonState )
393+ current_max_stepsize = get_parameter (qns. direction_update, Val (:max_stepsize ))
394+ if ! isnothing (current_max_stepsize) && ! isfinite (current_max_stepsize)
395+ return max_stepsize (M, qns. p) / norm (qns. η)
396+ else
397+ return current_max_stepsize
398+ end
399+ end
400+
392401function initialize_solver! (amp:: AbstractManoptProblem , qns:: QuasiNewtonState )
393402 M = get_manifold (amp)
394403 get_gradient! (amp, qns. X, qns. p)
@@ -401,10 +410,7 @@ function step_solver!(mp::AbstractManoptProblem, qns::QuasiNewtonState, k)
401410 M = get_manifold (mp)
402411 get_gradient! (mp, qns. X, qns. p)
403412 qns. direction_update (qns. η, mp, qns)
404- current_max_stepsize = get_parameter (qns. direction_update, Val (:max_stepsize ))
405- if ! isnothing (current_max_stepsize) && ! isfinite (current_max_stepsize)
406- current_max_stepsize = max_stepsize (M, qns. p) / norm (qns. η)
407- end
413+ current_max_stepsize = _get_max_stepsize (M, qns)
408414 if ! (qns. nondescent_direction_behavior === :ignore )
409415 qns. nondescent_direction_value = real (inner (M, qns. p, qns. η, qns. X))
410416 if qns. nondescent_direction_value >= 0
@@ -416,6 +422,12 @@ function step_solver!(mp::AbstractManoptProblem, qns::QuasiNewtonState, k)
416422 if qns. nondescent_direction_behavior === :reinitialize_direction_update
417423 initialize_update! (qns. direction_update)
418424 end
425+ # update direction after reinitialization to get a valid one
426+ if qns. nondescent_direction_behavior === :step_towards_negative_gradient ||
427+ qns. nondescent_direction_behavior === :reinitialize_direction_update
428+ qns. direction_update (qns. η, mp, qns)
429+ current_max_stepsize = _get_max_stepsize (M, qns)
430+ end
419431 end
420432 end
421433 local α # COV_EXCL_LINE
@@ -802,6 +814,17 @@ function update_hessian!(
802814 end
803815
804816 if reforming_required
817+ # we need to move first vectors in memory too because they most likely won't be
818+ # overwritten by new pairs
819+ if start == 2
820+ vector_transport_to! (
821+ M, d. memory_s[1 ], p_old, d. memory_s[1 ], p, d. vector_transport_method
822+ )
823+ vector_transport_to! (
824+ M, d. memory_y[1 ], p_old, d. memory_y[1 ], p, d. vector_transport_method
825+ )
826+ fill_rho_i! (M, p, d, 1 )
827+ end
805828 _drop_zero_rho_vectors! (d)
806829 end
807830
0 commit comments