Skip to content

Commit

Permalink
240402.212442.HKT revoke the modification to close_itpset in newuob…
Browse files Browse the repository at this point in the history
….f90 in 6db5dcf, as the performance against the classical version is not ideal, even though it outperforms the last version according to performance profiles
  • Loading branch information
zaikunzhang committed Apr 2, 2024
1 parent 803b7ac commit ed92be2
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 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: Sunday, March 31, 2024 PM08:16:14
! Last Modified: Tuesday, April 02, 2024 PM09:06:39
!--------------------------------------------------------------------------------------------------!

implicit none
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed92be2

Please sign in to comment.