I constructed a projected gradient descent (ascent) algorithm with backtracking line search based on the book "Convex optimization," written by Stephen Boyd and Lieven Vandenberghe.
The problem what I consider and the pseudocode to solve it is presented as follows:
\begin{array}{cl} \text{maximize} & f(x) = \sum_{i=1}^N f_i(x_i)\\ \text{subject to} & {1_N}^T x \le c_1,\\ & x\succeq 0_N, \end{array} where $x\in\mathbb{R}^N$ is the design variable, $f_i:\mathbb{R} \to \mathbb{R}$ is a concave function with respect to $x_i$ for all $i\in\{1, 2, \ldots, N\}$, $f:\mathbb{R}^N \to \mathbb{R}$ is also a concave function with respect to $x$, $1_N$ is the $N$-dimensional vector with all elements equal to $1$, $0_N$ is the $N$-dimensional vector with all elements equal to $0$, and $\succeq$ represents elements-wise inequality, i.e., $i$th element of $x$ is nonnegative all $i=1, 2, \ldots, N$.
Next, the pseudocode of my program to solve the above problem is (based on Matlab grammar)
alpha = 0.1;
beta = 0.8;
x = zeros(N,1);
while true
grad = find_gradient(......); % N by 1 vector representing the gradient of f.
y1 = get_objective(x); % obtain the objective value for x.
t = 1;
while true
x_new = x + t*grad;
y2 = get_objective(x_new) % obtain the objective value for x_new.
if y2 < y1 + alpha*t*norm(grad)*norm(grad)
t = beta*t;
else
break;
end
end
proj_x_new = projection(x_new, c_1); % project x_new so that the constraints are satisfied.
if norm(proj_x_new-x) < 0.00001
break;
else
x = proj_x_new;
end
end
In the above code, the projection is conducted using quadratic programming function (embedded in Matlab, named "quadprog") to solve the following problem: \begin{array}{cl} \text{minimize} & \lVert x - x_{new} \rVert^2 \\ \text{subject to} & {1_N}^T x \le c_1,\\ & x\succeq 0_N. \end{array}
In most cases, it has been confirmed in a numerical way that the above program shows a fairly good convergence speed and provides a near optimal solution. HOWEVER, it sometimes diverge. NOT converge. As a result of checking the intermediate values of the simulation, infinite repetition occurs due to the projection process.
I really want to make my own fast gradient-based code to solve constrained convex problem. However, my own is diverging....... What is the problem?