compute_next_step Subroutine

private subroutine compute_next_step(me, xold, search_direction, alpha, alpha_top, modified, xnew)

Compute the next step.

Type Bound

nlesolver_type

Arguments

Type IntentOptional Attributes Name
class(nlesolver_type), intent(inout) :: me
real(kind=wp), intent(in), dimension(me%n) :: xold

initial x

real(kind=wp), intent(in), dimension(me%n) :: search_direction

search direction vector

real(kind=wp), intent(in) :: alpha

step length to take in the search direction

real(kind=wp), intent(in) :: alpha_top

the largest step length that will be attempted in the line search (see adjust_search_direction)

logical, intent(in), dimension(me%n) :: modified

indicates the elements of p that were modified because they violated the bounds. Output of adjust_search_direction.

real(kind=wp), intent(out), dimension(me%n) :: xnew

final x


Called by

proc~~compute_next_step~~CalledByGraph proc~compute_next_step nlesolver_type%compute_next_step proc~backtracking_linesearch backtracking_linesearch proc~backtracking_linesearch->proc~compute_next_step proc~exact_linesearch exact_linesearch proc~exact_linesearch->proc~compute_next_step proc~fixed_point_linesearch fixed_point_linesearch proc~fixed_point_linesearch->proc~compute_next_step proc~simple_step simple_step proc~simple_step->proc~compute_next_step

Source Code

    subroutine compute_next_step(me, xold, search_direction, alpha, alpha_top, modified, xnew)

    class(nlesolver_type),intent(inout)  :: me
    real(wp),dimension(me%n),intent(in)  :: xold  !! initial `x`
    real(wp),dimension(me%n),intent(in)  :: search_direction  !! search direction vector
    real(wp),intent(in)                  :: alpha !! step length to take in the search direction
    real(wp),intent(in)                  :: alpha_top !! the largest step length that will be attempted
                                                      !! in the line search (see [[adjust_search_direction]])
    logical,dimension(me%n),intent(in)   :: modified  !! indicates the elements of `p` that were
                                                      !! modified because they violated the bounds.
                                                      !! Output of [[adjust_search_direction]].
    real(wp),dimension(me%n),intent(out) :: xnew  !! final `x`

    if (me%bounds_mode == NLESOLVER_WALL_BOUNDS) then
        ! for the 'wall' mode, the modified variables are put on the bounds and held
        ! fixed there during the line search (independent of alpha). Note that for these,
        ! `xold + alpha_top*search_direction` is the bound (see `adjust_search_direction`).
        where (modified)
            xnew = xold + alpha_top * search_direction
        else where
            xnew = xold + search_direction * alpha
        end where
    else
        ! all other modes just use the computed search direction
        xnew = xold + search_direction * alpha
    end if

    if (me%bounds_mode /= NLESOLVER_IGNORE_BOUNDS) then
        ! For alpha in (0,1], the steps computed by `adjust_search_direction` are within the
        ! bounds in exact arithmetic, but a point meant to be on a bound can be just outside
        ! it due to rounding (e.g., x + (xupp - x) > xupp). Make sure it never is:
        xnew = min(max(xnew, me%xlow), me%xupp)
    end if

    end subroutine compute_next_step