Skip to content

Commit

Permalink
230615.205251.CST cobyla: try the last trust-region step before retur…
Browse files Browse the repository at this point in the history
…ning if `info = SMALL_TR_RADIUS` and `shortd` is true; this improves the performance
  • Loading branch information
zaikunzhang committed Jun 15, 2023
1 parent d3af83b commit 2a644b0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .development
6 changes: 3 additions & 3 deletions fortran/bobyqa/bobyqb.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module bobyqb_mod
!
! Started: February 2022
!
! Last Modified: Tuesday, June 13, 2023 AM01:19:13
! Last Modified: Thursday, June 15, 2023 PM08:12:28
!--------------------------------------------------------------------------------------------------!

implicit none
Expand Down Expand Up @@ -561,13 +561,13 @@ subroutine bobyqb(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm
end if
end do ! End of DO TR = 1, MAXTR. The iterative procedure ends.

! Return, possibly after another Newton-Raphson step, if it is too short to have been tried before.
! Return from the calculation, after trying the Newton-Raphson step if it has not been tried yet.
if (info == SMALL_TR_RADIUS .and. shortd .and. nf < maxfun) then
x = xinbd(xbase, xpt(:, kopt) + d, xl, xu, sl, su) ! In precise arithmetic, X = XBASE + XOPT + D.
call evaluate(calfun, x, f)
nf = nf + 1_IK
! Print a message about the function evaluation according to IPRINT.
! Zaikun 20230512: DELTA has been updated. RHO only indicative here. TO BE IMPROVED.
! Zaikun 20230512: DELTA has been updated. RHO is only indicative here. TO BE IMPROVED.
call fmsg(solver, 'Trust region', iprint, nf, rho, f, x)
! Save X, F into the history.
call savehist(nf, x, xhist, f, fhist)
Expand Down
17 changes: 16 additions & 1 deletion fortran/cobyla/cobylb.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module cobylb_mod
!
! Started: July 2021
!
! Last Modified: Tuesday, June 13, 2023 PM08:36:35
! Last Modified: Thursday, June 15, 2023 PM08:24:11
!--------------------------------------------------------------------------------------------------!

implicit none
Expand Down Expand Up @@ -587,6 +587,21 @@ subroutine cobylb(calcfc, iprint, maxfilt, maxfun, ctol, cweight, eta1, eta2, ft

end do ! End of DO TR = 1, MAXTR. The iterative procedure ends.

! Return from the calculation, after trying the last trust-region step if it has not been tried yet.
if (info == SMALL_TR_RADIUS .and. shortd .and. nf < maxfun) then
x = sim(:, n + 1) + d
call evaluate(calcfc, x, f, constr, cstrv)
nf = nf + 1_IK
! Print a message about the function evaluation according to IPRINT.
! Zaikun 20230512: DELTA has been updated. RHO is only indicative here. TO BE IMPROVED.
! Print a message about the function/constraint evaluation according to IPRINT.
call fmsg(solver, 'Trust region', iprint, nf, rho, f, x, cstrv, constr)
! Save X, F, CONSTR, CSTRV into the history.
call savehist(nf, x, xhist, f, fhist, cstrv, chist, constr, conhist)
! Save X, F, CONSTR, CSTRV into the filter.
call savefilt(cstrv, ctol, cweight, f, x, nfilt, cfilt, ffilt, xfilt, constr, confilt)
end if

! Return the best calculated values of the variables.
! N.B. SELECTX and FINDPOLE choose X by different standards. One cannot replace the other.
kopt = selectx(ffilt(1:nfilt), cfilt(1:nfilt), max(cpen, cweight), ctol)
Expand Down
6 changes: 3 additions & 3 deletions fortran/lincoa/lincob.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module lincob_mod
!
! Started: February 2022
!
! Last Modified: Tuesday, June 13, 2023 AM01:03:05
! Last Modified: Thursday, June 15, 2023 PM08:11:49
!--------------------------------------------------------------------------------------------------!

implicit none
Expand Down Expand Up @@ -613,15 +613,15 @@ subroutine lincob(calfun, iprint, maxfilt, maxfun, npt, A_orig, amat, b_orig, bv
end if
end do ! End of DO TR = 1, MAXTR. The iterative procedure ends.

! Return from the calculation, after trying the Newton-Raphson step if it has not been tried before.
! Return from the calculation, after trying the Newton-Raphson step if it has not been tried yet.
if (info == SMALL_TR_RADIUS .and. shortd .and. nf < maxfun) then
x = xbase + (xpt(:, kopt) + d)
call evaluate(calfun, x, f)
nf = nf + 1_IK
constr = matprod(x, A_orig) - b_orig
cstrv = maximum([ZERO, constr])
! Print a message about the function evaluation according to IPRINT.
! Zaikun 20230512: DELTA has been updated. RHO only indicative here. TO BE IMPROVED.
! Zaikun 20230512: DELTA has been updated. RHO is only indicative here. TO BE IMPROVED.
call fmsg(solver, 'Trust region', iprint, nf, rho, f, x, cstrv, constr)
! Save X, F, CSTRV into the history.
call savehist(nf, x, xhist, f, fhist, cstrv, chist)
Expand Down
6 changes: 3 additions & 3 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: Tuesday, June 13, 2023 AM01:20:55
! Last Modified: Thursday, June 15, 2023 PM08:12:10
!--------------------------------------------------------------------------------------------------!

implicit none
Expand Down Expand Up @@ -569,13 +569,13 @@ subroutine newuob(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm
end if
end do ! End of DO TR = 1, MAXTR. The iterative procedure ends.

! Return, possibly after another Newton-Raphson step, if it is too short to have been tried before.
! Return from the calculation, after trying the Newton-Raphson step if it has not been tried yet.
if (info == SMALL_TR_RADIUS .and. shortd .and. nf < maxfun) then
x = xbase + (xpt(:, kopt) + d)
call evaluate(calfun, x, f)
nf = nf + 1_IK
! Print a message about the function evaluation according to IPRINT.
! Zaikun 20230512: DELTA has been updated. RHO only indicative here. TO BE IMPROVED.
! Zaikun 20230512: DELTA has been updated. RHO is only indicative here. TO BE IMPROVED.
call fmsg(solver, 'Trust region', iprint, nf, rho, f, x)
! Save X, F into the history.
call savehist(nf, x, xhist, f, fhist)
Expand Down
8 changes: 4 additions & 4 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: Tuesday, June 13, 2023 AM01:04:34
! Last Modified: Thursday, June 15, 2023 PM08:12:56
!--------------------------------------------------------------------------------------------------!

implicit none
Expand Down Expand Up @@ -199,7 +199,7 @@ subroutine uobyqb(calfun, iprint, maxfun, eta1, eta2, ftarget, gamma1, gamma2, r
! Then TRRAD will update DELTA to GAMMA2*RHO. If GAMMA3 >= GAMMA2, then DELTA will be reset to RHO,
! which is not reasonable as D is very successful. See paragraph two of Sec. 5.2.5 in
! T. M. Ragonneau's thesis: "Model-Based Derivative-Free Optimization Methods and Software".
! According to test on 20230613, for UOBYQA, this Powellful updating scheme of DELTA works better
! According to test on 20230613, for UOBYQA, this Powellful updating scheme of DELTA works better
! than setting directly DELTA = MAX(NEW_DELTA, RHO).
gamma3 = max(ONE, min(0.75_RP * gamma2, 1.5_RP))

Expand Down Expand Up @@ -444,13 +444,13 @@ subroutine uobyqb(calfun, iprint, maxfun, eta1, eta2, ftarget, gamma1, gamma2, r
end if
end do ! End of DO TR = 1, MAXTR. The iterative procedure ends.

! Return, possibly after another Newton-Raphson step, if it is too short to have been tried before.
! Return from the calculation, after trying the Newton-Raphson step if it has not been tried yet.
if (info == SMALL_TR_RADIUS .and. shortd .and. nf < maxfun) then
x = xbase + (xpt(:, kopt) + d)
call evaluate(calfun, x, f)
nf = nf + 1_IK
! Print a message about the function evaluation according to IPRINT.
! Zaikun 20230512: DELTA has been updated. RHO only indicative here. TO BE IMPROVED.
! Zaikun 20230512: DELTA has been updated. RHO is only indicative here. TO BE IMPROVED.
call fmsg(solver, 'Trust region', iprint, nf, rho, f, x)
! Save X, F into the history.
call savehist(nf, x, xhist, f, fhist)
Expand Down

0 comments on commit 2a644b0

Please sign in to comment.