
Image credit: Huang et al. (2022)
This article continues a three-part series on convex optimization. Across the series, we examine:
- How to determine if a function is convex.
- Properties and operations that preserve convexity.
- Standard forms of convex optimization problems.
- The Karush-Kuhn-Tucker (KKT) conditions: what they are and when they apply.
- Mathematical derivations, with an SVM-like example and various convex loss functions.
- A broad survey of commonly used convex functions in optimization.
Series Division:
- Part 1: Fundamentals, Convexity Criteria, and Examples.
- Part 2: Duality, KKT Conditions, and Advanced Applications.
- Part 3: Convex Loss Functions.
Checking that an objective is convex does not yet tell us how to handle constraints. We introduce Lagrange multipliers, which assign a coefficient to each constraint, and use them to derive the dual problem. The Karush-Kuhn-Tucker (KKT) conditions then connect this dual problem to the original optimum. We work through a soft-margin support vector machine (SVM) and a score-maximization problem with a Kullback–Leibler (KL) divergence constraint.
Recap: The supporting inequality for a convex function
Part 1 established that a differentiable convex function on an open convex domain satisfies
If its gradient vanishes at , no point in that domain has a smaller value. Below, we apply this reasoning to the Lagrangian and use feasibility and complementary slackness to relate it to the constrained objective.
3. Duality and Optimality Conditions in Convex Optimization.
The primal problem optimizes the original variables subject to constraints. The dual problem uses Lagrange multipliers to obtain bounds on the primal optimum. The KKT conditions identify when a feasible primal point and valid multipliers give the same value. The assumptions below explain when such multipliers exist.
3.1 Standard Form of a Convex Optimization Problem
A convex optimization problem typically takes the form:
where is convex, each is convex, and each is affine. Here we take these functions to be finite and differentiable on an open convex domain. Slater's condition requires a point in that domain satisfying all equalities and all inequalities strictly. For a convex problem with finite optimal value, this condition gives strong duality and attainment of the dual optimum. See Boyd and Vandenberghe's duality notes for the general domain formulation.
3.2 Karush-Kuhn-Tucker (KKT) Conditions
The KKT conditions are sufficient for global optimality in the differentiable convex setting above. A constraint qualification such as Slater's condition also makes them necessary at an attained optimum. Consider the problem
Under Slater's condition, an optimal point has Lagrange multipliers and satisfying:
-
Stationarity:
-
Primal Feasibility:
-
Dual Feasibility:
-
Complementary Slackness:
Conversely, any point and multipliers satisfying these conditions solve the convex problem. Without a constraint qualification, an optimum need not have multipliers satisfying stationarity.
Application Case I: Soft-Margin SVM
We apply the KKT conditions to the soft-margin SVM. Let be features, the labels, and a penalty parameter. The variables are , , and slack variables . The primal formulation is
subject to margin and nonnegativity constraints:
Let and be the Lagrange multipliers. Form the Lagrangian:
To derive the dual, we differentiate with respect to each primal variable and set the derivatives to zero:
-
Stationarity w.r.t :
-
Stationarity w.r.t :
-
Stationarity w.r.t :
Since , we get .
We then substitute back into the Lagrangian, eliminating to obtain the dual problem:
subject to and . The stationarity equations remove the primal variables from the dual objective. The constraints on the multipliers remain: they are required for the Lagrangian infimum to be finite.
Application Case II: Score Maximization under a KL Constraint
Consider a fixed feature-label pair with classes and fixed class-score vectors . Define
Here, is the shifted logit score for class . We introduce a distribution and a radius . This example maximizes an average score over distributions in a Kullback–Leibler (KL) ball around the uniform distribution. Its dual involves log-sum-exp, which connects the calculation to softmax and cross-entropy; the constrained objective itself is not a supervised cross-entropy loss.
For each candidate , the average is . The feature-label pair and all scores stay fixed. We optimize the distribution of this auxiliary class index, not a distribution of training datasets. The primal problem is
subject to
In words:
- We want to maximize a linear function of .
- must lie in the probability simplex.
- The constraint is a bound on KL divergence from the uniform distribution. We use . A smaller radius requires the distribution to remain closer to uniform.
Proving Convexity
Although the objective is a maximization of a linear function, we can equivalently view it as
where is the feasible set:
- Probability simplex:
- Entropic constraint:
The objective is linear, so its negative is convex. The probability simplex is convex, and is convex: each term has second derivative in the interior and extends continuously to zero. Its sublevel set is therefore convex. Intersecting these two feasible sets gives a convex optimization problem.
Strict Feasibility and Slater’s Condition
To use strong duality, we typically invoke Slater’s condition. We need a strictly feasible point that satisfies
- for all
A simple choice is the uniform distribution Then
If , the uniform distribution is strictly feasible, so Slater's condition holds. When , KL divergence forces the uniform distribution; that boundary case can be solved directly.
Forming the Lagrangian
Let be the Lagrange multiplier for and let be the multiplier for the entropic constraint Define
For this maximization problem, we subtract the inequality term. Keeping nonnegativity in the domain, the Lagrangian is
Rewriting,
Solving for
The dual function is given by
The sum-to-one constraint now appears in the Lagrangian. We therefore do not impose it again when taking this supremum. For , the maximizing coordinates are positive, so we can differentiate with respect to and set the derivative to zero:
Hence,
implying
Minimizing the dual function over enforces . This yields
Solving for in terms of leads to
so
Substituting this value of gives a normalized candidate distribution for each :
Constructing the Dual Problem
After eliminating , the dual problem reduces to
At the boundary, define by continuity from the right. Thus the dual objective is defined even when the softmax expression cannot be evaluated at zero. For , strong duality identifies the minimum dual value with the primal optimum.
At an optimum, complementary slackness gives
In other words,
- If the KL constraint is slack, then .
- If , the KL constraint is active.
- An active constraint alone does not imply a strictly positive multiplier.
For an interior optimum, differentiation gives . Thus an interior minimizer chooses the softmax distribution whose KL divergence equals the prescribed radius.
Primal Solution from Optimal Dual Variables
If the optimal multiplier satisfies , the primal solution is
This is a softmax distribution with temperature , not its reciprocal. The boundary cases require separate treatment. If , the solution is uniform. Let and let be its size. If , the distribution uniform on is feasible and reaches the largest possible score, so it is optimal and is dual-optimal. For nonconstant scores and , the optimal multiplier is positive and the normalized softmax formula applies.
Only distributions supported on can attain the largest score. Among them, the uniform distribution has the smallest KL divergence from the uniform distribution on all classes, namely . The radius must therefore reach this threshold before an optimum can place all mass on maximizing classes.
Interpretation
- Temperature: The multiplier controls concentration in the softmax distribution. If this problem is solved separately for each observation, its multiplier may differ across observations; that is a modeling construction, not by itself a guarantee about knowledge distillation.
- Distributional robustness: The optimization considers the worst average score over a specified KL neighborhood of a reference distribution. It does not, on its own, establish robustness to mislabeled observations or outliers.
- Entropy: Since the reference distribution is uniform, the KL constraint is equivalent to a lower bound on entropy. The reference distribution and radius determine which alternatives are allowed.
Conclusion:
The examples follow the same sequence: state the constraints, form the Lagrangian, derive stationarity conditions, and examine the multipliers. Part 3: Convex Loss Functions complements this discussion with a reference to the functions that appear in optimization objectives.
References & Further Reading
- Boyd, S., & Vandenberghe, L. (2004). Convex Optimization. Cambridge University Press.
- Hastie, T., Tibshirani, R., & Friedman, J. (2009). The Elements of Statistical Learning.
- Schölkopf, B., & Smola, A. (2001). Learning with Kernels. MIT Press.
