  Computing the critical points of a polynomial function $q\in\mathbb
Q[X_1,\ldots,X_n]$ restricted to the vanishing locus $V\subset\mathbb R^n$ of
polynomials $f_1,\ldots, f_p\in\mathbb Q[X_1,\ldots, X_n]$ is of first
importance in several applications in optimization and in real algebraic
geometry. These points are solutions of a highly structured system of
multivariate polynomial equations involving maximal minors of a Jacobian
matrix. We investigate the complexity of solving this problem by using
Gr\"obner basis algorithms under genericity assumptions on the coefficients of
the input polynomials. The main results refine known complexity bounds (which
depend on the maximum $D=\max(deg(f_1),\ldots,deg(f_p),deg(q))$) to bounds
which depend on the list of degrees $(deg(f_1),\ldots,deg(f_p),deg(q))$: we
prove that the Gr\"obner basis computation can be performed in
$\delta^{O(\log(A)/\log(G))}$ arithmetic operations in $\mathbb Q$, where
$\delta$ is the algebraic degree of the ideal vanishing on the critical points,
and $A$ and $G$ are the arithmetic and geometric average of a multiset
constructed from the sequence of degrees. As a by-product, we prove that
solving such generic optimization problems with Gr\"obner bases requires at
most $D^{O(n)}$ arithmetic operations in $\mathbb Q$, which meets the best
known complexity bound for this problem. Finally, we illustrate these
complexity results with experiments, giving evidence that these bounds are
relevant for applications.
