Linear Programming Solver

Interactive linear programming calculator using the simplex method. Enter an LP in standard form, see each simplex iteration, and get the optimal solution or an infeasibility/unboundedness diagnosis.

Full original guide (expanded)

Linear Programming Solver

Use this linear programming calculator to solve small LP models with the simplex method. Enter your objective coefficients and constraints in standard form; the tool builds the simplex tableau, runs each pivot step, and reports the optimal solution or explains why the problem is infeasible or unbounded.

Educational, small-scale solver – intended for learning, coursework, and quick sanity checks, not for production optimization or large industrial models.

Simplex method – standard-form LP

Between 2 and 6 decision variables.

Between 1 and 8 inequality constraints.

For minimization, multiply the objective by −1 and interpret the result accordingly.

Standard form assumed by this solver: maximize \( z = c_1 x_1 + \dots + c_n x_n \) subject to \( a_{i1} x_1 + \dots + a_{in} x_n \le b_i \) with \( b_i \ge 0 \) and \( x_j \ge 0 \). The algorithm adds slack variables and applies the primal simplex method.

Objective function coefficients

Enter the coefficients of the objective function \( z = c_1 x_1 + c_2 x_2 + \dots + c_n x_n \).

Constraint coefficients

Each constraint is interpreted as \( a_{i1} x_1 + \dots + a_{in} x_n \le b_i \), with \( b_i \ge 0 \). If your model has \( \ge \) or equality constraints, rewrite them in ≤ form (or use textbook transformations) before entering them.

What is linear programming?

Linear programming (LP) is a method for optimizing a linear objective function subject to linear constraints. A typical model looks like:

\[ \text{Maximize} \quad z = c_1 x_1 + c_2 x_2 + \dots + c_n x_n \] \[ \text{subject to} \quad \begin{cases} a_{11} x_1 + \dots + a_{1n} x_n \le b_1 \\ \vdots \\ a_{m1} x_1 + \dots + a_{mn} x_n \le b_m \\ x_1, \dots, x_n \ge 0 \end{cases} \]

Here, the \( x_j \) are decision variables (production quantities, flows, investments, etc.), the coefficients \( c_j \) measure contribution to the objective, and the constraints represent resource limits, capacity, time, or other linear restrictions.

How the simplex method works (high-level)

The simplex method is a classic algorithm for solving LPs. It operates on basic feasible solutions (corner points of the feasible region) and moves from one corner to a better one until no further improvement is possible.

Key ideas of the simplex method:

  • Introduce slack variables to turn each ≤ constraint into an equality.
  • Represent the system in a tableau, with basic and non-basic variables.
  • Choose an entering variable (with a negative coefficient in the objective row for max problems).
  • Choose a leaving variable using the minimum ratio test to maintain feasibility.
  • Pivot on the chosen element to update the tableau, producing a new basic solution.

Geometrically, each pivot corresponds to moving along an edge of the polyhedron defined by the constraints, always improving (or at least not worsening) the objective, until an optimal vertex is reached or the problem is detected as unbounded.

Worked example (maximization problem)

Consider the LP:

\[ \text{Maximize} \quad z = 3x_1 + 5x_2 \] \[ \text{subject to} \quad \begin{cases} x_1 + x_2 \le 4 \\ 2x_1 + x_2 \le 5 \\ x_1, x_2 \ge 0 \end{cases} \]

In standard form, we add slack variables \( s_1, s_2 \) to obtain:

\[ x_1 + x_2 + s_1 = 4, \quad 2x_1 + x_2 + s_2 = 5, \quad s_1, s_2 \ge 0. \]

The initial basic feasible solution is given by setting \( x_1 = x_2 = 0 \), so \( s_1 = 4, s_2 = 5 \), and \( z = 0 \). The simplex algorithm then chooses the best entering variable (with the most negative coefficient in the objective row), performs pivots, and quickly reaches the optimal solution, which you can reproduce in this calculator by entering the coefficients above.

When does the simplex method fail or need care?

  • Infeasible problems: no solution satisfies all constraints. The solver will typically fail to find a feasible basic solution or detect inconsistencies.
  • Unbounded problems: the objective can grow without bound while remaining feasible, often because a direction improves the objective without violating constraints.
  • Degeneracy and cycling: some basic variables can become zero, causing the algorithm to stall or cycle without progress unless anti-cycling rules are used (beyond this educational tool).
  • Equality and ≥ constraints: these require surplus and artificial variables or two-phase simplex / Big-M methods, which are not implemented in this simplified interface.

Graphical interpretation (2-variable LPs)

For LPs with only two decision variables \( x_1 \) and \( x_2 \), you can also solve the problem graphically:

  1. Plot each constraint as a straight line and shade the feasible side.
  2. Identify the polygon representing the intersection of all feasible half-planes.
  3. Plot the objective function as a family of parallel lines.
  4. Slide the objective line in the direction of improvement (upwards for max, downwards for min) until it touches the feasible region for the last time – at a vertex.

