Quadratic programming is a type of mathematical optimization problem where the objective or constraints include quadratic terms, often representing risk, smoothness, or squared error.  

In practical QP optimization work, those squared terms can capture realities that linear models approximate poorly, like variance in a portfolio, power losses, or deviation from targets. 

What is quadratic programming, in plain terms?

Quadratic programming (QP) chooses decision variables to optimize an objective that includes squared or cross-product terms. When quadratic terms appear in constraints as well, the problem is called quadratically constrained programming (QCP). Those quadratic terms let you model tradeoffs like risk vs. return, tracking error vs. service level, or smooth changes vs. aggressive moves. Many real systems have costs that grow faster than linearly, and QP captures that naturally. 

When should I use QP instead of linear programming?

Use QP when the economics of the decision are not well represented by straight lines. Common triggers include: 

  • Risk penalties (variance, tracking error) in finance and supply planning 
  • Squared deviation from a target (quality, demand matching, setpoints) 
  • Smoothness penalties (avoid sudden changes in production rates or controls) 
  • Physical relationships that are inherently quadratic (power losses, flow dynamics) 

 

If your costs and tradeoffs are truly linear or can be approximated acceptably with piecewise-linear terms, LP may remain simpler. Note that LP (linear programming) and MILP (mixed-integer linear programming) differ in whether integer variables are present; similarly, QP has continuous variants and mixed-integer variants (MIQP), so choose the formulation that matches your decision structure. 

What is convex quadratic programming, and why does it matter?

Convex quadratic programming means the quadratic objective curves upward (for minimization problems), so any local optimum is also a global optimum. This property extends to convex quadratic constraints, where the feasible region forms a convex set. Convexity matters because it enables stronger algorithmic guarantees: in convex QP, when the solver finishes, you can trust that the result is globally optimal for the given data and model. 

Importantly, Gurobi can solve both convex and non-convex quadratic programming problems to global optimality. Non-convex problems—where quadratic terms may create multiple local optima—are significantly more challenging and can require longer solution times, but Gurobi uses global optimization techniques such as spatial branch-and-bound to find provably optimal solutions, rather than settling for local optima. 

What changes when integers are involved (MIQP)?

Mixed-integer quadratic programming (MIQP) combines quadratic objectives with yes/no or integer decisions, like selecting which facilities to open, which assets to include, or which machines to turn on. The integers introduce combinatorial complexity, so runtime depends heavily on model structure and data. For convex MIQP, the continuous relaxation provides strong bounds, while non-convex MIQP presents the combined challenge of both non-convexity and discrete decisions. 

Where does quadratic programming show up in portfolio optimization?

A classic use in portfolio optimization is balancing expected return against risk, where risk is represented by a quadratic form derived from asset covariances. The decision variables are asset weights, often with constraints like budget, leverage limits, sector bounds, and turnover limits. If you add discrete choices (for example, minimum lot sizes or cardinality limits), the model becomes MIQP. 

What about energy and industrial systems?

In power and process operations, QP and QCP can model quadratic generation costs, transmission losses, or tracking objectives. Decisions might include dispatch levels across generators, storage charge/discharge, and ramping limits. The quadratic objective can encourage efficient, stable operation while linear and quadratic constraints enforce physics-based bounds and operational rules. 

How do I know if my QP is well-posed and solvable?

Start by validating units, bounds, and data ranges. Poor scaling or missing bounds can produce numerically fragile models. Also check that constraints reflect physical limits, and that the quadratic terms represent the intended penalty (for example, whether cross terms imply interactions you truly want). For convex models, verify that your quadratic matrix is positive semi-definite (PSD); for non-convex models, understand that solution times may be significantly longer. Performance depends on model structure, data quality, and solver settings, so prototype with realistic data and measure solution time and quality. 

Quadratic programming is a practical way to model decisions where squared penalties and interactions are central to the business problem, not a detail to approximate away. Convex QP and QCP support strong optimality guarantees and efficient solution methods, while non-convex formulations bring additionalmodeling power at the cost of more variable runtimes. 

Gurobi solves both convex and non-convex quadratic problems to global optimality, distinguishing it from many nonlinear solvers that only guarantee local solutions. If you frame decisions, objectives, and constraints around real operating rules and measurable KPIs, Gurobi serves as the mathematical optimization solver that helps you move from intuition-driven tuning to repeatable, auditable decision-making, with solution quality tracked via optimality and gap reporting. 

Additional Insight

OneChronos: Using Optimization and Combinatorial Auctions to Innovate Modern Trading

Learn More

National Institute for Environmental Studies

Learn More

Guidance for Your Journey

30 Day Free Trial for Commercial Users

Start solving your most complex challenges, with the world's fastest, most feature-rich solver.

Always Free for Academics

We make it easy for students, faculty, and researchers to work with mathematical optimization.

Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Academic License
Gurobi provides free, full-featured licenses for coursework, teaching, and research at degree-granting academic institutions. Academics can receive guidance and support through our Community Forum.

Search

Gurobi Optimization

Navigation Menu