From Convex Optimization to Nonconvex Optimization. Necessary and Sufficient Conditions for Global Optimality