Skip to content

Commit

Permalink
240406.235444.HKT fortran/newuoa: revise the threshold for shiftbase …
Browse files Browse the repository at this point in the history
…in newuob.f90 from 5.0E2 to 1.0E2 and the threshold for model scaling in trustregion.f90 from 1.0E10 to 1.0E12; without this, the performance compared with `archiva` is bad when `RP = REAL32`
  • Loading branch information
zaikunzhang committed Apr 6, 2024
1 parent d5af08e commit 5ca897c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .development
2 changes: 1 addition & 1 deletion fortran/common/linalg.f90
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module linalg_mod
!
! Started: July 2020
!
! Last Modified: Friday, April 05, 2024 PM12:19:24
! Last Modified: Saturday, April 06, 2024 PM05:14:34
!--------------------------------------------------------------------------------------------------!

implicit none
Expand Down
6 changes: 4 additions & 2 deletions fortran/newuoa/newuob.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module newuob_mod
!
! Started: July 2020
!
! Last Modified: Thursday, April 04, 2024 PM10:26:06
! Last Modified: Saturday, April 06, 2024 PM11:42:10
!--------------------------------------------------------------------------------------------------!

implicit none
Expand Down Expand Up @@ -626,7 +626,9 @@ subroutine newuob(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm
! Powell's original criteria for shifting XBASE is as follows.
! 1. After a trust region step that is not short, shift XBASE if SUM(XOPT**2) >= 1.0E3*DNORM**2.
! 2. Before a geometry step, shift XBASE if SUM(XOPT**2) >= 1.0E3*DELBAR**2.
if (sum(xpt(:, kopt)**2) >= 5.0E2_RP * delta**2) then ! 5.0E2 works better than 1.0E3 on 20240316.
! 1.0E2 works better than 1.0E3 on 20230227.
! 1.0E2 works better than 5.0E2 on 20240406, especially if RP = REAL32.
if (sum(xpt(:, kopt)**2) >= 1.0E2_RP * delta**2) then
call shiftbase(kopt, xbase, xpt, zmat, bmat, pq, hq, idz)
end if

Expand Down
4 changes: 2 additions & 2 deletions fortran/newuoa/trustregion.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module trustregion_newuoa_mod
!
! Started: July 2020
!
! Last Modified: Thursday, April 04, 2024 PM09:31:44
! Last Modified: Saturday, April 06, 2024 PM11:03:07
!--------------------------------------------------------------------------------------------------!

implicit none
Expand Down Expand Up @@ -133,7 +133,7 @@ subroutine trsapp(delta, gopt_in, hq_in, pq_in, tol, xpt, crvmin, s, info)
! Note that CRVMIN must be scaled back if it is nonzero, but the step is scale invariant.
! N.B.: It is faster and safer to scale by multiplying a reciprocal than by division. See
! https://fortran-lang.discourse.group/t/ifort-ifort-2021-8-0-1-0e-37-1-0e-38-0/
if (maxval(abs(gopt_in)) > 1.0E10) then ! The threshold is empirical.
if (maxval(abs(gopt_in)) > 1.0E12) then ! The threshold is empirical.
modscal = max(TWO * REALMIN, ONE / maxval(abs(gopt_in))) ! MAX: precaution against underflow.
gopt = gopt_in * modscal
pq = pq_in * modscal
Expand Down

0 comments on commit 5ca897c

Please sign in to comment.