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.Â
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.Â
Use QP when the economics of the decision are not well represented by straight lines. Common triggers include:Â
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.Â
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.Â
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.Â
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.Â
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.Â
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.Â
Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.
Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.