Binary Integer Programming (BIP) is a special case of integer programming in which every decision variable is restricted to exactly two values: 0 or 1. These problems arise naturally in yes/no decisions — selecting projects from a portfolio, assigning workers to shifts, or activating equipment — where a continuous relaxation would produce meaningless fractional answers. TheDocumentation 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.
POST /api/v1/binary/solve endpoint solves such problems using the Branch and Bound algorithm, returning both the optimal 0/1 variable assignment and the full exploration tree so the search process can be visualized.
When to use
Use this endpoint when your LP has the additional requirement that all decision variables are binary integers (xᵢ ∈ {0, 1}). The objective function and constraints are otherwise identical in structure to those of the standard Simplex endpoint — same coefficient arrays, same inequality types, same right-hand sides.
The solver supports 2 to 5 binary decision variables. Every constraint must have the same number of coefficients as there are entries in the
objective array.Branch and Bound algorithm
The engine inbinary_engine.py performs a depth-first Branch and Bound search over the space of 0/1 assignments:
-
LP relaxation — at each node, the subproblem is solved as a continuous LP by
SimplexEngine, with every unfixed variable bounded to[0, 1]and every fixed variable forced toxᵢ ≤ 0(forxᵢ = 0) orxᵢ ≥ 1(forxᵢ = 1). -
Integer feasibility check — if the LP is optimal and all variable values are already integer (within
ε = 1e-6), the node is recorded as"integer"and, if its objective is better than the current incumbent, it becomes the new best solution. -
Bounding and pruning — if an incumbent already exists and the node’s LP relaxation value is no better than the current best (for maximization,
lp_val ≤ best_val; for minimization,lp_val ≥ best_val), the node is pruned as"pruned_bound". -
Infeasibility pruning — if the LP relaxation is infeasible or unbounded, the node is pruned as
"pruned_infeasible". -
Branching — when fractional variables remain, the algorithm selects the most fractional variable (the one closest to
0.5) as the branch variable. Two child nodes are pushed onto the DFS stack: one fixing that variable to1(explored first) and one fixing it to0. -
Node limit — the search terminates after at most 500 nodes (
MAX_NODES) to prevent runaway execution on large instances. If the limit is reached the response status is"limit".
Endpoint
Request
Coefficients of the objective function, one per binary variable. Length must be between 2 and 5.Example:
[1, 6, 10, 16] represents x₁ + 6x₂ + 10x₃ + 16x₄.Optimization direction. Accepted values:
"max" or "min".Array of linear constraint objects. At least one constraint is required. Constraint coefficients must each have the same length as
objective.Request example
The following problem selects a subset of four binary projects to maximize profit subject to a weight capacity of 22 units.Response
Final solution status. One of:
"optimal"— a globally optimal 0/1 solution was found."infeasible"— no feasible integer solution exists."limit"— the 500-node exploration limit was reached before proving optimality.
Optimal objective value for the best integer solution found.
null when the problem is infeasible.Dictionary mapping variable names to their optimal binary values (always
0 or 1), e.g. { "x1": 0, "x2": 1, "x3": 0, "x4": 1 }. null when infeasible.Total number of B&B nodes evaluated during the search.
Full exploration tree as a flat list of node objects. The frontend uses this array to render the Branch and Bound tree visualization. Parent–child relationships are encoded via
parent_id.Human-readable summary, e.g.
"Solución óptima encontrada con valor Z = 22.0. Nodos explorados: 5.".Response example
cURL example
Branch and Bound tree visualization
Thenodes array is designed to drive the frontend’s interactive tree diagram. Because every node records its node_id, parent_id, depth, edge_label, and status, the frontend can reconstruct the full directed tree without any additional API calls.
Each node is rendered with a colour that reflects its status:
| Status | Meaning | Typical color |
|---|---|---|
"branched" | Node was split further | Neutral / blue |
"integer" | Integer solution found | Green |
"pruned_bound" | Bound cut-off applied | Orange |
"pruned_infeasible" | LP was infeasible | Red |
edge_label (e.g. "x2 = 1") to show which branching decision led to each child node.