Linear Programming Solver (LP)

Find the best possible outcome when your objective and constraints are all linear. A linear programming solver maximizes or minimizes a linear objective, such as profit or cost, subject to resource limits, and returns the optimal decision values.

Solve Linear Program →

What is Linear Programming?

Linear programming (LP) is a mathematical method for finding the best outcome, such as maximum profit or minimum cost, in a model whose objective and constraints are all linear functions of the decision variables. It is one of the most widely used techniques in operations research because so many real allocation problems fit its form.

An LP model has three parts: decision variables (the quantities you choose), an objective function to maximize or minimize, and constraints that limit the feasible choices, such as available materials, labor or budget. The solver searches the feasible region defined by the constraints for the point that optimizes the objective.

A key property of linear programs is that the optimal solution always lies at a corner (vertex) of the feasible region, which is what makes methods like the simplex algorithm efficient. Beyond the optimal values, LP also yields sensitivity information, including shadow prices that show how much the objective would improve if a constraint were relaxed.

In plain terms: When you're trying to get the most of something (profit) or the least of something (cost), and everything scales in straight lines, LP finds the best mix. You tell it what you're deciding, what you want to optimize, and your limits, and it finds the sweet spot, plus how much each limit is really costing you.

The Three Parts

Decision Variables

The quantities you control, such as how much of each product to make. LP allows these to take any continuous (fractional) value.

Objective Function

The linear quantity to maximize or minimize, such as total profit or total cost, expressed in terms of the decision variables.

Constraints

Linear limits on the variables, such as resource, capacity or demand restrictions, defining the feasible region.

Key Formulas

Maximize (or minimize): c₁x₁ + c₂x₂ + … + cnxn
Subject to: ai1x₁ + … + ainxn ≤ bi
And: xj ≥ 0 (non-negativity)
Optimum lies at a vertex of the feasible region

Reading the Solution

The solver returns the optimal values of the decision variables and the resulting objective value. Because the optimum sits at a corner of the feasible region, the binding constraints, those met with equality, are the ones limiting further improvement.

Shadow prices (dual values) tell you how much the objective would change per unit relaxation of each binding constraint, revealing which resources are most valuable to acquire more of. This sensitivity analysis is often as useful as the optimal solution itself for real decisions.

Assumptions & Validation

Linearity

The objective and all constraints are linear in the decision variables.

If violated: For nonlinear relationships, use nonlinear programming.

Divisibility

Variables may take fractional values.

If violated: If variables must be whole numbers, use integer programming.

Certainty

Coefficients are known with certainty.

If violated: For uncertain data, use stochastic or robust optimization.

⚠️ Check assumptions first

Linear programming assumes the objective and constraints are strictly linear, that variables can take fractional values, and that all coefficients are known. If any variable must be a whole number, such as a number of trucks or open facilities, LP can give a fractional answer that does not make sense, and integer programming is required. Nonlinear relationships or significant uncertainty also take the problem outside standard LP.

When NOT to Use Linear Programming Solver

Whole-Number Decisions

When variables must be integers, use integer programming instead of rounding LP results.

Multiple Conflicting Goals

To balance several competing objectives, use goal programming.

Nonlinear Relationships

When the objective or constraints are nonlinear, use nonlinear optimization methods.

Industry Applications

Product Mix

Decide how much of each product to make to maximize profit within resource limits.

Blending & Diet

Find the least-cost mix of ingredients that meets nutritional or quality specifications.

Resource Allocation

Allocate limited labor, budget or capacity across competing activities.

Production Planning

Plan production and scheduling to minimize cost or maximize output under constraints.

Frequently Asked Questions

What is linear programming?

Linear programming is a method for finding the best outcome, such as maximum profit or minimum cost, in a model where the objective and all constraints are linear functions of the decision variables. It consists of decision variables, an objective to optimize, and constraints defining feasible choices. Widely used in operations research, it efficiently solves resource-allocation problems that fit its linear form.

Why does the optimal solution lie at a corner of the feasible region?

Because both the objective and the constraints are linear, the objective improves steadily in a fixed direction across the feasible region, a convex polygon or polytope. The best value in such a direction is always reached at a vertex, where constraints intersect. This property is the basis of the simplex algorithm, which moves efficiently from corner to corner toward the optimum.

What is a shadow price?

A shadow price, or dual value, is the amount by which the optimal objective value would change per unit increase in the right-hand side of a binding constraint. It reveals how valuable an additional unit of a limiting resource would be. Shadow prices are a key output of sensitivity analysis, helping decide which constraints are most worth relaxing to improve the result.

What is the difference between linear and integer programming?

Linear programming allows decision variables to take any fractional value, while integer programming requires some or all variables to be whole numbers. Many real decisions, such as how many facilities to open or vehicles to use, are inherently integer. Integer programming is computationally harder than linear programming, and rounding a linear solution to whole numbers can give an infeasible or suboptimal answer, which is why the integer form exists.

What are the assumptions of linear programming?

The main assumptions are linearity, the objective and constraints are linear in the variables; divisibility, variables can take fractional values; and certainty, the coefficients are known exactly. When variables must be integers, integer programming is used; when relationships are nonlinear, nonlinear programming applies; and when data is uncertain, stochastic or robust optimization is more appropriate.

What kinds of problems does linear programming solve?

Linear programming solves resource-allocation problems such as product mix, where limited resources are divided among products to maximize profit; blending and diet problems, finding least-cost mixtures meeting specifications; and production and distribution planning. The transportation and assignment problems are specialized linear programs. Its versatility across allocation, blending, scheduling and planning makes it a cornerstone of operations research.

Optimize a Linear Objective Under Constraints

Solve a linear program and read the optimal values and shadow prices. Free during Beta.

Solve Linear Program →