enforce the bound constraints on x
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout), | dimension(:) | :: | x |
optimization variable vector |
|
real(kind=wp), | intent(in), | dimension(:) | :: | xl |
lower bounds (must be same dimension as |
|
real(kind=wp), | intent(in), | dimension(:) | :: | xu |
upper bounds (must be same dimension as |
|
real(kind=wp), | intent(in) | :: | infbnd |
"infinity" for the upper and lower bounds.
Note that |
subroutine enforce_bounds(x,xl,xu,infbnd) implicit none real(wp),dimension(:),intent(inout) :: x !! optimization variable vector real(wp),dimension(:),intent(in) :: xl !! lower bounds (must be same dimension as `x`) real(wp),dimension(:),intent(in) :: xu !! upper bounds (must be same dimension as `x`) real(wp),intent(in) :: infbnd !! "infinity" for the upper and lower bounds. !! Note that `NaN` may also be used to indicate no bound. where (x<xl .and. xl>-infbnd .and. .not. ieee_is_nan(xl)) x = xl elsewhere (x>xu .and. xu<infbnd .and. .not. ieee_is_nan(xu)) x = xu end where end subroutine enforce_bounds