diff --git a/.development b/.development index c98b3036b4..3ad8202fd9 160000 --- a/.development +++ b/.development @@ -1 +1 @@ -Subproject commit c98b3036b40175af1586732c9ebc6099c4d25999 +Subproject commit 3ad8202fd920757fc8ab361104cf1f7197d7f52e diff --git a/fortran/bobyqa/bobyqb.f90 b/fortran/bobyqa/bobyqb.f90 index 48162ade1b..65267c9e7a 100644 --- a/fortran/bobyqa/bobyqb.f90 +++ b/fortran/bobyqa/bobyqb.f90 @@ -291,7 +291,7 @@ subroutine bobyqb(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm ! When D is short, make a choice between reducing RHO and improving the geometry depending ! on whether or not our work with the current RHO seems complete. RHO is reduced if the - ! errors in the quadratic model at the last three interpolation points compare favourably + ! errors in the quadratic model at the recent interpolation points compare favourably ! with predictions of likely improvements to the model within distance HALF*RHO of XOPT. ! Why do we reduce RHO when SHORTD is true and the entries of MODERR_REC and DNORM_REC are all ! small? The reason is well explained by the BOBYQA paper in the paragraphs surrounding @@ -326,10 +326,10 @@ subroutine bobyqb(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm end if ! Update DNORM_REC and MODERR_REC. - ! DNORM_REC records the DNORM of the latest 3 function evaluations with the current RHO. + ! DNORM_REC records the DNORM of the recent function evaluations with the current RHO. dnorm_rec = [dnorm_rec(2:size(dnorm_rec)), dnorm] ! MODERR is the error of the current model in predicting the change in F due to D. - ! MODERR_REC records the prediction errors of the latest 3 models with the current RHO. + ! MODERR_REC records the prediction errors of the recent models with the current RHO. moderr = f - fval(kopt) + qred moderr_rec = [moderr_rec(2:size(moderr_rec)), moderr] @@ -518,13 +518,13 @@ subroutine bobyqb(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm end if ! Update DNORM_REC and MODERR_REC. - ! DNORM_REC records the DNORM of the latest 3 function evaluations with the current RHO. + ! DNORM_REC records the DNORM of the recent function evaluations with the current RHO. ! Powell's code does not update DNORM. Therefore, DNORM is the length of the last ! trust-region trial step, inconsistent with MODERR_REC. The same problem exists in NEWUOA. dnorm = min(delbar, norm(d)) dnorm_rec = [dnorm_rec(2:size(dnorm_rec)), dnorm] ! MODERR is the error of the current model in predicting the change in F due to D. - ! MODERR_REC records the prediction errors of the latest 3 models with the current RHO. + ! MODERR_REC records the prediction errors of the recent models with the current RHO. moderr = f - fval(kopt) - quadinc(d, xpt, gopt, pq, hq) ! QRED = Q(XOPT) - Q(XOPT + D) moderr_rec = [moderr_rec(2:size(moderr_rec)), moderr] @@ -552,7 +552,7 @@ subroutine bobyqb(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm rho = redrho(rho, rhoend) ! Print a message about the reduction of RHO according to IPRINT. call rhomsg(solver, iprint, nf, delta, fval(kopt), rho, xbase + xpt(:, kopt)) - ! DNORM_REC and MODERR_REC are corresponding to the latest 3 function evaluations with + ! DNORM_REC and MODERR_REC are corresponding to the recent function evaluations with ! the current RHO. Update them after reducing RHO. dnorm_rec = REALMAX moderr_rec = REALMAX diff --git a/fortran/lincoa/lincob.f90 b/fortran/lincoa/lincob.f90 index 52f18f33e5..c90a023cae 100644 --- a/fortran/lincoa/lincob.f90 +++ b/fortran/lincoa/lincob.f90 @@ -15,7 +15,7 @@ module lincob_mod ! ! Started: February 2022 ! -! Last Modified: Tuesday, October 17, 2023 PM02:52:22 +! Last Modified: Saturday, October 21, 2023 PM08:06:39 !--------------------------------------------------------------------------------------------------! implicit none @@ -182,7 +182,7 @@ subroutine lincob(calfun, iprint, maxfilt, maxfun, npt, Aeq, Aineq, amat, beq, b real(RP) :: delta real(RP) :: distsq(npt) real(RP) :: dnorm -real(RP) :: dnorm_rec(4) ! Powell's implementation uses 5 +real(RP) :: dnorm_rec(3) ! Powell's implementation: DNORM_REC(5) real(RP) :: ffilt(maxfilt) real(RP) :: fval(npt) real(RP) :: galt(size(x)) @@ -368,9 +368,9 @@ subroutine lincob(calfun, iprint, maxfilt, maxfun, npt, Aeq, Aineq, amat, beq, b ! !SHORTD = (DNORM < HALF * RHO) !------------------------------------------------------------------------------------------! - ! DNORM_REC records the DNORM of last few (five) trust-region iterations. It will be used to - ! decide whether we should improve the geometry of the interpolation set or reduce RHO when - ! SHORTD is TRUE. Note that it does not record the geometry steps. + ! DNORM_REC records the DNORM of recent trust-region iterations. It will be used to decide + ! whether we should improve the geometry of the interpolation set or reduce RHO when SHORTD + ! is TRUE. Note that it does not record the geometry steps. dnorm_rec = [dnorm_rec(2:size(dnorm_rec)), dnorm] ! In some cases, we reset DNORM_REC to REALMAX. This indicates a preference of improving the @@ -485,7 +485,7 @@ subroutine lincob(calfun, iprint, maxfilt, maxfun, npt, Aeq, Aineq, amat, beq, b ! verify a curvature condition that really indicates that recent models are sufficiently ! accurate. Here, however, we are not really sure whether they are accurate or not. Therefore, ! ACCURATE_MOD is not the best name, but we keep it to align with the other solvers. - accurate_mod = all(dnorm_rec <= HALF * rho) .or. all(dnorm_rec(3:size(dnorm_rec)) <= 0.2 * rho) + accurate_mod = all(dnorm_rec <= rho) .or. all(dnorm_rec(2:size(dnorm_rec)) <= 0.2 * rho) ! Powell's version (note that size(dnorm_rec) = 5 in his implementation): !accurate_mod = all(dnorm_rec <= HALF * rho) .or. all(dnorm_rec(3:size(dnorm_rec)) <= TENTH * rho) ! CLOSE_ITPSET: Are the interpolation points close to XOPT? diff --git a/fortran/newuoa/newuob.f90 b/fortran/newuoa/newuob.f90 index 708b254e55..039d0e576d 100644 --- a/fortran/newuoa/newuob.f90 +++ b/fortran/newuoa/newuob.f90 @@ -290,10 +290,10 @@ subroutine newuob(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm end if ! Update DNORM_REC and MODERR_REC. - ! DNORM_REC records the DNORM of the latest 3 function evaluations with the current RHO. + ! DNORM_REC records the DNORM of the recent function evaluations with the current RHO. dnorm_rec = [dnorm_rec(2:size(dnorm_rec)), dnorm] ! MODERR is the error of the current model in predicting the change in F due to D. - ! MODERR_REC records the prediction errors of the latest 3 models with the current RHO. + ! MODERR_REC records the prediction errors of the recent models with the current RHO. moderr = f - fval(kopt) + qred moderr_rec = [moderr_rec(2:size(moderr_rec)), moderr] @@ -523,12 +523,12 @@ subroutine newuob(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm end if ! Update DNORM_REC and MODERR_REC. (Should we?) - ! DNORM_REC contains the DNORM of the latest 3 function evaluations with the current RHO. + ! DNORM_REC contains the DNORM of the recent function evaluations with the current RHO. dnorm = min(delbar, norm(d)) ! In theory, DNORM = DELBAR in this case. dnorm_rec = [dnorm_rec(2:size(dnorm_rec)), dnorm] ! MODERR is the error of the current model in predicting the change in F due to D. - ! MODERR_REC is the prediction errors of the latest 3 models with the current RHO. + ! MODERR_REC is the prediction errors of the recent models with the current RHO. moderr = f - fval(kopt) - quadinc(d, xpt, gopt, pq, hq) moderr_rec = [moderr_rec(2:size(moderr_rec)), moderr] !------------------------------------------------------------------------------------------! @@ -561,7 +561,7 @@ subroutine newuob(calfun, iprint, maxfun, npt, eta1, eta2, ftarget, gamma1, gamm rho = redrho(rho, rhoend) ! Print a message about the reduction of RHO according to IPRINT. call rhomsg(solver, iprint, nf, delta, fval(kopt), rho, xbase + xpt(:, kopt)) - ! DNORM_REC and MODERR_REC are corresponding to the latest 3 function evaluations with + ! DNORM_REC and MODERR_REC are corresponding to the recent function evaluations with ! the current RHO. Update them after reducing RHO. dnorm_rec = REALMAX moderr_rec = REALMAX diff --git a/fortran/uobyqa/uobyqb.f90 b/fortran/uobyqa/uobyqb.f90 index 9372628298..a753ffb262 100644 --- a/fortran/uobyqa/uobyqb.f90 +++ b/fortran/uobyqa/uobyqb.f90 @@ -267,10 +267,10 @@ subroutine uobyqb(calfun, iprint, maxfun, eta1, eta2, ftarget, gamma1, gamma2, r end if ! Update DNORM_REC and MODERR_REC. - ! DNORM_REC records the DNORM of the latest 3 function evaluations with the current RHO. + ! DNORM_REC records the DNORM of the recent function evaluations with the current RHO. dnorm_rec = [dnorm_rec(2:size(dnorm_rec)), dnorm] ! MODERR is the error of the current model in predicting the change in F due to D. - ! MODERR_REC records the prediction errors of the latest 3 models with the current RHO. + ! MODERR_REC records the prediction errors of the recent models with the current RHO. moderr = f - fval(kopt) + qred moderr_rec = [moderr_rec(2:size(moderr_rec)), moderr] @@ -423,11 +423,11 @@ subroutine uobyqb(calfun, iprint, maxfun, eta1, eta2, ftarget, gamma1, gamma2, r end if ! Update DNORM_REC and MODERR_REC. - ! DNORM_REC records the DNORM of the latest 3 function evaluations with the current RHO. + ! DNORM_REC records the DNORM of the recent function evaluations with the current RHO. dnorm = min(delbar, norm(d)) ! In theory, DNORM = DELBAR in this case. dnorm_rec = [dnorm_rec(2:size(dnorm_rec)), dnorm] ! MODERR is the error of the current model in predicting the change in F due to D. - ! MODERR_REC records the prediction errors of the latest 3 models with the current RHO. + ! MODERR_REC records the prediction errors of the recent models with the current RHO. moderr = f - fval(kopt) - quadinc(pq, d, xpt(:, kopt)) ! QUADINC = Q(XOPT + D) - Q(XOPT) moderr_rec = [moderr_rec(2:size(moderr_rec)), moderr] @@ -446,7 +446,7 @@ subroutine uobyqb(calfun, iprint, maxfun, eta1, eta2, ftarget, gamma1, gamma2, r rho = redrho(rho, rhoend) ! Print a message about the reduction of RHO according to IPRINT. call rhomsg(solver, iprint, nf, delta, fval(kopt), rho, xbase + xpt(:, kopt)) - ! DNORM_REC and MODERR_REC are corresponding to the latest 3 function evaluations with + ! DNORM_REC and MODERR_REC are corresponding to the recent function evaluations with ! the current RHO. Update them after reducing RHO. dnorm_rec = REALMAX moderr_rec = REALMAX