From 93a97caf08ab227d123aed8f8fb7608b9e005ac9 Mon Sep 17 00:00:00 2001 From: zaikunzhang Date: Wed, 3 Apr 2024 00:53:16 +0800 Subject: [PATCH] 240403.005316.HKT minor revision to comments --- fortran/bobyqa/geometry.f90 | 12 +++++++----- fortran/uobyqa/uobyqb.f90 | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fortran/bobyqa/geometry.f90 b/fortran/bobyqa/geometry.f90 index ac843b87b9..a850b9834d 100644 --- a/fortran/bobyqa/geometry.f90 +++ b/fortran/bobyqa/geometry.f90 @@ -8,7 +8,7 @@ module geometry_bobyqa_mod ! ! Started: February 2022 ! -! Last Modified: Tuesday, March 12, 2024 PM09:58:03 +! Last Modified: Wednesday, April 03, 2024 AM12:49:42 !--------------------------------------------------------------------------------------------------! implicit none @@ -99,14 +99,16 @@ function setdrop_tr(kopt, ximproved, bmat, d, delta, rho, xpt, zmat) result(knew ! However, Powell's LINCOA code is different. In his code, the KNEW after a trust-region step is ! picked in lines 72--96 of the update.f for LINCOA, where DISTSQ is calculated as the square of the ! distance to XPT(KOPT, :) (Powell recorded the interpolation points in rows). However, note that -! the trust-region trial point has not been included into XPT yet --- it can not be included -! without knowing KNEW (see lines 332-344 and 404--431 of lincob.f). Hence Powell's LINCOA code -! picks KNEW based on the distance to the un-updated "optimal point", which is unreasonable. -! This has been corrected in our implementation of LINCOA, yet it does not boost the performance. +! the trust-region trial point has not been included into XPT yet --- it cannot be included without +! knowing KNEW (see lines 332-344 and 404--431 of lincob.f). Hence Powell's LINCOA code picks KNEW +! based on the distance to the un-updated "optimal point", which is unreasonable. This has been +! corrected in our implementation of LINCOA, yet it does not boost the performance. if (ximproved) then distsq = sum((xpt - spread(xpt(:, kopt) + d, dim=2, ncopies=npt))**2, dim=1) + !!MATLAB: distsq = sum((xpt - (xpt(:, kopt) + d)).^2) % d should be a column! Implicit expansion else distsq = sum((xpt - spread(xpt(:, kopt), dim=2, ncopies=npt))**2, dim=1) + !!MATLAB: distsq = sum((xpt - xpt(:, kopt)).^2) % Implicit expansion end if weight = max(ONE, distsq / rho**2)**4 diff --git a/fortran/uobyqa/uobyqb.f90 b/fortran/uobyqa/uobyqb.f90 index 2ac2483e18..d76b86f0e5 100644 --- a/fortran/uobyqa/uobyqb.f90 +++ b/fortran/uobyqa/uobyqb.f90 @@ -8,7 +8,7 @@ module uobyqb_mod ! ! Started: February 2022 ! -! Last Modified: Wednesday, April 03, 2024 AM12:02:22 +! Last Modified: Wednesday, April 03, 2024 AM12:45:05 !--------------------------------------------------------------------------------------------------! implicit none @@ -408,7 +408,7 @@ subroutine uobyqb(calfun, iprint, maxfun, eta1, eta2, ftarget, gamma1, gamma2, r !bad_trstep = (shortd .or. trfail .or. ratio <= eta1 .or. knew_tr == 0) ! Works poorly! improve_geo = bad_trstep .and. .not. adequate_geo ! BAD_TRSTEP (for REDUCE_RHO): Is the last trust-region step bad? - bad_trstep = (shortd .or. trfail .or. ratio <= 0 .or. knew_tr == 0) ! Performs better than the below from Powell. + bad_trstep = (shortd .or. trfail .or. ratio <= 0 .or. knew_tr == 0) ! Performs better than the one below from Powell. !bad_trstep = (shortd .or. trfail .or. (ratio <= 0 .and. ddmove <= 4.0_RP * delta**2) .or. knew_tr == 0) reduce_rho = bad_trstep .and. adequate_geo .and. small_trrad