From 5ca897cb942af5af6dae1d76a01ceca15b04153d Mon Sep 17 00:00:00 2001 From: zaikunzhang Date: Sat, 6 Apr 2024 23:54:44 +0800 Subject: [PATCH] 240406.235444.HKT fortran/newuoa: revise the threshold for shiftbase 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` --- .development | 2 +- fortran/common/linalg.f90 | 2 +- fortran/newuoa/newuob.f90 | 6 ++++-- fortran/newuoa/trustregion.f90 | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.development b/.development index 12fdc8ccf3..faa999d7a7 160000 --- a/.development +++ b/.development @@ -1 +1 @@ -Subproject commit 12fdc8ccf3b954ca39500520eb853c26dfaa6418 +Subproject commit faa999d7a74c56089dfed3480bb823187dc8f985 diff --git a/fortran/common/linalg.f90 b/fortran/common/linalg.f90 index 137fb159f0..e279d92f2f 100644 --- a/fortran/common/linalg.f90 +++ b/fortran/common/linalg.f90 @@ -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 diff --git a/fortran/newuoa/newuob.f90 b/fortran/newuoa/newuob.f90 index 52a7561d95..83f632e6af 100644 --- a/fortran/newuoa/newuob.f90 +++ b/fortran/newuoa/newuob.f90 @@ -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 @@ -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 diff --git a/fortran/newuoa/trustregion.f90 b/fortran/newuoa/trustregion.f90 index 0d4378696c..d7623287cd 100644 --- a/fortran/newuoa/trustregion.f90 +++ b/fortran/newuoa/trustregion.f90 @@ -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 @@ -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