4 - Linear, Quadratic & Conic Optimization
Before we touch a solver, clear a small corner of the desk and keep one blank sheet of paper beside you. Today that sheet matters more than any software: every important model in this blog will first have to survive a hand calculation.
Optimization often arrives wearing intimidating notation: vectors, cones, multipliers, matrix inequalities, solver logs. The central question, however, is wonderfully ordinary: among all decisions that obey the rules, which one best serves our purpose? In this blog we will learn three increasingly expressive languages for answering that question—linear programming (LP), quadratic programming (QP), and second-order cone programming (SOCP). We will not begin with software. We will begin with a decision, derive every mathematical object, solve small instances by hand, and only then discuss algorithms and code.
The running competition case is the 2024 CUMCM Problem C on crop-planning. A publicly displayed national excellent paper formulates a seven-year planting strategy over heterogeneous plots, seasons, crops, rotation rules, uncertain yield, price, cost, and demand. That case is useful because it reveals both the power and the danger of optimization: writing “maximize profit” is easy; encoding what can actually be planted, sold, rotated, and managed is the real work. We will reconstruct the core model independently rather than copying the paper’s equations or numerical answer. The original paper remains the source of record in the CUMCM excellent-paper archive .
Every optimization model must expose five things: decision variables, objective, constraints, data, and validation. If one is missing, the solver may still return a number, but you do not yet have a defensible decision.
1. From a Decision to a Mathematical Program
Suppose a small campus kitchen must choose how many trays of rice bowls and salad bowls to prepare for lunch. A rice tray earns
Pause before calculating. What is under our control? Not profit, rice stock, or demand. We control the numbers of trays. Let
Profit becomes
This is a linear program because the objective and every constraint are affine. “Linear” does not mean easy or one-dimensional. It means each expression is a weighted sum of decisions plus a constant; there are no products such as
In matrix form an LP can be written
Here
Natural language usually hides the algebra in three verbs. “At most,” “capacity,” and “cannot exceed” produce
Logical phrases require more care. “Plant crop
A clinic schedules nurses for four shifts. Each nurse can work at most two consecutive shifts; each shift needs a minimum number of nurses. What should the decision variable mean? Which rule is a coverage constraint, and which rule needs binary logic? Write the meanings before writing any equation.
2. Geometry, Vertices, and Why LP Works
Each kitchen inequality describes a half-plane. Their intersection is the feasible region. Because intersections of half-spaces are convex, a line segment joining any two feasible points stays feasible.
The objective
For two variables, list candidate vertices. The labor and salad-demand boundaries intersect at
This hand calculation also supplies a unit test. If a solver returns
A set
An interior convex combination cannot be strictly better than both endpoints. Repeatedly moving toward an extreme point preserves or improves the objective. This is the mathematical idea behind vertex-search methods such as simplex.
An optimization run has more outcomes than “success” and “error”: it may be optimal, infeasible, unbounded, or numerically difficult. Never make an infeasible model feasible by quietly deleting constraints. Introduce explicit slack, price the violation, and explain which promise must be relaxed.
3. Duality: The Price of a Scarce Resource
Consider
Assign a nonnegative price
Thus
This is weak duality. Under standard feasibility conditions, LP strong duality says the best primal value equals the best dual value. The dual variable
At the kitchen optimum
Complementary slackness makes the relationship precise:
A resource can carry positive price only when its constraint binds; a positive activity must have zero reduced cost. This converts a solver result into an explanation: which rule limits the decision, and what is the marginal value of relaxing it?
4. Quadratic Objectives: Risk, Tracking, and Diminishing Returns
Linear objectives assume marginal value is constant. Often it is not. A schedule may be penalized for deviating from a target; a portfolio may trade return against variance; a control input may be penalized for changing too sharply. These lead to
When
Ordinary least squares is a QP:
So
For another example, two generators provide
5. KKT Conditions: A Common Language
For
The Karush–Kuhn–Tucker conditions are
$$
\begin{aligned}
\nabla_xL(x^*,\lambda^*,\nu^*)&=0 &&\text{stationarity},\
g_i(x^*)&\le0,quad h_j(x^*)=0 &&\text{primal feasibility},\
\lambda_i^*&\ge0 &&\text{dual feasibility},\
\lambda_i^g_i(x^)&=0 &&\text{complementary slackness}.
\end{aligned}
$$
For convex problems satisfying a qualification such as Slater’s condition, these conditions are sufficient as well as necessary. For nonconvex problems they may describe only a local stationary point.
Take
The correction occurs only along the constraint normal and has exactly the magnitude needed to reach the boundary.
6. Norms, Uncertainty, and Second-Order Cones
The canonical second-order cone is
This language includes LPs, many convex quadratic constraints, robust linear constraints under ellipsoidal uncertainty, portfolio risk limits, and geometric location problems.
Suppose resource usage is uncertain:
The worst perturbation is
with equality when
an SOCP constraint. Uncertainty does not automatically require simulation; the right uncertainty geometry can yield a tractable deterministic model.
If
7. Algorithms and Numerical Evidence
Simplex walks between adjacent vertices and provides useful basis sensitivity information. Interior-point methods move through the interior and solve Newton systems associated with barrier-regularized KKT equations. First-order methods use gradients and projections; they scale farther but may need more iterations for high accuracy.
For an inequality
As
and a line search that remains feasible.
Use LP/MILP solvers for linear relationships and discrete decisions, convex QP when the Hessian is positive semidefinite, and SOCP when norms or ellipsoidal robustness appear. Do not send a convex model to a genetic algorithm merely because the heuristic is easier to describe. Do not claim a global optimum for a nonconvex heuristic without a valid bound or proof.
Scale variables when coefficients differ by many orders of magnitude. After solving, report primal residuals, constraint violation, dual residuals, and duality gap—not only a status string.
8. Winning-Paper Case: 2024 CUMCM Crop Planning
The real case asks for crop decisions across years, seasons, plots, and crops. Let
and
To avoid the nonlinear expression
If surplus is wasted, its price is zero. If it sells at half price, revenue is
Core rules are:
and, for legumes
Incompatible plot-crop-season combinations are fixed to zero. The resulting model is a MILP. The excellent paper uses a differential-evolution genetic algorithm and later incorporates CVaR and correlation. A strong audit first asks which parts are already linear and whether an exact MILP solver can provide a benchmark. Even if the full instance is large, solve a reduced exact model.
For a hand test, take two 10-mu plots, two years, and crops wheat
This tests compatibility, rotation, legume coverage, and accounting. Only after it passes should we trust a seven-year workbook.
The lesson is not that one algorithm name is superior. It is that a plausible heatmap can violate rotation, a high profit can come from selling more than demand, and an unlinked binary variable can be meaningless. Recompute the objective from exported decisions and check every rule independently.
9. Implementation and Verification
1 | import cvxpy as cp |
Audit primal feasibility with
$$r_p=\max{|Ex-d|\infty,\ |(Ax-b)+|_\infty},$$
recompute the objective, check units and integrality, and inspect business rules independently. Perturb important inputs. If a 1% demand change replaces the whole schedule, the recommendation needs a stability warning even if profit barely changes.
For integer models, report best feasible value
“Timed out” is not “failed.” A 0.4% gap may support a decision; an unreported gap does not.
10. A Defensible Optimization Report
A reader should be able to reconstruct the chain:
- define every decision with indices and units;
- write the objective as an accounting identity;
- group constraints by physical, temporal, logical, and policy meaning;
- classify the model and justify the classification;
- explain solver choice and termination criteria;
- verify a hand-sized instance;
- report residuals, bounds, and active constraints;
- translate dual values into operational language;
- stress-test uncertain coefficients;
- state what the model omits.
LP teaches disciplined translation. QP teaches curvature and compromise. SOCP teaches that useful nonlinear structure can remain globally tractable. The shared habit is more important than the labels: model the decision faithfully, exploit structure honestly, and treat verification as part of the mathematics.
One small easter egg before you leave: return to the kitchen model and increase available labor from 72 to 73. The best profit rises by exactly the labor shadow price predicted by the dual. Keep increasing it one minute at a time and watch for the first moment when that prediction fails. That breakpoint is where sensitivity analysis stops being a slogan and becomes something you can see.
Sources and further reading
- CUMCM official site and excellent-paper display for the 2024 crop-planning case.
- Stephen Boyd and Lieven Vandenberghe, Convex Optimization, Chapters 4–6.
- CVXPY documentation for disciplined convex programming.
The next blog goes deeper into convexity proofs, conjugates, duality, proximal operators, first-order rates, and algorithms for models too large to hand directly to a generic solver.
- Title: 4 - Linear, Quadratic & Conic Optimization
- Author: Gavin0576
- Created at : 2026-09-15 18:00:18
- Updated at : 2026-10-23 07:06:57
- Link: https://jiangpf2022.github.io/blog//2026/09/15/Mathematical-Modeling-04-Linear-Quadratic-and-Conic-Optimization/
- License: This work is licensed under CC BY-NC-SA 4.0.