check_convergence Function

private pure function check_convergence(n, f, f0, x, x0, s, h3, acc, tolf, toldf, toldx, converged, not_converged, inconsistent_linearization) result(mode)

Check for convergence.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
real(kind=wp), intent(in) :: f
real(kind=wp), intent(in) :: f0
real(kind=wp), intent(in), dimension(:) :: x
real(kind=wp), intent(in), dimension(:) :: x0
real(kind=wp), intent(in), dimension(:) :: s
real(kind=wp), intent(in) :: h3
real(kind=wp), intent(in) :: acc
real(kind=wp), intent(in) :: tolf
real(kind=wp), intent(in) :: toldf
real(kind=wp), intent(in) :: toldx
integer, intent(in) :: converged

mode value if converged

integer, intent(in) :: not_converged

mode value if not converged

logical, intent(in) :: inconsistent_linearization

if the SQP problem is inconsistent (will return not_converged)

Return Value integer


Calls

proc~~check_convergence~~CallsGraph proc~check_convergence slsqp_core::check_convergence proc~dnrm2 slsqp_support::dnrm2 proc~check_convergence->proc~dnrm2

Called by

proc~~check_convergence~~CalledByGraph proc~check_convergence slsqp_core::check_convergence proc~slsqpb slsqp_core::slsqpb proc~slsqpb->proc~check_convergence proc~slsqp slsqp_core::slsqp proc~slsqp->proc~slsqpb proc~slsqp_wrapper slsqp_module::slsqp_solver%slsqp_wrapper proc~slsqp_wrapper->proc~slsqp

Source Code

    pure function check_convergence(n,f,f0,x,x0,s,h3,acc,tolf,toldf,toldx,&
                                    converged,not_converged,inconsistent_linearization) result(mode)

    implicit none

    integer,intent(in) :: n
    real(wp),intent(in) :: f
    real(wp),intent(in) :: f0
    real(wp),dimension(:),intent(in) :: x
    real(wp),dimension(:),intent(in) :: x0
    real(wp),dimension(:),intent(in) :: s
    real(wp),intent(in) :: h3
    real(wp),intent(in) :: acc
    real(wp),intent(in) :: tolf
    real(wp),intent(in) :: toldf
    real(wp),intent(in) :: toldx
    integer,intent(in) :: converged     !! mode value if converged
    integer,intent(in) :: not_converged !! mode value if not converged
    logical,intent(in) :: inconsistent_linearization !! if the SQP problem is inconsistent (will return `not_converged`)
    integer :: mode

    logical :: ok ! temp variable
    real(wp),dimension(n) :: xmx0

    if (h3>=acc .or. inconsistent_linearization .or. ieee_is_nan(f)) then
        mode = not_converged
    else

        ! if any are OK then it is converged
        ok = .false.
        if (.not. ok) ok = abs(f-f0)<acc
        if (.not. ok) ok = dnrm2(n,s,1)<acc
        ! note that these can be ignored if they are < 0:
        if (.not. ok .and. tolf>=zero)  ok = abs(f)<tolf
        if (.not. ok .and. toldf>=zero) ok = abs(f-f0)<toldf
        if (.not. ok .and. toldx>=zero) then
            xmx0 = x-x0 ! to avoid array temporary warning
            ok = dnrm2(n,xmx0,1)<toldx
        end if

        if (ok) then
            mode = converged
        else
            mode = not_converged
        end if

    end if

    end function check_convergence