The simplex method essentially performs the same search over vertices but using algebraic operations instead of a geometric picture.

Frequently asked questions

Can I use this tool for integer programming (IP/MILP)?

No. This calculator assumes continuous variables. Integer programming problems, where some or all variables must take integer values, require branch-and-bound, cutting planes, or other specialized algorithms. You can sometimes use this tool to solve the LP relaxation and then reason about integer solutions by hand.

How big a problem can I safely enter here?

For transparency and browser performance, the interface is limited to at most 6 variables and 8 constraints. This is more than enough for typical textbook and exam exercises and allows you to see the full simplex iteration log without being overwhelmed.

What if I have ≥ constraints or equalities?

Try to rewrite them in standard ≤ form if possible. A constraint such as \( 3x_1 + x_2 \ge 7 \) can often be multiplied by −1 to obtain \( -3x_1 - x_2 \le -7 \). True equality constraints generally require introducing surplus and artificial variables and using two-phase simplex or Big-M, which this minimal solver does not implement.

How should I validate critical results?

For teaching, homework, and small planning problems, this tool is a convenient way to verify hand calculations and build intuition. For production decisions, safety-critical engineering, or large-scale planning, always validate models and solutions with professional-grade optimization software and, where relevant, an experienced operations research practitioner.


Audit: Complete
Formula (LaTeX) + variables + units
This section shows the formulas used by the calculator engine, plus variable definitions and units.
Formula (extracted LaTeX)
\[\text{Maximize} \quad z = c_1 x_1 + c_2 x_2 + \dots + c_n x_n\]
\text{Maximize} \quad z = c_1 x_1 + c_2 x_2 + \dots + c_n x_n
Formula (extracted LaTeX)
\[\text{subject to} \quad \begin{cases} a_{11} x_1 + \dots + a_{1n} x_n \le b_1 \\ \vdots \\ a_{m1} x_1 + \dots + a_{mn} x_n \le b_m \\ x_1, \dots, x_n \ge 0 \end{cases}\]
\text{subject to} \quad \begin{cases} a_{11} x_1 + \dots + a_{1n} x_n \le b_1 \\ \vdots \\ a_{m1} x_1 + \dots + a_{mn} x_n \le b_m \\ x_1, \dots, x_n \ge 0 \end{cases}
Formula (extracted LaTeX)
\[\text{Maximize} \quad z = 3x_1 + 5x_2\]
\text{Maximize} \quad z = 3x_1 + 5x_2
Formula (extracted LaTeX)
\[\text{subject to} \quad \begin{cases} x_1 + x_2 \le 4 \\ 2x_1 + x_2 \le 5 \\ x_1, x_2 \ge 0 \end{cases}\]
\text{subject to} \quad \begin{cases} x_1 + x_2 \le 4 \\ 2x_1 + x_2 \le 5 \\ x_1, x_2 \ge 0 \end{cases}
Formula (extracted LaTeX)
\[x_1 + x_2 + s_1 = 4, \quad 2x_1 + x_2 + s_2 = 5, \quad s_1, s_2 \ge 0.\]
x_1 + x_2 + s_1 = 4, \quad 2x_1 + x_2 + s_2 = 5, \quad s_1, s_2 \ge 0.
Formula (extracted LaTeX)
\[','\\]
','\
Formula (extracted text)
\[ \text{Maximize} \quad z = c_1 x_1 + c_2 x_2 + \dots + c_n x_n \] \[ \text{subject to} \quad \begin{cases} a_{11} x_1 + \dots + a_{1n} x_n \le b_1 \\ \vdots \\ a_{m1} x_1 + \dots + a_{mn} x_n \le b_m \\ x_1, \dots, x_n \ge 0 \end{cases} \]
Formula (extracted text)
\[ \text{Maximize} \quad z = 3x_1 + 5x_2 \] \[ \text{subject to} \quad \begin{cases} x_1 + x_2 \le 4 \\ 2x_1 + x_2 \le 5 \\ x_1, x_2 \ge 0 \end{cases} \]
Formula (extracted text)
\[ x_1 + x_2 + s_1 = 4, \quad 2x_1 + x_2 + s_2 = 5, \quad s_1, s_2 \ge 0. \]
Variables and units
  • No variables provided in audit spec.
Sources (authoritative):
Changelog
Version: 0.1.0-draft
Last code update: 2026-01-19
0.1.0-draft · 2026-01-19
  • Initial audit spec draft generated from HTML extraction (review required).
  • Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
  • Confirm sources are authoritative and relevant to the calculator methodology.
Verified by Ugo Candido on 2026-01-19
Profile · LinkedIn
Formulas

(Formulas preserved from original page content, if present.)

Version 0.1.0-draft
Citations

Add authoritative sources relevant to this calculator (standards bodies, manuals, official docs).

Changelog
  • 0.1.0-draft — 2026-01-19: Initial draft (review required).