We study an optimization problem with the feasible set being a real algebraic variety X and whose parametric objective function \(f_u\) is gradient-solvable with respect to the parametric data u. This class of problems includes Euclidean distance and maximum likelihood optimization. For these particular optimization problems, a prominent role is played by the ED and ML correspondence, respectively. We associate an optimization correspondence with our generalized optimization problem and show that it is equidimensional. This leads to the notion of algebraic degree of optimization on X. We apply these results to p-norm optimization and define the p-norm distance degree of X, which coincides with the ED degree of X for \(p=2\) . Finally, we derive a formula for the p-norm distance degree of X as a weighted sum of the polar classes of X under suitable transversality conditions.