The Simplex endpoint accepts a linear objective function and a set of linear constraints, then applies the Big-M simplex algorithm to find the optimal solution. It supports both maximization and minimization goals, handles mixed constraint types (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/FabianeloV/Metodo-simplex/llms.txt
Use this file to discover all available pages before exploring further.
<=, >=, =), and returns not only the final variable values but also the complete tableau at every iteration — making it practical for both production optimization and step-by-step educational inspection.
When to use
Use this endpoint when you need to solve a linear programming (LP) problem of the form:The solver supports 2 to 5 decision variables. Every constraint must have exactly as many coefficients as there are variables in the objective function. Problems with exactly 2 variables additionally receive a
graphical payload — see Graphical Method for details.Big-M algorithm
The engine insimplex_engine.py uses the Big-M method to handle all constraint types in a single phase:
-
Objective conversion — minimization problems are converted to maximization internally by negating the objective coefficients (
sign = -1). The final value is negated back before it is returned. -
Row normalization — any constraint row whose right-hand side is negative is multiplied by
-1and its inequality is flipped, guaranteeingb ≥ 0throughout. -
Auxiliary variable construction
<=constraint → adds a slack variablesᵢwith coefficient+1.>=constraint → adds a surplus variablesrᵢ(-1) plus an artificial variableaᵢ(+1).=constraint → adds an artificial variableaᵢ(+1) only.
-
Big-M penalty — each artificial variable receives a coefficient of
1 000 000in the objective row, making it extremely costly to keep artificials in the basis. -
Pivot selection
- Entering variable: column with the most negative coefficient in the objective row.
- Leaving variable: minimum ratio test (
RHS / pivot column entry) among rows where the entry is positive (> ε).
- Gaussian elimination — the pivot row is divided by the pivot element; then every other row (including the objective row) has a multiple of the pivot row subtracted to produce a unit column.
-
Termination checks
- Optimal: no negative coefficient remains in the objective row.
- Unbounded: a pivot column has no positive entry in the constraint rows.
- Infeasible: after optimality, an artificial variable remains in the basis with a value greater than
ε.
iteration_tableaux array.
Endpoint
Request
Coefficients of the objective function, one per decision variable. Length must be between 2 and 5.Example:
[3, 2, 5] represents 3x₁ + 2x₂ + 5x₃.Optimization direction. Accepted values:
"max" or "min".Array of constraint objects. At least one constraint is required. Every constraint must have the same number of coefficients as
objective.Request example
The following problem maximizes3x₁ + 2x₂ + 5x₃ subject to three resource constraints — the same example shown in the project README.
Response
Solution status. One of
"optimal", "unbounded", or "infeasible".Optimal value of the objective function.
null when no solution exists.Dictionary mapping variable names to their optimal values, e.g.
{ "x1": 0.0, "x2": 100.0, "x3": 230.0 }. Variable values are rounded to 8 decimal places. null when no solution exists.Number of pivot operations performed.
Column labels for the final tableau, e.g.
["Básica", "Z", "x1", "x2", "x3", "s1", "s2", "s3", "RHS"]. Artificial-variable columns are omitted.Rows of the final simplex tableau, including the objective (
Z) row.One snapshot per iteration (iteration
0 is the initial tableau before any pivots).Populated only when
objective has exactly 2 coefficients. Contains constraint lines, the feasible polygon, corner vertices, and the optimal point in 2D coordinates. See Graphical Method for the full field reference.Human-readable summary, e.g.
"Se encontró una solución óptima después de 3 iteración(es).".Response example
cURL example
Automatic graphical output for 2-variable problems
When theobjective array has exactly 2 elements, the endpoint automatically calls the graphical engine and appends a graphical object to the response. This object contains everything required to render a 2D feasibility plot — constraint boundary lines, the shaded feasible polygon, corner vertices, the optimal objective line, and the optimal point. No separate request is needed.