if necessary, adjust the x vector to be within the bounds.
used for the initial guess.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(nlesolver_type), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(inout), | dimension(me%n) | :: | x |
the |
subroutine adjust_x_for_bounds(me,x) implicit none class(nlesolver_type),intent(inout) :: me real(wp),dimension(me%n),intent(inout) :: x !! the `x` vector to adjust integer :: i !! counter if (me%bounds_mode/=NLESOLVER_IGNORE_BOUNDS) then ! for all bounds modes, adjust the initial guess to be within the bounds ! x = min(max(x,me%xlow),me%xupp) do i = 1, me%n if (x(i)<me%xlow(i)) then x(i) = me%xlow(i) if (me%verbose) write(me%iunit, '(A)') 'Initial x('//int2str(i)//') < xlow(i) : adjusting to lower bound' else if (x(i)>me%xupp(i)) then x(i) = me%xupp(i) if (me%verbose) write(me%iunit, '(A)') 'Initial x('//int2str(i)//') > xupp(i) : adjusting to upper bound' end if end do end if end subroutine adjust_x_for_bounds