diff --git a/fortran/newuoa/newuob.f90 b/fortran/newuoa/newuob.f90 index 1af9b8bf3a..a45921ca60 100644 --- a/fortran/newuoa/newuob.f90 +++ b/fortran/newuoa/newuob.f90 @@ -8,7 +8,7 @@ module newuob_mod ! ! Started: July 2020 ! -! Last Modified: Sunday, March 31, 2024 PM08:16:14 +! Last Modified: Tuesday, April 02, 2024 PM09:06:39 !--------------------------------------------------------------------------------------------------! implicit none @@ -274,18 +274,6 @@ subroutine newuob(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm ! REDUCE_RHO: Should we reduce rho (Boxes 14 and 10 of Fig. 1 in the NEWUOA paper)? ! NEWUOA never sets IMPROVE_GEO and REDUCE_RHO to TRUE simultaneously. do tr = 1, maxtr - ! CLOSE_ITPSET: Are the interpolation points close to XOPT? It affects IMPROVE_GEO, REDUCE_RHO. - ! N.B. (Zaikun 20240331): In Powell's algorithms, CLOSE_ITPSET is defined after XPT is updated - ! according to the trust-region trial step. - distsq = sum((xpt - spread(xpt(:, kopt), dim=2, ncopies=npt))**2, dim=1) - !!MATLAB: distsq = sum((xpt - xpt(:, kopt)).^2) % Implicit expansion - close_itpset = all(distsq <= 4.0_RP * delta**2) ! Powell's code. - ! Below are some alternative definitions of CLOSE_ITPSET. - ! N.B.: The threshold for CLOSE_ITPSET is at least DELBAR, the trust region radius for GEOSTEP. - ! !close_itpset = all(distsq <= 4.0_RP * rho**2) ! Powell's UOBYQA code. - ! !close_itpset = all(distsq <= max((TWO * delta)**2, (TEN * rho)**2)) ! Powell's BOBYQA code. - ! !close_itpset = all(distsq <= max(delta**2, 4.0_RP * rho**2)) ! Powell's LINCOA code. - ! Generate the next trust region step D. call trsapp(delta, gopt, hq, pq, trtol, xpt, crvmin, d) dnorm = min(delta, norm(d)) @@ -403,6 +391,15 @@ subroutine newuob(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm ! ACCURATE_MOD: Are the recent models sufficiently accurate? Used only if SHORTD is TRUE. accurate_mod = all(abs(moderr_rec) <= 0.125_RP * crvmin * rho**2) .and. all(dnorm_rec <= rho) + ! CLOSE_ITPSET: Are the interpolation points close to XOPT? It affects IMPROVE_GEO, REDUCE_RHO. + distsq = sum((xpt - spread(xpt(:, kopt), dim=2, ncopies=npt))**2, dim=1) + !!MATLAB: distsq = sum((xpt - xpt(:, kopt)).^2) % Implicit expansion + close_itpset = all(distsq <= 4.0_RP * delta**2) ! Powell's code. + ! Below are some alternative definitions of CLOSE_ITPSET. + ! N.B.: The threshold for CLOSE_ITPSET is at least DELBAR, the trust region radius for GEOSTEP. + ! !close_itpset = all(distsq <= 4.0_RP * rho**2) ! Powell's UOBYQA code. + ! !close_itpset = all(distsq <= max((TWO * delta)**2, (TEN * rho)**2)) ! Powell's BOBYQA code. + ! !close_itpset = all(distsq <= max(delta**2, 4.0_RP * rho**2)) ! Powell's LINCOA code. ! ADEQUATE_GEO: Is the geometry of the interpolation set "adequate"? adequate_geo = (shortd .and. accurate_mod) .or. close_itpset ! SMALL_TRRAD: Is the trust-region radius small? This indicator seems not impactive in practice. @@ -522,8 +519,6 @@ subroutine newuob(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm ! Improve the geometry of the interpolation set by removing a point and adding a new one. if (improve_geo) then ! XPT(:, KNEW_GEO) will become XOPT + D below. KNEW_GEO /= KOPT unless there is a bug. - distsq = sum((xpt - spread(xpt(:, kopt), dim=2, ncopies=npt))**2, dim=1) - !!MATLAB: distsq = sum((xpt - xpt(:, kopt)).^2) % Implicit expansion knew_geo = int(maxloc(distsq, dim=1), kind(knew_geo)) ! Set DELBAR, which will be used as the trust-region radius for the geometry-improving