This example shows how to solve a simple concave fractional problem, in which the objective is to maximize the ratio of a nonnegative concave function and a positive convex function. Concave fractional problems are quasiconvex programs (QCPs). They can be specified using disciplined quasiconvex programming (DQCP), and hence can be solved using CVXR.
Problem Formulation
Our goal is to maximize the function
\[
\frac{\sqrt{x}}{\exp(x)}.
\]
This function is not concave, but it is quasiconcave, as can be seen by inspecting its graph.
The below code specifies and solves the QCP using DQCP. The concave fractional function is DQCP-compliant because the ratio atom is quasiconcave (actually quasilinear), increasing in the numerator when the denominator is positive, and decreasing in the denominator when the numerator is nonnegative.
Is DQCP? TRUE
Optimal value: 0.4288819
x: 0.4999465
Note the explicit solver = "SCS". DQCP bisection necessarily generates feasibility subproblems that are marginally infeasible as the query point approaches the optimal ratio, and interior-point solvers can fail to certify infeasibility there: with the default solver (Clarabel), this example stalls and errors with “Max iterations hit during bisection” — in CVXPY just as in CVXR. First-order solvers such as SCS certify the near-boundary subproblems cleanly, so the bisection converges.
The optimal value of \(x\) is approximately \(0.5\), which corresponds to the peak of the function \(\sqrt{x}/\exp(x)\). We can verify this analytically: setting the derivative to zero,