Nonlinear conjugate gradient for smooth convex functions††thanks: Supported in part by a grant from the Natural Sciences and Engineering Research Council (NSERC) of Canada.
Abstract
The method of nonlinear conjugate gradients (NCG) is widely used in practice for unconstrained optimization, but it satisfies weak complexity bounds at best when applied to smooth convex functions. In contrast, Nesterov’s accelerated gradient (AG) method is optimal up to constant factors for this class.
However, when specialized to quadratic function, conjugate gradient is optimal in a strong sense among function-gradient methods. Therefore, there is seemingly a gap in the menu of available algorithms: NCG, the optimal algorithm for quadratic functions that also exhibits good practical performance for general functions, has poor complexity bounds compared to AG.
We propose an NCG method called C+AG (“conjugate plus accelerated gradient”) to close this gap, that is, it is optimal for quadratic functions and still satisfies the best possible complexity bound for more general smooth convex functions. It takes conjugate gradient steps until insufficient progress is made, at which time it switches to accelerated gradient steps, and later retries conjugate gradient. The proposed method has the following theoretical properties: (i) It is identical to linear conjugate gradient (and hence terminates finitely) if the objective function is quadratic; (ii) Its running-time bound is gradient evaluations for an -smooth convex function, where is the desired residual reduction, (iii) Its running-time bound is if the function is both -smooth and -strongly convex. We also conjecture and outline a proof that a variant of the method has the property: (iv) It is -step quadratically convergent for a function whose second derivative is smooth and invertible at the optimizer. Note that the bounds in (ii) and (iii) match AG and are the best possible, i.e., they match lower bounds up to constant factors for the classes of functions under consideration. On the other hand, (i) and (iv) match NCG.
In computational tests, the function-gradient evaluation count for the C+AG method typically behaves as whichever is better of AG or classical NCG. In some test cases it outperforms both.
1 First-order methods for smooth convex functions
The problem under consideration is minimizing an unconstrained -smooth convex function . Recall that a convex function is -smooth if it is differentiable and for all ,
(1) |
Note that convexity implies that the quantity on the left-hand side of this inequality is nonnegative. We will also sometimes consider -strongly convex functions, which are defined to be those functions satisfying
(2) |
for all for some modulus . (This definition presumes differentiability. The class of strongly convex functions includes nondifferentiable functions as well, but those functions are not smooth and are therefore not relevant to this paper.) Note that means simply that is differentiable and convex.
Nonlinear conjugate gradient (NCG) [21] is perhaps the most widely used first-order method for unconstrained optimization. It is an extension of linear conjugate gradient (LCG) introduced by Hestenes and Stiefel [13] to minimize convex quadratic functions. The smoothness modulus for a quadratic function , where is positive semidefinite, is the maximum eigenvalue of . LCG is optimal for quadratic functions in a strong sense that , where is the th iterate, is minimized over all choices of lying in the th Krylov space leading to the estimate of iterations to reduce the residual of by a factor .
Stated precisely, Daniel [9, Theorem 1.2.2] proved the following bound for the th iteration of LCG:
(3) |
Here and in the remainder of the paper, stands for and is assumed to be attained. Therefore, if we define the residual reduction
then a rearrangement and application of simple bounds in (3) shows that reduction is achieved after iterations.
However, if the class of problems is enlarged to include all smooth, strongly convex functions, then NCG fails to satisfy this complexity bound and could perform even worse than steepest descent as shown by Nemirovsky and Yudin [18]. Nonetheless, in practice, nonlinear conjugate gradient is difficult to beat even by algorithms with better theoretical guarantees, as observed in our experiments and by others, e.g., Carmon et al. [4].
Several first-order methods have been proposed for smooth strongly convex functions that achieve the running time including Nemirovsky and Yudin’s [18] method, which requires solution of a two-dimensional subproblem on each iteration, Nesterov’s accelerated gradient (AG) [19], and Geometric Descent (GD) [2]. In the case of GD, the bound is on iterations rather than gradient evaluations since each iteration requires additional gradient evaluations for the line search. It is known that gradient evaluations are required to reduce the objective function residual by a factor of ; see, e.g., the book of Nesterov [20] for a discussion of the lower bound result. Since the algorithms mentioned in this paragraph match the lower bound, these algorithms are optimal up to a constant factor. In the case of smooth convex (not strongly convex) functions, AG requires iterations.
The precise bound for accelerated gradient for strongly convex functions is stated below in (14), and this bound can be rearranged and estimated as follows. Define the residual reduction
This reduction can be attained after no more than iterations.
A technical issue in comparing the bounds is the different definitions of and . A standard result of extremal eigenvalues states that
Therefore, it follows that Thus, tightly controls , whereas only loosely controls , and therefore, the LCG bound is slightly better than the corresponding AG bound in this technical sense.
In practice, conjugate gradient for quadratic functions is typically superior to AG applied to quadratic functions. The reason appears to be not so much the technical reason mentioned in the previous paragraph but the fact that LCG is optimal in a stronger sense than AG: the iterate is the true minimizer of over the th Krylov space, which is defined to be assuming . For quadratic problems in which the eigenvalues lie in a small number of clusters, one expects convergence much faster than . But even in the case of spread-out eigenvalues, conjugate gradient often bests accelerated gradient. Table 1 shows the results for these algorithms for three matrices:
two of which have clustered eigenvalues, and the third has spread-out eigenvalues.
. LCG C+AG NCG AG : # iterations 2 3 2 9167 : # function-gradient evaluations 2 27 5 18357 : # iterations 3 4 3 10267 : # function-gradient evaluations 3 30 7 20557 : # iterations 1509 1512 1515 : # function-gradient evaluations 1509 3065 3036
Note that the three conjugate gradient methods require roughly the same number of iterations, all much less than AG. The function evaluations are: 1 per LCG iteration (i.e., a single matrix-vector multiplication), 2 per C+AG iteration, approximately 2 per NCG iteration, and 1 per AG iteration. The requirement for more than one function evaluation per NCG iteration stems from the need to select a step-size. We return to this point below. Table 1 shows results for the adaptive versions of C+AG and AG for the case that is not known a priori, discussed in Section 6. Thus, further function-gradient evaluations are needed to estimate , and the number of function-gradient evaluations is increased accordingly. The reader will note from Table 1 that C+AG required only iterations for but function evaluations due to the overhead of initially estimating , and a similar pattern is noted for . The adaptive estimation doubles the function-gradient evaluations for AG from 1 to 2 per iteration.
In the previous paragraph and for the remainder of this paper, we speak of a “function-gradient evaluation”, which means, for a given , the simultaneous evaluation of and . We regard function-gradient evaluation as the atom of work. This metric may be inaccurate in the setting that can be evaluated much more efficiently than for an algorithm that separately uses and . However, in most applications evaluating together is not much more expensive than evaluating either separately. Theoretically, gradient evaluation is never more than a constant factor larger than function evaluation due to the existence of reverse-mode automatic differentiation; see, e.g., [21].
It is also known that NCG is fast for functions that are nearly quadratic. In particular, a classic result of Cohen [5] shows that NCG exhibits -step quadratic convergence near the minimizer provided that the objective function is nearly quadratic and strongly convex in this neighborhood.
Thus, there is seemingly a gap in the menu of available algorithms because NCG, though optimal for quadratic functions and fast for nearly quadratic functions, is not able to achieve reasonable complexity bounds for the larger class of smooth, strongly convex functions. On the other hand, the methods with the good complexity bounds for this class are all suboptimal for quadratic functions.
We propose C+AG to close this gap. The method is based on the following ideas:
-
1.
A line-search for NCG described in Section 2 is used that is exact for quadratic functions but could be poor for general functions. Failure of the line-search is caught by the progress measure described in the next item.
-
2.
A progress measure described in Section 3 for nonlinear conjugate gradient based on Nesterov’s estimate sequence is checked. The progress measure is inexpensive to evaluate on every iteration.
-
3.
Restarting in the traditional sense of NCG (i.e., an occasional steepest descent step) is used, as described in Section 4
-
4.
On iterations when insufficient progress is made, C+AG switches to AG to guarantee reduction in the progress measure as explained in Section 5.
-
5.
C+AG switches from AG back to NCG after a test measuring nearness to a quadratic is satisfied. When CG resumes, the progress measure may be modified to a more elaborate procedure discussed in Appendix A, although this elaborate progress measure is disabled by default.
When applied to a quadratic function, the progress measure is always satisfied (this is proved in Section 3), and hence all steps will be NCG (and therefore LCG) steps. The fact that the C+AG satisfies the running-time bound of AG for general convex functions follows because of the progress measure. The conjectured final theoretical property of the method, namely, -step quadratic convergence, is described in the Appendix B. Computational testing in Section 8 indicates that the running time of the method measured in function-gradient evaluations is roughly equal to whichever of AG or NCG is better for the problem at hand, and in some cases it outperforms both of them.
Both AG and C+AG use prior knowledge of . However, can be estimated by both methods, and may be taken to be 0 if no further information is available. Thus, both algorithms are useable, albeit slower, in the absence of prior knowledge of these parameters. We return to this topic in Section 6.
We conclude this introductory section with a few remarks about our previous unpublished manuscript [16]. That work explored connections between AG, GD, and LCG, and proposed a hybrid of NCG and GD. However, that work did not address the number of function-gradient evaluations because the the evaluation count for the line search was not analyzed. Closer to what is proposed here is a hybrid algorithm from the first author’s PhD thesis [15]. Compared to the PhD thesis, the proposed algorithm herein has several improvements including the line search and the method for switching from AG to CG as well as additional analysis.
2 NCG and line search
The full C+AG algorithm is presented in Section 7. In this section, we present the NCG portion of C+AG, which is identical to most other NCG routines and is as follows
while | |
Select ; | |
Confirm that satisfies the progress measure. | |
Select ; | |
; | |
end while |
For we use the Hager-Zhang formula [12], which is as follows:
For , we use the following formulas.
(4) | ||||
(5) | ||||
(6) |
The rationale for this choice of is as follows. In the case that (quadratic), and , and therefore and . In this case, is the exact minimizer of the univariate quadratic function .
In the case of a nonquadratic function, this choice of could be inaccurate, which could lead to a poor choice for . The progress measure in the next section will catch this failure and select a new search direction in this case.
As for the choice of , we mention that Dai and Yuan [7] carried out an extensive convergence study of different formulas for (not including the Hager-Zhang formula, but covering many others), and in the end, proposed a certain hybrid formula for . Note that Dai and Kou [8] propose another family with the interesting property [8, Theorem 4.2] that convergence is guaranteed for smooth, strongly convex functions, although no rate is derived.
Our experiments (not reported here) suggest that the choice of is not critical to the performance of C+AG. The Dai-Yuan paper points out that certain choices of will lead to nonconvergence if the line-search fails to satisfy the strong Wolfe conditions. However, our line-search does not satisfy even the weak Wolfe conditions. In other words, the criteria used in the previous literature to distinguish among the choices of formulas for may not be applicable to C+AG.
3 Progress measure
The progress measure is taken from Nesterov’s [20] analysis of the AG method. The basis of the progress measure is a sequence of strongly convex quadratic functions called an “estimate sequence” in [20].
The sequence is initialized with
(7) |
where . Then for is defined in terms of its predecessor via:
(8) |
Here, and are detailed below. Note that the Hessian of and of the square-bracketed quadratic function in (8) are both multiples of , and therefore inductively the Hessian of is a multiple of for all . In other words, for each there exists such that , where . The formulas for , , are straightforward to obtain from (8) given , , as well as and . These formulas appear in [20, p. 73] and are repeated here for the sake of completeness:
(9) | ||||
(10) | ||||
(11) |
We call the sequence the gradient sequence because the gradient is evaluated at these points.
To complete the formulation of , we now specify and . Scalar is selected as the positive root of the quadratic equation
(12) |
The fact that is easily seen by observing the sign-change in this quadratic over . A consequence of (12) and (9) is the identity
(13) |
Finally, C+AG has three cases for selecting gradient sequence . The first case is . The second and third cases are presented later.
The principal theorem assuring progress is Theorem 2.2.2 of Nesterov [20], which we restate here for the sake of completeness. The validity of this theorem does not depend on how the gradient sequence is selected in the definition of .
Theorem 1
(Nesterov) Suppose that for each , there exists a point , called the witness, satisfying . Then
(14) |
The sufficient-progress test used for CG is the condition of the theorem, namely, . That is, in the case of CG, the witness sequence is also the main sequence computed by CG. As long as this test holds, the algorithm continues to take CG steps, and the right-hand side of (14) assures us that the optimal complexity bound is achieved (up to constants) in the case of both smooth convex functions and smooth, strongly convex functions.
The main result of this section is the following theorem, which states that if the objective function is quadratic, then the progress measure is always satisfied by conjugate gradient.
Theorem 2
Assume . If , where is positive definite, and if the gradient sequence and witness sequence are the same as the CG sequence , then for every iteration .
Proof. The result clearly holds when by (7). Assuming , we now show that For ,
(15) | ||||
(16) | ||||
(17) | ||||
(18) | ||||
(19) | ||||
(20) |
Here, (15) is a restatement of (11) under the assumption that . Line (16) follows from the induction hypothesis. Line (17) follows from (13).
Line (18) follows because, according to the recursive formula (10), lies in the affine space . Similarly, lies in this space. Therefore, lies the th Krylov subspace . It is well known (see, e.g., [10]) that is orthogonal to every vector in this space.
Line (19) is a standard inequality for -smooth convex functions; see, e.g., p. 57 of [20]. Finally (20) follows because lies in the -dimensional affine space while minimizes over the same affine space, another well known property of CG.
We note that this proof yields another proof of Daniel’s result that conjugate gradient converges at a linear rate with a factor per iteration. Specifically, the two bounds are
We see that the reduction factor is better in Daniel’s bound because of the exponent rather than , which means approximately reduction of per iteration (assuming ) instead of . Furthermore, the multiplicative constant in Daniel’s bound is better as noted earlier.
A limitation of this proof is that it requires . In the case that the CG iterations follow a sequence of AG iterations, this equality will not hold. We return to this point in Appendix A.
4 Restarting CG
The classical method for coping with failure to make progress in nonlinear CG is ‘restarting’, which means taking a step using the steepest descent direction instead of the conjugate gradient direction. Our proposed C+AG method, when it detects insufficient progress on the th iteration (i.e., the inequality fails to hold), attempts two fall-back solutions. The first fall-back is restarting CG in the traditional manner (steepest descent). It should be noted that this restart does not play a role in the theoretical analysis of the algorithm, but we found that in practice it improves performance (versus immediately proceeding to the second fall-back of the AG method).
The issue of when to restart has received significant attention in the previous literature. One guideline is to restart every iterations. In more modern codes, restarting is done every iterations, where is a constant, e.g., Hager-Zhang’s CG-Descent restarts every iterations. We also have implemented this restart in our code, although it is usually not activated because some other test fails first.
Three other conditions for restarting from the previous literature, collectively termed the “Beale-Powell” conditions by Dai and Yuan [6], are
(21) |
(22) |
(23) |
where , , and . It should be noted that in exact arithmetic on a quadratic objective function, none of these tests will ever be activated. It should also be noted that Powell [24] as well as Dai and Yuan consider other restart directions (which we have not implemented) besides the steepest descent direction.
We have found that including these tests (BP1)–(BP3) caused the code to take more iterations in the majority of tests (although the difference in iteration counts was never large), so we have turned them off by default. In other words, the default values are , (i.e., we restart if is not a descent direction), and . Presumably this is because there are cases when progress is possible according to our progress measure even though a BP condition fails.
One additional restart condition in our code is that if the denominator of (6) is nonpositive, then we restart because this means that calculation of has failed.
A recent paper by Buhler et al. [3] considers nonlinear conjugate gradient for problems in machine learning and in particular the role of (BP) restarts. The motivation for their work is somewhat different from ours: they consider general objective functions, not necessarily smooth convex functions, and therefore accelerated gradient is not available for their class of problems. Their first main concern, costly line search, is not an issue for C+AG since its line search requires only one additional gradient per iteration. Their second main concern, nonconjugacy in search directions, is also less of a concern for C+AG since conjugacy is not an ingredient of the C+AG progress measure. They conclude that (BP1)–(BP3) (and (BP1) in particular) are important for a successful nonlinear CG implementation. The fact that their conclusions differ from ours arises from the different aims of the papers.
5 Switching to AG in the case of lack of progress
If the inequality fails to hold also for the steepest descent direction described in the previous section, then the second fall-back is to switch to a sequence of AG steps.
AG steps continue until the following “almost-quadratic” test is satisfied. Let
The termination test for AG is
(24) |
The rationale for this formula is as follows. One checks with a few lines of algebra that if were quadratic, then the identity holds, assuming that is defined as as in AG (see l. 46 of Algorithm C+AG, Part II below ). Thus, (24) tests whether in the neighborhood of is behaving approximately as a quadratic function would behave, which indicates that conjugate gradient might succeed.
Note that (24) involves an extra function-gradient evaluation since an ordinary AG iteration evaluates at but not at . Therefore, (24) is checked only every 8 iterations to reduce the overhead of the test.
Overall, the C+AG algorithm requires two function-gradient evaluations for a CG step, one to obtain the gradient at and the second to evaluate in (5). Similarly, the first fall-back requires two function-gradient evaluations. Finally, the accelerated gradient step requires another gradient evaluation. Therefore, the maximum number of function-gradient evaluations on a single iteration before progress is made is five. Therefore, Theorem 14 applies to our algorithm except for a constant factor of 5. In practice, on almost every step, either the CG step succeeds or AG is used, meaning the actual number of function-gradient evaluations per iteration lies between 1 and 2.
6 Estimating
The C+AG method as described thus far requires knowledge of and , the moduli of smoothness and strong convexity respectively. In case these parameters are not known, the method estimates and simply assumes . For many problems (including our examples) , meaning that convergence is governed by the second parenthesized of factor of (14). Thus, taking does not appear to significantly impede convergence.
As for estimating , we use the following procedure outlined in §10.4.2 of Beck [1]. Starting from an initial guess of , we first decrease by multiplying by or increase by multiplying by until the condition
is satisfied. This means that C+AG and AG require iterations for the initial estimate. On subsequent iterations, we re-estimate on the first iteration of consecutive sequences of CG iterations and on every iteration of AG. On iterations after the first, cannot decrease; it will either stay the same or increase. Beck proves that using this procedure does not worsen the iteration-complexity of AG when compared to the case that is known a priori. However, this procedure increases the number of function-gradient evaluations per AG step from one to approximately two. In the case of the conjugate gradient steps, the impact is negligible since only the first in a sequence requires the extra function-gradient evaluation.
It is not necessary to re-estimate on every CG iteration because the CG step uses only as the finite-difference step size in its procedure to determine as in (4)–(6). This dependence is mild in the sense that, assuming is quadratic, (4)–(6) will compute the same (correct) value of regardless of the step size. All computational tests in Tables 1 and 2 use the adaptive version of C+AG described in this section.
There are procedures in the literature for estimating also, for example, the procedure by Carmon et al. [4]. However, Carmon et al.’s procedure is costly as it involves several trial steps and a guess-and-update procedure for . Even in the pure quadratic case, estimating apparently requires multiple steps of the Lanczos method [10] and would be costly. We have not implemented it since, as mentioned above, taking appears to be satisfactory.
7 Pseudocode for C+AG
In this section we present pseudocode for the C+AG algorithm. The pseudocode includes the procedure for estimating . It does not, however, include the elaborate procedure for finding witnesses after CG is restarted as described in Appendix A. We did not include this in the pseudocode because it is disabled by default as discussed in the appendix. See the concluding remarks of the paper for a downloadable implementation in Matlab, which does include that procedure as an option. The input arguments are and , the objective function and gradient, , the initial guess, gtol, the termination criterion, and , , the smoothness modulus and the modulus of strong convexity respectively. Note that is a valid argument, and (not a number) is a signal to the algorithm to estimate .
The mathematical structure of the algorithm has already been described in previous sections, and in this section we will describe a few computational details. The flag onlyAG indicates that the algorithm is currently executing a block of AG statements. As mentioned in Section 5, once AG iterations begin, they continue uninterrupted until (24) holds, and this is checked every 8th iteration.
The variable counts the number of consecutive CG iterations without a restart. A restart means that is defined to be , i.e., a steepest descent step is taken. The code forces a restart after iterations. Such a test is typical in NCG algorithms. The theory for -step quadratic convergence requires a restart every iterations, but well known codes, e.g., CG-Descent [12] often use a longer interval.
The for-loop on l. 11 tries first a CG step and second a steepest descent step in order to make progress. Line 25 computes as discussed in Section 2. The test for sufficient progress in a CG step appears in l. 29. If sufficient progress is attained, then the next CG search direction is computed.
Line 38 can be reached if both attempts at CG fail to make sufficient progress. It is also reached if the onlyAG flag is set to ‘true’, meaning that the algorithm is currently inside a block of consecutive AG iterations. The statements beginning with 43 are the formulation of the AG method taken from [20]. Statement l. 48 implements the test for resuming CG described in Section 5.
8 Computational experiments
In this section we report on computational experiments with C+AG. We compared it to two other codes: AG coded by us based on (2.2.8) of [20] and CG-Descent by Hager and Zhang. We used C version 6.8 of CG-Descent with the Matlab front-end. We used it in memoryless mode, i.e., NCG rather than L-BFGS.
As for our own code C+AG, we discovered via experimentation that the more elaborate calculation of described in Appendix A diminished the performance of the code. In particular, as mentioned the additional overhead of 100% per iteration slowed the code down without improving the iteration count and thus was not used.
To the best of our knowledge, there is no standard benchmark set of smooth convex functions with a known , so instead we constructed our own test set of eight problem instances based on formulations that have occurred in the recent literature in data science.
The convergence criterion is , where for the ABPDN and LL problems described below, while for the HR problems. (None of the algorithms were able to converge to for the HR problems in fewer than iterations, so we loosened the criterion for that problem.) In the case of CG-Descent, the convergence criterion is based on the -norm rather than 2-norm. (The -norm convergence criterion is hardwired into the code, and we did not attempt to rewrite this fairly complex software.) Via some experiments not reported here, we found that stopping when approximately reproduced the criterion used for the other methods, so this was the termination criterion for CG-Descent.
The reported results for our C+AG routine used and in all cases, in other words, adaptive estimation of . We assume most users would select this mode since are often not known in advance. For AG, we tested both the known and unknown modes; this is indicated in the table below by “AG” and “AG/EstL.”
As mentioned in the introduction, we have reported on function-gradient evaluation counts since that is usually taken as the primary work-unit of first-order methods. We did not report on wall-clock time because CG-Descent, having been written in highly optimized C, has an advantage over AG and C+AG, which are written Matlab.
The first four problems are based on BPDN (basis pursuit denoising), that is, the unconstrained convex optimization problem:
in which and has fewer rows than columns, so that the problem is neither strongly convex nor smooth. However, the following approximation (called APBDN) is both smooth and strongly convex on any bounded domain:
where is a fixed scalar. It is easy to see that as , the original problem is recovered. As , and , where are the moduli of strong and smooth convexity respectively.
In our tests of ABPDN we took to be a subset of rows of the discrete-cosine transform matrix of size , where is an even power of 2. (This matrix and its transpose, although dense, can be applied in operations.) The subset of rows was selected to be those numbered by the first prime integers in order to get reproducible pseudorandomness in the choices. Similarly, in order to obtain a pseudorandom , we selected according to the formula . The value of was fixed at in all tests. Finally, we varied and and we tried both and for a total of four test cases.
The -penalty term in the original BPDN formulation leads to many entries of the solution equal to 0. This is no longer the case for ABPDN since the nondifferentiability at has been smoothed out. However, a simple scaling argument suggests that the threshold for “nearly zero” should be magnitude bounded above by . We determined that our computed solutions for the four ABPDN solutions had between 78% to 82% of entries nearly zero.
The second test case is logistic loss (LL), which is as follows:
where is a given matrix, and is a regularization parameter. Here, where . Row of , , is of the form , where is the vector of all 1’s and where . We seeded Matlab’s random number generator with the same seed on each run for reproducibility. This formulation arises from the problem of identifying the the best halfspace that contains noisy data points. We ran this test with with two values of , namely, and . This function is smooth and strongly convex. The function controls the strong convexity.
The third test case is Huber regression (HR). Given a matrix and a vector , Huber regression [14] has been proposed as a means to make linear least-squares regression more robust against outliers. In more detail, a cutoff is selected in order to define the function
Note that is differentiable and convex and behaves like for small and like for large . Finally, This function is smooth but not strongly convex, i.e., . We chose the sparse matrix with ’s on the main diagonal and ’s on the first sub diagonal. The vector was taken to be all 1’s except for the final entry, which is . (This is close to where ; in other words, is close to a right-hand side that has a 0-residual solution.) We fixed . We selected two choices for , namely, and .
Our results for the four algorithms on the eight problems are shown in Table 2. We set a limit of function-gradient evaluations for C+AG and AG.
Problem | %AG | C+AG | AG | AG/EstL | CG-Descent |
ABPDN | .03% | 55,891 | 518,019 | 982,919 | 82,472 |
ABPDN | 14% | 226,141 | 660,355 | 165,207 | |
ABPDN | .02% | 80,335 | 901,418 | 130,040 | |
ABPDN | 0% | 483,420 | 532,706 | ||
LL | 0% | 148 | 106,507 | 128 | |
LL | 0% | 140 | 362,236 | 125 | |
HR | 64% | 160,115 | 946,488 | ||
HR | 60% | 95,416 | 245,376 |
The results in Table 2 show that C+AG outperformed both AG and CG-Descent in most cases. In all cases, C+AG did as about as well as or better than whichever of AG or CG-Descent performed better.
9 Conclusions
We have presented an algorithm called C+AG, which is a variant of nonlinear conjugate gradient tailored to smooth, convex objective functions. It has a guaranteed rate of convergence equal to that of accelerated gradient, which is optimal for the class of problems under consideration in the function-gradient evaluation model of computation. The method reduces to linear conjugate gradient in the case that the objective function is quadratic.
The code and all the test cases are implemented in Matlab and available on Github under the project named ‘ConjugatePlusAcceleratedGradient’.
The C+AG code outperformed both AG and CG on most test cases tried. One interesting future direction is as follows. The method switches between CG and AG steps depending on the progress measure. A more elegant approach would be a formulation that interpolates continuously between the two steps. Indeed, it is possible (see, e.g., [16]) to write down a single parameterized update step in which one parameter value corresponds to AG and another to CG. But we do not know of a systematic way to select this parameter that leads to a complexity bound.
Another direction to pursue is incorporating restarts into AG. In particular, [22] propose a restart method that appears to work well in practice according to their experiments. Both AG and C+AG could use their restarts, although presumably the former would benefit more than the latter since AG steps are not used as frequently in C+AG compared to pure AG. However, to the best of our knowledge, the restart method is not guaranteed in the sense: It has not been proved that the bounds on AG iteration of Theorem 14 are still valid in the presence of restarts. Since our goal here was to provide a method with the iteration guarantee of AG, we did not incorporate their restarts.
Yet another extension would be to use memory of previous iterates. In the context of NCG, adding memory yields L-BFGS [21]. It is clearly possible to hybridize L-BFGS with AG, and it is likely that the progress measure proposed still holds for L-BFGS in the case that it is applied to a quadratic since L-BFGS reduces to LCG in this case. Note that some authors, e.g. [25], have also proposed adding memory to AG-like methods, so many combinations are possible.
Another interesting direction is to develop a conjugate gradient iteration suitable for constrained convex problems. Conjugate gradient is known to extend to the special case of minimizing a convex quadratic function with a Euclidean-ball constraint; see e.g. Gould et al. [11] and further remarks on the complexity in Paquette and Vavasis [23].
10 Acknowledgements
The authors are grateful to the referees of the previous version of this paper for their helpful comments.
Appendix A Restarting CG after AG
As mentioned in Section 5, if the sufficient-progress test fails for a CG iteration, then the method can fall back to AG iterations. After the AG termination test holds, the method resumes CG, say at iteration .
An issue with restarting CG is that the sufficient-progress test may not hold for the CG iterations even if the function is purely quadratic on the remaining iterations. This is because the proof of sufficient progress in Theorem 2 assumed that . However, we would not expect the equality to hold, where is the first iteration of CG, and therefore Theorem 2 does not apply.
We can address this issue with a more elaborate CG sufficient-progress test after resuming CG. The more elaborate test increases the number of function-gradient evaluations per CG iteration from two to four. This extra overhead, according to our experiments, overwhelmed any benefit from the more elaborate procedure.
We did observe the benefit of the elaborate procedure in a contrived test
case. In this contrived test, the objective function is quadratic, and
the C+AG code is modified in two ways. First, the initial block of iterations
is AG instead of CG, i.e., the only_ag
flag is set to true
at
initialization. Second, instead of setting , we add random noise
to the right-hand side. For this contrived test, indeed we observed for some
choices of the random noise that CG was never able to restart unless the elaborate
progress measure computation was enabled, and therefore the number of function-gradient
evaluations associated with the elaborate procedure was much smaller than
without it. However, we did not observe this behavior in any
naturally occurring test case.
Therefore, our default setting is not to use the elaborate test. This means that with our default settings, there is no theoretical guarantee that CG iterations can continue indefinitely upon their resumption after AG even if the objective function is purely quadratic on the level set of when CG resumes. However, the other theoretical guarantees of our method (that it has the same complexity as accelerated gradient and that it reduces to CG on a quadratic function) remain.
Despite the fact that the test is turned off by default, it is available in the code and may prove useful, and therefore we describe it here for the sake of completeness. Also, the proof-sketch of -step quadratic convergence in the next appendix requires that this procedure be used.
Above, we defined to be the iteration at which CG iterations are resumed. To simplify notation in the remainder of the section, assume . Thus, we consider CG starting with . As in Theorem 2, we assume the objective function is quadratic, say . Recall that linear CG generates a sequence of vectors (see, e.g., [21], §5.1) such that whenever (called “conjugacy”) and such that for all , , called the th Krylov space and denoted for (where ). Other properties are that is the minimizer of over the affine set and the equation .
The new progress-checking procedure augments the Krylov space with two additional directions on each iteration to assure that the analogs of (18) and (20), that is, (41) and (43) below, hold for the method. In more detail, it computes additional sequences of vectors ; ; and ; and scalars ; ; and whose formulas are forthcoming. Let and for , . For each , define
(25) |
which is not computed by the method but used in its derivation. The construction of these vectors and scalars inductively has the following properties.
-
1.
For all , . Furthermore, when writing as a linear combination of , the coefficients of are respectively. For this property and the next, in the degenerate case that are dependent, this property is understood to mean that there exists a way to write with coefficients .
-
2.
For all , . Furthermore, when writing as a linear combination of , the coefficients of are respectively.
-
3.
For , the vectors of are conjugate with respect to .
-
4.
For , define , and for , define . Observe that lies in . Then for all , is the minimizer of over .
-
5.
For all , vector is computed (as usual) from according to (10).
To initiate this sequence of properties, let
(26) |
This formula implies Property 1 holds. Properties 2–3 do not apply when . Assure Property 4 by solving a 1-dimensional minimization problem for , that is,
(27) |
Finally, Property 5 specifies how is computed.
Next, for the induction step, assume all the above properties hold for . Recall that (10) is used to obtain . Observe from (10) that is written as a linear combination
(28) |
where the scalars may be read off from (10). Note: we omit the subscripts on , and some other scalars in this discussion for clarity, since is fixed. In the upcoming formulas, if , take , , and to be zero. Let us define
(29) | ||||
(30) |
where are yet to be determined. We now establish that these formulas satisfy the above properties.
Starting with Property 1, we have
(31) | ||||
(32) | ||||
(33) |
Here, (31) follows by substituting (28) for and for ; (32) follows from rearranging and from substituting the definition of ; (33) adds and subtracts .
Consider the terms of (33) separately. The first term lies in with coefficients of on respectively by Property 1 inductively. The second term lies in with coefficients on respectively by Property 4 inductively. The third term lies in by the usual properties of CG. The fourth term lies in = . In this expansion, the coefficients of and are respectively. Finally, the last term obviously lies in . Therefore, if we define according to (29), then Property 1 holds for .
Next we turn to Property 2. Observe that
(34) | ||||
(35) |
Here, (34) follows from the definition (25) while (35) follows from the substitutions and and adding and subtracting .
Considering (35) term by term, the first term lies in with coefficients on inductively by Property 4. The second term lies in . The third term lies in . As in the preceding derivation, the fourth term lies in with coefficients on respectively. Again, we see now that (30) is chosen precisely so that the induction carries through on Property 2.
Now we turn to Property 3. By the induction hypothesis on Property 3, are conjugate to each other and to . This implies are conjugate to since for , , and , and similarly for . Thus, we see term-by-term that every term in the definitions of in (29)–(30) is already conjugate to . Thus, to ensure is also conjugate to and , solve a system of two linear equations for the scalars that appear in (29). (In fact, by conjugacy, the system decouples into two univariate linear equations that are solved via single division operations.) Similarly, to assure is conjugate to , we solve three linear equations for from (30), which again decouple into three separate equations.
Next, for Property 4, recall again from the theory of CG that minimizing over for which we have a conjugate basis of reduces to uncoupled 1-dimensional minimizations; indeed, this is the main purpose of conjugacy. However, is already minimal with respect to by the usual properties of CG, so it is necessary to minimize only with respect to . Therefore, to obtain , one defines
(36) |
where
(37) |
a problem that decouples into two simple equations.
Thus, we have established the following result:
Theorem 3
Now, finally, we can propose a progress measure assured to hold for quadratic functions, namely, . The proof that this holds is a straightforward rewriting of Theorem 2.
Theorem 4
If , where is positive definite, then for every iteration , where is the sequence of conjugate gradient iterates and is defined by (36).
Proof. The result clearly holds when by (7) and the fact that by the minimality of in the line . Assuming , we now show that . For ,
(38) | ||||
(39) | ||||
(40) | ||||
(41) | ||||
(42) | ||||
(43) |
Here, (38) is a restatement of (11). Line (39) follows from the induction hypothesis. Line (40) follows from (13).
Line (41) follows because, according to the recursive formula (10), lies in the affine space . Also, lies in this affine space and is optimal for over this space. Therefore, is orthogonal to every vector in and in particular to .
Line (42) is the standard inequality for -smooth convex functions. Finally (43) follows because by (25) and by Property 2. On the other hand minimizes over .
This concludes the discussion of how to compute in the case that is quadratic. In the general case, we do not have a matrix but only and . Therefore, we propose a method to evaluate the quantities in the preceding paragraphs in the general case. Assume inductively that we have , where corresponds to in the above equations and similarly corresponds to . Then all the formulas above may be evaluated using these vectors. Note that we already have vectors corresponding to and ; these are found in (4)–(6). We need these vectors to solve for the scalars assuring conjugacy.
To continue the induction, it is necessary to evaluate corresponding to . Multiplying both sides of (29) and (30) by the fictitious shows that we need to obtain the analog of the product . Note that this combination of appears in both right-hand sides of (29) and (30). This may be found by evaluating and then subtracting (which is already evaluated).
We also need to evaluate and in order to obtain (25) and check the progress measure . Thus, the cost of carrying out the method of this section is two extra function-gradient evaluations per iteration. As mentioned earlier, our computational experiments indicate that this 100% overhead is not compensated for by any reduction in iteration count in any test case, and therefore the method described in this section is disabled by default.
Appendix B Toward -step quadratic convergence
In previous sections, we showed the proposed C+AG method has the same complexity bound up to a constant factor as accelerated gradient. In this section we suggest that it has an additional complexity bound known to apply to nonlinear conjugate gradient, namely, -step quadratic convergence. This property is mainly of theoretical interest since -step quadratic convergence is not usually observed in practice (see, e.g., [21, p. 124]) for larger problems. Therefore, we will provide only a sketch of a possible proof and leave the proof, which is likely to be complicated, to future research.
We propose to follow the proof given by McCormick and Ritter [17] rather than the original proof by Cohen [5]. They argue that classical NCG is -step quadratically convergent provided that the line-search is sufficiently accurate and provided that the objective function is strongly convex in the neighborhood of the objective function and that its second derivative is Lipschitz continuous. Finally, they assume that nonlinear CG is restarted every iterations.
In order to apply this result to C+AG, we first need to argue that the sufficient-progress test will not prevent CG iterations. We showed in the last section that for quadratic functions, the sufficient-progress test always holds. A strongly convex function with a Lipschitz second derivative is approximated arbitrarily closely by a quadratic function in a sufficiently small neighborhood of the root. In particular, if we assume that is strictly larger than the largest eigenvalue of the Hessian in a neighborhood of the root, then inequality (42) is strictly satisfied, and small deviations from a quadratic function are dominated by the residual in (42).
Some other issues with [17] is that their version of NCG implements a step-limiter operation that is not present in our algorithm. It is not clear whether the step-limiter is a requirement for -step quadratic convergence or merely a device to simplify their analysis. Furthermore, [17] assume the Polak-Ribière choice of [21] rather than the Hager-Zhang step that we used. Note that [17] predates [12] by several decades. We conjecture that the analysis of [17] extends to [12].
The line-search accuracy required by [17] is as follows. On each iteration , , where is chosen by C+AG in (4)–(6) and . We sketch an argument that could prove as follows.
Let . It follows from [17] that . In other words, there is both an upper and lower bound on
independent of . It also follows from their results that . Write , where is the estimate of obtained from (4)–(6), that is . It follows by strong convexity and the equation that and . Again by these same assumptions, we can also derive that . By the Lipschitz assumption, for .
It also follows from the assumption of strict convexity and proximity to the root . The true minimizer is the root of and therefore satisfies the equation
i.e.,
The computed minimizer is . The integral in the previous line is bounded by , whereas is , and . Therefore, the intermediate value theorem applied to the above univariate equation for tells us that . This concludes the explanation of accuracy of the line-search.
References
- [1] Amir Beck. First-Order Methods in Optimization. SIAM, 2017.
- [2] S. Bubeck, Y. T. Lee, and Mohit Singh. A geometric alternative to Nesterov’s accelerated gradient descent. http://arxiv.org/abs/1506.08187, 2015.
- [3] C. K. Buhler, H. Benson, and D. Shanno. Regularized step directions in conjugate gradient minimization for machine learning. arXiv preprint arXiv:2110.06308, 2021.
- [4] Yair Carmon, John C. Duchi, Oliver Hinder, and Aaron Sidford. “Convex until proven guilty”: dimension-free acceleration of gradient descent on non-convex functions. In Proceedings of 2017 International Conference on Machine Learning, 2017.
- [5] A. Cohen. Rate of convergence of several conjugate gradient algorithms. SIAM Journal on Numerical Analysis, 9(2):248–259, 1972.
- [6] Y. Dai and Y. Yuan. Convergence properties of Beale-Powell restart algorithms. Science in China, Ser. A, 41:1142–1150, 1998.
- [7] Y. Dai and Y. Yuan. An efficient hybrid conjugate gradient method for unconstrained optimization. Annals of Operations Research, 103:33–47, 2001.
- [8] Yu-Hong Dai and Cai-Xia Kou. A nonlinear conjugate gradient algorithm with an optimal property and an improved Wolfe line search. SIAM J. Optimization, 23:296–320, 2013.
- [9] James W Daniel. The conjugate gradient method for linear and nonlinear operator equations. SIAM Journal on Numerical Analysis, 4(1):10–26, 1967.
- [10] G. H. Golub and C. F. Van Loan. Matrix Computations, 3rd Edition. Johns Hopkins University Press, Baltimore, 1996.
- [11] N. Gould, S. Lucidi, M. Roma, and P. Toint. Solving the trust-region subproblem using the Lanczos method. SIAM Journal on Optimization, 9(2):504–525, 1999.
- [12] W. Hager and H. Zhang. A new conjugate gradient method with guaranteed descent and an efficient line search. SIAM J. Optimization, 16:170–192, 2005.
- [13] Magnus Rudolph Hestenes and Eduard Stiefel. Methods of conjugate gradients for solving linear systems. Journal of Research of the National Bureau of Standards, 49:409–436, 1952.
- [14] P. J. Huber. Robust regression: asymptotics, conjectures, and Monte Carlo. Annals of Statistics, 1(5):799–821, 1973.
- [15] Sahar Karimi. On the relationship between conjugate gradient and optimal first-order methods for convex optimization. PhD thesis, University of Waterloo, 2014.
- [16] Sahar Karimi and Stephen Vavasis. A single potential governing convergence of conjugate gradient, accelerated gradient and geometric descent. https://arxiv.org/abs/1712.09498, 2017.
- [17] G. P. McCormick and K. Ritter. Alternative proofs of the convergence properties of the conjugate-gradient method. J. Optimization Theory and Applications, 13(5):497–518, 1974.
- [18] A. S. Nemirovsky and D. B. Yudin. Problem Complexity and Method Efficiency in Optimization. John Wiley and Sons, Chichester, 1983. Translated by E. R. Dawson from Slozhnost’ Zadach i Effektivnost’ Metodov Optimizatsii, 1979, Glavnaya redaktsiya fiziko-matematicheskoi literatury, Izdatelstva “Nauka”.
- [19] Y. Nesterov. A method for unconstrained convex minimization problem with the rate of convergence . Doklady AN SSSR (translated as Soviet Math. Dokl.), 269(3):543–547, 1983.
- [20] Y. Nesterov. Introductory Lectures on Convex Optimization. Kluwer, 2003.
- [21] J. Nocedal and S. Wright. Numerical Optimization, 2nd Edition. Springer, New York, 2006.
- [22] B. O’Donoghue and E. Candès. Adaptive restart for accelerated gradient schemes. Foundations of Computational Mathematics, 15(3):715–732, 2015.
- [23] C. Paquette and S. Vavasis. Potential-based analyses of first-order methods for constrained and composite optimization. http://arxiv.org/abs/1903.08497, 2019.
- [24] M. J. D. Powell. Restart procedures for the conjugate gradient method. Mathematical Programming, 12:241–254, 1977.
- [25] J. Zhang, B. O’Donoghue, and S. Boyd. Globally convergent type-I Anderson acceleration for nonsmooth fixed-point iterations. SIAM Journal on Optimization, 30(4):3170–3197, 2020.