Skip to main content

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.

The /api/v1/simplex/solve endpoint accepts a linear objective function and a set of linear constraints, then applies the Simplex algorithm to find the optimal solution. Along with the final tableau the response includes a per-iteration snapshot of every pivot step, and — for 2-variable problems — a graphical payload ready for plotting.

Request

POST /api/v1/simplex/solve
Content-Type: application/json
objective
list[float]
required
Coefficients of the objective function, one per decision variable. Must contain between 2 and 5 elements. The number of elements determines the number of decision variables (x1, x2, …, x5).Example: [5, 4, 3] represents 5x1 + 4x2 + 3x3.
goal
string
required
Optimisation direction. Accepted values: "max" or "min".
constraints
list[Constraint]
required
At least one linear constraint. Every constraint must have the same number of coefficients as objective.

Response

A successful call returns a SimplexResponse object.
status
string
Outcome of the solve. One of "optimal", "unbounded", or "infeasible".
objective_value
float | null
The optimal value of the objective function. null when status is not "optimal".
variables
object | null
Map of variable names to their optimal values, e.g. {"x1": 3.0, "x2": 2.5, "x3": 0.0}. null when status is not "optimal".
iterations
integer | null
Total number of pivot iterations performed. null when status is not "optimal".
tableau_headers
list[string] | null
Column labels of the final simplex tableau (includes decision variables, slacks, and "RHS"). null when status is not "optimal".
tableau_rows
list[TableauRow] | null
Rows of the final simplex tableau. null when status is not "optimal".
message
string | null
Human-readable status message describing the result.
graphical
GraphicalData | null
Graphical representation of the feasible region. Only populated when the problem has exactly 2 decision variables; otherwise null.
iteration_tableaux
list[IterationTableau] | null
Ordered list of tableau snapshots, one per pivot iteration.

Example

Maximize 5x1 + 4x2 + 3x3 subject to:
  • 6x1 + 4x2 + 2x3 ≤ 240
  • 3x1 + 2x2 + 5x3 ≤ 270
  • 5x1 + 6x2 + 5x3 ≤ 420
curl -X POST https://api.example.com/api/v1/simplex/solve \
  -H "Content-Type: application/json" \
  -d '{
    "objective": [5, 4, 3],
    "goal": "max",
    "constraints": [
      {"coefficients": [6, 4, 2], "inequality": "<=", "rhs": 240},
      {"coefficients": [3, 2, 5], "inequality": "<=", "rhs": 270},
      {"coefficients": [5, 6, 5], "inequality": "<=", "rhs": 420}
    ]
  }'
{
  "status": "optimal",
  "objective_value": 220.0,
  "variables": {
    "x1": 40.0,
    "x2": 0.0,
    "x3": 0.0
  },
  "iterations": 2,
  "tableau_headers": ["x1", "x2", "x3", "s1", "s2", "s3", "RHS"],
  "tableau_rows": [
    {"basic_variable": "x1", "values": [1.0, 0.667, 0.333, 0.167, 0.0, 0.0, 40.0]},
    {"basic_variable": "s2", "values": [0.0, 0.0, 4.0, -0.5, 1.0, 0.0, 150.0]},
    {"basic_variable": "s3", "values": [0.0, 2.667, 3.333, -0.833, 0.0, 1.0, 220.0]}
  ],
  "message": "Optimal solution found",
  "graphical": null,
  "iteration_tableaux": [
    {
      "iteration": 1,
      "entering": "x1",
      "leaving": "s1",
      "tableau_headers": ["x1", "x2", "x3", "s1", "s2", "s3", "RHS"],
      "tableau_rows": [
        {"basic_variable": "x1", "values": [1.0, 0.667, 0.333, 0.167, 0.0, 0.0, 40.0]},
        {"basic_variable": "s2", "values": [0.0, 0.0, 4.0, -0.5, 1.0, 0.0, 150.0]},
        {"basic_variable": "s3", "values": [0.0, 2.667, 3.333, -0.833, 0.0, 1.0, 220.0]}
      ]
    }
  ]
}
When the problem has exactly 2 decision variables, the graphical field in the response is populated with line data, feasible polygon vertices, and the optimal point — useful for rendering a 2-D plot on the client side.
All constraint coefficients arrays must have the same length as objective. Mismatched lengths return HTTP 422 Unprocessable Entity.

Health Check

GET /api/v1/simplex/health Returns a simple liveness confirmation for the Simplex service.
curl https://api.example.com/api/v1/simplex/health
{
  "status": "ok",
  "service": "simplex-optimizer-api"
}

Build docs developers (and LLMs) love