Skip to content

Commit

Permalink
240403.005316.HKT minor revision to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zaikunzhang committed Apr 2, 2024
1 parent d1a5557 commit 93a97ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions fortran/bobyqa/geometry.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions fortran/uobyqa/uobyqb.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 93a97ca

Please sign in to comment.