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.

Pure Integer Programming (IP) solves linear optimization problems in which every decision variable must be a non-negative integer. Unlike Binary Integer Programming — where each variable is restricted to exactly 0 or 1 — pure integer variables can take any non-negative integer value (0, 1, 2, 3, …). The solver uses a Branch and Bound algorithm that systematically explores candidate solutions while pruning regions that cannot improve the best integer solution found so far.

How Branch and Bound Works

The algorithm begins by solving the LP relaxation of the problem at the root node (integrality constraints are temporarily dropped). It then proceeds depth-first through a search tree:
  1. Integer solution found — if all variables in the LP solution are already integers, the node is recorded as a candidate and the best-known bound is updated.
  2. Prune by infeasibility — if the LP relaxation at a node is infeasible or unbounded, the subtree is discarded.
  3. Prune by bound — if the LP objective at a node is no better than the current best integer solution, the subtree is discarded.
  4. Branch — the algorithm selects the most-fractional variable (the one whose fractional part is closest to 0.5) and creates two child nodes:
    • Floor child: adds the constraint xᵢ ≤ ⌊v⌋
    • Ceil child: adds the constraint xᵢ ≥ ⌈v⌉
Each node carries its own lower_bounds and upper_bounds dictionaries that accumulate all branching constraints from root to that node. The search stops when no more nodes remain, or the 500-node safety limit is reached.
Pure Integer vs. Binary Integer: In Binary Integer Programming every variable is fixed between 0 and 1, so branching simply assigns a variable to 0 or to 1. In Pure Integer Programming, variables can grow arbitrarily, so each branch instead tightens a lower or upper bound — tracked independently for every node in the tree.

Endpoint

POST /integer/solve

Request

Send a JSON body matching IntegerRequest. The structure is identical to a standard Simplex request — the engine enforces integrality automatically.

Body fields

objective
float[]
required
Coefficients of the objective function, one per decision variable. Must contain between 2 and 5 elements. Variables are labelled x1, x2, … in the order they appear.Example: [5, 4] represents the objective 5x1 + 4x2.
goal
string
required
Optimization direction. Accepted values: "max" or "min".
constraints
Constraint[]
required
Array of linear constraints. Each constraint object contains:

Response

Top-level fields

status
string
Result status of the solver run:
  • "optimal" — a best integer solution was found and confirmed.
  • "infeasible" — no feasible integer solution exists.
  • "limit" — the 500-node exploration limit was reached; the best incumbent (if any) is returned.
objective_value
float | null
The optimal objective value achieved by the integer solution, or null when infeasible.
variables
object | null
Mapping of variable names to their optimal integer values, e.g. {"x1": 3, "x2": 2}. null when infeasible.
nodes_explored
integer
Total number of Branch and Bound nodes evaluated during the search.
nodes
IntegerNode[]
Full list of every node visited during the search. Used by the frontend to render the interactive Branch and Bound tree visualization.
message
string
Human-readable summary of the result, including the optimal value and the total number of nodes explored.

Example

Maximize Z = 5x1 + 4x2 subject to:
  • 6x1 + 4x2 ≤ 24
  • x1 + 2x2 ≤ 6
  • x1, x2 ≥ 0 and integer
curl -X POST http://localhost:8000/integer/solve \
  -H "Content-Type: application/json" \
  -d '{
    "objective": [5, 4],
    "goal": "max",
    "constraints": [
      { "coefficients": [6, 4], "inequality": "<=", "rhs": 24 },
      { "coefficients": [1, 2], "inequality": "<=", "rhs": 6 }
    ]
  }'
{
  "status": "optimal",
  "objective_value": 21.0,
  "variables": { "x1": 3, "x2": 1 },
  "nodes_explored": 5,
  "nodes": [
    {
      "node_id": 0,
      "parent_id": null,
      "depth": 0,
      "lower_bounds": {},
      "upper_bounds": {},
      "lp_value": 21.333333,
      "lp_vars": { "x1": 3.333333, "x2": 1.0 },
      "status": "branched",
      "branched_on": "x1",
      "branch_direction": null,
      "edge_label": null
    },
    {
      "node_id": 1,
      "parent_id": 0,
      "depth": 1,
      "lower_bounds": { "x1": 4.0 },
      "upper_bounds": {},
      "lp_value": 20.0,
      "lp_vars": { "x1": 4.0, "x2": 0.0 },
      "status": "integer",
      "branched_on": null,
      "branch_direction": "ceil",
      "edge_label": "x1 ≥ 4"
    },
    {
      "node_id": 2,
      "parent_id": 0,
      "depth": 1,
      "lower_bounds": {},
      "upper_bounds": { "x1": 3.0 },
      "lp_value": 21.0,
      "lp_vars": { "x1": 3.0, "x2": 1.5 },
      "status": "branched",
      "branched_on": "x2",
      "branch_direction": "floor",
      "edge_label": "x1 ≤ 3"
    }
  ],
  "message": "Solución entera óptima: Z = 21.0. Nodos explorados: 5."
}
The nodes array is consumed directly by the frontend tree visualization. Each node’s node_id and parent_id form the edges of the directed graph, and edge_label is rendered on the connecting arc.

Build docs developers (and LLMs) love